X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gedcom_lex_common.c;h=5d734c44689adb6e8fe9ae0b46c9bb15594af1f9;hb=8093e53a57e174b019f07760f5bf815271ceee9b;hp=d547ea4fa8eb6683e920cd60cef8772dc8250784;hpb=70151ec5721c6d6d6595a325ab10c73873c4df41;p=gedcom-parse.git diff --git a/gedcom_lex_common.c b/gedcom_lex_common.c index d547ea4..5d734c4 100644 --- a/gedcom_lex_common.c +++ b/gedcom_lex_common.c @@ -12,10 +12,11 @@ #ifndef IN_LEX -#include "gedcom.tab.h" -#include "gedcom.h" +#include "gedcom_internal.h" #include "multilex.h" #include "encoding.h" +#include "gedcom.h" +#include "gedcom.tab.h" #define YY_NO_UNPUT @@ -76,13 +77,14 @@ int test_loop(ENCODING enc, char* code) line_len = 0; #define CHECK_LINE_LEN \ - { if (line_len != (size_t)-1) \ + { if (line_len != (size_t)-1) { \ line_len += strlen(yytext); \ - if (line_len > MAXGEDCLINELEN * encoding_width) { \ - gedcom_error("Line too long, max %d characters", \ - MAXGEDCLINELEN); \ - line_len = (size_t)-1; \ - return BADTOKEN; \ + if (line_len > MAXGEDCLINELEN * encoding_width) { \ + gedcom_error("Line too long, max %d characters", \ + MAXGEDCLINELEN); \ + line_len = (size_t)-1; \ + return BADTOKEN; \ + } \ } \ } @@ -264,6 +266,10 @@ int test_loop(ENCODING enc, char* code) return CLOSE; \ } \ else { \ + /* Reset our state */ \ + current_level = -1; \ + level_diff = MAXGEDCLEVEL; \ + /* ... then terminate lex */ \ yyterminate(); \ } \ }