- char *save_textdom = textdomain(NULL);
- setlocale(LC_ALL, ""); /* In fact only necessary if main program doesn't
- do this */
- bindtextdomain(PACKAGE, LOCALEDIR);
- bind_textdomain_codeset(PACKAGE, INTERNAL_ENCODING);
- textdomain(PACKAGE);
-
- line_no = 1;
- file = fopen(file_name, "r");
- if (!file) {
- gedcom_error(_("Could not open file '%s'"), file_name);
+ 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)
+ || ! bind_textdomain_codeset(PACKAGE, INTERNAL_ENCODING)
+ || ! textdomain(PACKAGE)) {
+ gedcom_error(_("Could not set locale: %s"), strerror(errno));
+ return result;
+ }
+
+ if (!init_called) {
+ gedcom_error(_("Internal error: GEDCOM parser not initialized"));