From: Daniel Kolesa Date: Tue, 19 May 2015 14:44:33 +0000 (+0100) Subject: eolian: cleaner cyclic import checks X-Git-Tag: v1.15.0-alpha1~505 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=30515bc946622dcc03322916184f36003e40b062;p=platform%2Fupstream%2Fefl.git eolian: cleaner cyclic import checks --- diff --git a/src/lib/eolian/database_fill.c b/src/lib/eolian/database_fill.c index 00dd224..58eaace 100644 --- a/src/lib/eolian/database_fill.c +++ b/src/lib/eolian/database_fill.c @@ -218,6 +218,8 @@ eo_parser_database_fill(const char *filename, Eina_Bool eot) if (eot && eina_hash_find(_parsedeots, filename)) return EINA_TRUE; + if (eot) eina_hash_set(_parsingeots, filename, (void *)EINA_TRUE); + ls = eo_lexer_new(filename); if (!ls) { @@ -254,12 +256,16 @@ eo_parser_database_fill(const char *filename, Eina_Bool eot) done: if (eot) - eina_hash_set(_parsedeots, filename, (void *)EINA_TRUE); + { + eina_hash_set(_parsedeots, filename, (void *)EINA_TRUE); + eina_hash_set(_parsingeots, filename, (void *)EINA_FALSE); + } eo_lexer_free(ls); return EINA_TRUE; error: + if (eot) eina_hash_set(_parsingeots, filename, (void *)EINA_FALSE); eo_lexer_free(ls); return EINA_FALSE; } diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index 30b1ced..774bf14 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -1798,22 +1798,21 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot) check(ls, TOK_VALUE); eina_strbuf_append(buf, ls->t.value.s); eina_strbuf_append(buf, ".eot"); - if (eina_hash_find(_parsingeots, ls->t.value.s)) + if (!(found = eina_hash_find(_tfilenames, eina_strbuf_string_get(buf)))) { pop_strbuf(ls); snprintf(errbuf, sizeof(errbuf), - "cyclic import '%s'", ls->t.value.s); + "unknown import '%s'", ls->t.value.s); eo_lexer_syntax_error(ls, errbuf); } - if (!(found = eina_hash_find(_tfilenames, eina_strbuf_string_get(buf)))) + if (eina_hash_find(_parsingeots, found)) { pop_strbuf(ls); snprintf(errbuf, sizeof(errbuf), - "unknown import '%s'", ls->t.value.s); + "cyclic import '%s'", ls->t.value.s); eo_lexer_syntax_error(ls, errbuf); } pop_strbuf(ls); - eina_hash_set(_parsingeots, ls->t.value.s, (void *)EINA_TRUE); if (!eo_parser_database_fill(found, EINA_TRUE)) { pop_strbuf(ls); @@ -1821,7 +1820,6 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot) "error while parsing import '%s'", ls->t.value.s); eo_lexer_syntax_error(ls, errbuf); } - eina_hash_set(_parsingeots, ls->t.value.s, (void *)EINA_FALSE); pop_strbuf(ls); eo_lexer_get(ls); check_next(ls, ';');