From: Peter Verthez Date: Sun, 22 Sep 2002 13:20:17 +0000 (+0000) Subject: Let init_called be global (used from encoding.c). X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=23c9ff48c00de38e6539a420b7a2df85cd5a51bb;p=gedcom-parse.git Let init_called be global (used from encoding.c). --- diff --git a/gedcom/gedcom_internal.h b/gedcom/gedcom_internal.h index e343181..7804a41 100644 --- a/gedcom/gedcom_internal.h +++ b/gedcom/gedcom_internal.h @@ -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 */ diff --git a/gedcom/multilex.c b/gedcom/multilex.c index 3772e85..175a7be 100644 --- a/gedcom/multilex.c +++ b/gedcom/multilex.c @@ -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; }