Let init_called be global (used from encoding.c).
authorPeter Verthez <Peter.Verthez@advalvas.be>
Sun, 22 Sep 2002 13:20:17 +0000 (13:20 +0000)
committerPeter Verthez <Peter.Verthez@advalvas.be>
Sun, 22 Sep 2002 13:20:17 +0000 (13:20 +0000)
gedcom/gedcom_internal.h
gedcom/multilex.c

index e34318144869dede3c2e6b7870fd1cce6f823ca8..7804a419a98042423f917c3c3ce028371be9d853 100644 (file)
@@ -62,4 +62,5 @@ void       gedcom_mem_error(const char *filename, int line);
 #define MEMORY_ERROR gedcom_mem_error(__FILE__, __LINE__)
 
 extern int line_no;
+extern int init_called;
 #endif /* __GEDCOM_INTERNAL_H */
index 3772e858a0c97f34dad08a3abd1d3a1a0d751a17..175a7be6cb3dbddc0222ec95983b2414c9d65619 100644 (file)
@@ -116,7 +116,7 @@ int determine_encoding(FILE* f)
   }
 }
 
-static int init_called = 0;
+int init_called = 0;
 
 void gedcom_init()
 {
@@ -195,14 +195,23 @@ int gedcom_parse_file(const char* file_name)
 int gedcom_new_model()
 {
   int result = 1;
-  char* filename = (char*) malloc(strlen(PKGDATADIR) + strlen(NEW_MODEL_FILE)
-                                 + 2);
-  if (!filename)
-    MEMORY_ERROR;
+  FILE* file;
+
+  file = fopen(NEW_MODEL_FILE, "r");
+  if (file) {
+    fclose(file);
+    result = gedcom_parse_file(NEW_MODEL_FILE);
+  }
   else {
-    sprintf(filename, "%s/%s", PKGDATADIR, NEW_MODEL_FILE);
-    result = gedcom_parse(filename);
-    free(filename);
+    char* filename = (char*) malloc(strlen(PKGDATADIR) + strlen(NEW_MODEL_FILE)
+                                   + 2);
+    if (!filename)
+      MEMORY_ERROR;
+    else {
+      sprintf(filename, "%s/%s", PKGDATADIR, NEW_MODEL_FILE);
+      result = gedcom_parse_file(filename);
+      free(filename);
+    }
   }
   return result;
 }