X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;ds=sidebyside;f=gedcom%2Fmultilex.c;h=5b0aa4eec262861c492e5745115b7bbcd957ddb2;hb=3a3f7c5589b2e265306385da92727592e168e442;hp=3772e858a0c97f34dad08a3abd1d3a1a0d751a17;hpb=0d11e282c6948aad8f0d15eb86020eabfd5a59ba;p=gedcom-parse.git diff --git a/gedcom/multilex.c b/gedcom/multilex.c index 3772e85..5b0aa4e 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() { @@ -171,7 +171,7 @@ int gedcom_parse_file(const char* file_name) enc = determine_encoding(file); if (lexer_init(enc, file)) { - line_no = 1; + line_no = 0; make_xref_table(); result = gedcom_parse(); line_no = 0; @@ -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; }