From: Peter Verthez Date: Sun, 2 Dec 2001 14:00:32 +0000 (+0000) Subject: Reset the state properly for new files. X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=5d0394aa935ca4c58f5695fb7a488e8d79c026db;p=gedcom-parse.git Reset the state properly for new files. --- diff --git a/gedcom_lex_common.c b/gedcom_lex_common.c index 5829633..1eeab45 100644 --- a/gedcom_lex_common.c +++ b/gedcom_lex_common.c @@ -265,6 +265,10 @@ int test_loop(ENCODING enc, char* code) return CLOSE; \ } \ else { \ + /* Reset our state */ \ + current_level = -1; \ + level_diff = MAXGEDCLEVEL; \ + /* ... then terminate lex */ \ yyterminate(); \ } \ } diff --git a/multilex.c b/multilex.c index 60bb0a3..8cac810 100644 --- a/multilex.c +++ b/multilex.c @@ -14,7 +14,7 @@ #include "multilex.h" #include "encoding.h" -int line_no = 1; +int line_no; typedef int (*lex_func)(void); lex_func lf; @@ -98,6 +98,7 @@ int gedcom_parse_file(char* file_name) ENCODING enc; int result = 1; FILE* file = fopen (file_name, "r"); + line_no = 1; if (!file) { gedcom_error("Could not open file '%s'\n", file_name); return 1; @@ -110,6 +111,7 @@ int gedcom_parse_file(char* file_name) result = gedcom_parse(); } lexer_close(); + fclose(file); return result; }