michal-grzedzicki / rpms / rpm

Forked from rpms/rpm 5 months ago
Clone
0b2921
diff --git a/lib/tagexts.c b/lib/tagexts.c
0b2921
index f72ff60..2c0b179 100644
0b2921
--- a/lib/tagexts.c
0b2921
+++ b/lib/tagexts.c
0b2921
@@ -535,15 +535,6 @@ static int filerequireTag(Header h, rpmtd td, headerGetFlags hgflags)
0b2921
     return filedepTag(h, RPMTAG_REQUIRENAME, td, hgflags);
0b2921
 }
0b2921
 
0b2921
-/* I18N look aside diversions */
0b2921
-
0b2921
-#if defined(ENABLE_NLS)
0b2921
-extern int _nl_msg_cat_cntr;	/* XXX GNU gettext voodoo */
0b2921
-#endif
0b2921
-static const char * const language = "LANGUAGE";
0b2921
-
0b2921
-static const char * const _macro_i18ndomains = "%{?_i18ndomains}";
0b2921
-
0b2921
 /**
0b2921
  * Retrieve i18n text.
0b2921
  * @param h		header
0b2921
@@ -554,59 +545,30 @@ static const char * const _macro_i18ndomains = "%{?_i18ndomains}";
0b2921
  */
0b2921
 static int i18nTag(Header h, rpmTag tag, rpmtd td, headerGetFlags hgflags)
0b2921
 {
0b2921
-    int rc;
0b2921
+    int rc = headerGet(h, tag, td, HEADERGET_ALLOC);
0b2921
 #if defined(ENABLE_NLS)
0b2921
-    char * dstring = rpmExpand(_macro_i18ndomains, NULL);
0b2921
-
0b2921
-    td->type = RPM_STRING_TYPE;
0b2921
-    td->data = NULL;
0b2921
-    td->count = 0;
0b2921
-
0b2921
-    if (dstring && *dstring) {
0b2921
-	char *domain, *de;
0b2921
-	const char * langval;
0b2921
-	char * msgkey;
0b2921
-	const char * msgid;
0b2921
+    if (rc) {
0b2921
+	static const char * const _macro_i18ndomains = "%{?_i18ndomains}";
0b2921
+	char *de, *dstring = rpmExpand(_macro_i18ndomains, NULL);
0b2921
+	const char *domain;
0b2921
 
0b2921
-	rasprintf(&msgkey, "%s(%s)", headerGetString(h, RPMTAG_NAME), 
0b2921
-		  rpmTagGetName(tag));
0b2921
-
0b2921
-	/* change to en_US for msgkey -> msgid resolution */
0b2921
-	langval = getenv(language);
0b2921
-	(void) setenv(language, "en_US", 1);
0b2921
-        ++_nl_msg_cat_cntr;
0b2921
-
0b2921
-	msgid = NULL;
0b2921
 	for (domain = dstring; domain != NULL; domain = de) {
0b2921
+	    const char *msgid = td->data;
0b2921
+	    const char *msg = NULL;
0b2921
+
0b2921
 	    de = strchr(domain, ':');
0b2921
 	    if (de) *de++ = '\0';
0b2921
-	    msgid = dgettext(domain, msgkey);
0b2921
-	    if (msgid != msgkey) break;
0b2921
-	}
0b2921
-
0b2921
-	/* restore previous environment for msgid -> msgstr resolution */
0b2921
-	if (langval)
0b2921
-	    (void) setenv(language, langval, 1);
0b2921
-	else
0b2921
-	    unsetenv(language);
0b2921
-        ++_nl_msg_cat_cntr;
0b2921
-
0b2921
-	if (domain && msgid) {
0b2921
-	    td->data = dgettext(domain, msgid);
0b2921
-	    td->data = xstrdup(td->data); /* XXX xstrdup has side effects. */
0b2921
-	    td->count = 1;
0b2921
-	    td->flags = RPMTD_ALLOCED;
0b2921
+	    msg = dgettext(domain, td->data);
0b2921
+	    if (msg != msgid) {
0b2921
+		free(td->data);
0b2921
+		td->data = xstrdup(msg);
0b2921
+		break;
0b2921
+	    }
0b2921
 	}
0b2921
-	dstring = _free(dstring);
0b2921
-	free(msgkey);
0b2921
-	if (td->data)
0b2921
-	    return 1;
0b2921
+	free(dstring);
0b2921
     }
0b2921
-
0b2921
-    free(dstring);
0b2921
 #endif
0b2921
 
0b2921
-    rc = headerGet(h, tag, td, HEADERGET_ALLOC);
0b2921
     return rc;
0b2921
 }
0b2921