- char *save_locale = strdup(setlocale(LC_ALL, NULL));
- char *save_textdom = textdomain(NULL);
- setlocale(LC_ALL, "");
- bindtextdomain(PACKAGE, LOCALEDIR);
- bind_textdomain_codeset(PACKAGE, INTERNAL_ENCODING);
- textdomain(PACKAGE);
+ save_locale = strdup(locale);
+ if (! save_locale) {
+ 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)
+ || ! bind_textdomain_codeset(PACKAGE, INTERNAL_ENCODING)
+ || ! textdomain(PACKAGE)) {
+ gedcom_error(_("Could not set locale: %s"), strerror(errno));
+ return result;
+ }