Reset the state properly for new files.
authorPeter Verthez <Peter.Verthez@advalvas.be>
Sun, 2 Dec 2001 14:00:32 +0000 (14:00 +0000)
committerPeter Verthez <Peter.Verthez@advalvas.be>
Sun, 2 Dec 2001 14:00:32 +0000 (14:00 +0000)
gedcom_lex_common.c
multilex.c

index 58296331b732313651202cf5042a1234097c3889..1eeab459d8e6c8c1579e19a8050ada9dee47fcc0 100644 (file)
@@ -265,6 +265,10 @@ int test_loop(ENCODING enc, char* code)
       return CLOSE;                                                           \
     }                                                                         \
     else {                                                                    \
       return CLOSE;                                                           \
     }                                                                         \
     else {                                                                    \
+      /* Reset our state */                                                   \
+      current_level = -1;                                                     \
+      level_diff = MAXGEDCLEVEL;                                              \
+      /* ... then terminate lex */                                            \
       yyterminate();                                                          \
     }                                                                         \
   } 
       yyterminate();                                                          \
     }                                                                         \
   } 
index 60bb0a32bd8672d6819e66d41e78bb88c6c5995f..8cac810164dfdf79ca18a50c051ac180285cfa34 100644 (file)
@@ -14,7 +14,7 @@
 #include "multilex.h"
 #include "encoding.h"
 
 #include "multilex.h"
 #include "encoding.h"
 
-int line_no = 1;
+int line_no;
 
 typedef int (*lex_func)(void);
 lex_func lf;
 
 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");
   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;
   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();
     result = gedcom_parse();
   }
   lexer_close();
+  fclose(file);
   
   return result;
 }
   
   return result;
 }