X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gedcom%2Fmultilex.c;h=ec7c35c45a5ec34bbcce01fed3d8ba92923c3097;hb=a049a06b8f811d38984d2b8053a6ff77d6415c29;hp=175a7be6cb3dbddc0222ec95983b2414c9d65619;hpb=23c9ff48c00de38e6539a420b7a2df85cd5a51bb;p=gedcom-parse.git diff --git a/gedcom/multilex.c b/gedcom/multilex.c index 175a7be..ec7c35c 100644 --- a/gedcom/multilex.c +++ b/gedcom/multilex.c @@ -122,6 +122,7 @@ void gedcom_init() { init_called = 1; update_gconv_search_path(); + setlocale(LC_ALL, ""); } int gedcom_parse_file(const char* file_name) @@ -129,31 +130,24 @@ int gedcom_parse_file(const char* file_name) ENCODING enc; int result = 1; FILE* file; - char *locale, *save_locale, *save_textdom; + char *textdom, *save_textdom; - locale = setlocale(LC_ALL, NULL); - if (! locale) { - gedcom_error(_("Could not retrieve locale information")); + textdom = textdomain(NULL); + if (!textdom) { + gedcom_error(_("Could not retrieve text domain: %s"), strerror(errno)); return result; } - save_locale = strdup(locale); - if (! save_locale) { + save_textdom = strdup(textdom); + if (! save_textdom) { MEMORY_ERROR; return result; } - save_textdom = textdomain(NULL); - if (!save_textdom) { - gedcom_error(_("Could not retrieve locale domain: %s"), strerror(errno)); - return result; - } - - if (! setlocale(LC_ALL, "") - || ! bindtextdomain(PACKAGE, LOCALEDIR) + if (! bindtextdomain(PACKAGE, LOCALEDIR) || ! bind_textdomain_codeset(PACKAGE, INTERNAL_ENCODING) || ! textdomain(PACKAGE)) { - gedcom_error(_("Could not set locale: %s"), strerror(errno)); + gedcom_error(_("Could not set text domain: %s"), strerror(errno)); return result; } @@ -171,7 +165,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; @@ -183,12 +177,10 @@ int gedcom_parse_file(const char* file_name) } } - if (! textdomain(save_textdom) - || ! setlocale(LC_ALL, save_locale)) { - gedcom_error(_("Could not restore locale: %s"), strerror(errno)); + if (! textdomain(save_textdom)) { + gedcom_error(_("Could not restore text domain: %s"), strerror(errno)); return result; } - free(save_locale); return result; } @@ -215,3 +207,19 @@ int gedcom_new_model() } return result; } + +int gedcom_check_version(int major, int minor, int patch) +{ + if (major < GEDCOM_PARSE_VERSION_MAJOR) + return 1; + else if (major > GEDCOM_PARSE_VERSION_MAJOR) + return 0; + else if (minor < GEDCOM_PARSE_VERSION_MINOR) + return 1; + else if (minor > GEDCOM_PARSE_VERSION_MINOR) + return 0; + else if (patch <= GEDCOM_PARSE_VERSION_PATCH) + return 1; + else + return 0; +}