michal-grzedzicki / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone
648606
diff --git a/lib/tagexts.c b/lib/tagexts.c
648606
index dc0e0fb..e0a5d1f 100644
648606
--- a/lib/tagexts.c
648606
+++ b/lib/tagexts.c
648606
@@ -478,59 +478,29 @@ static const char * const _macro_i18ndomains = "%{?_i18ndomains}";
648606
  */
648606
 static int i18nTag(Header h, rpmTag tag, rpmtd td, headerGetFlags hgflags)
648606
 {
648606
-    int rc;
648606
+    int rc = headerGet(h, tag, td, HEADERGET_ALLOC);
648606
 #if defined(ENABLE_NLS)
648606
-    char * dstring = rpmExpand(_macro_i18ndomains, NULL);
648606
-
648606
-    td->type = RPM_STRING_TYPE;
648606
-    td->data = NULL;
648606
-    td->count = 0;
648606
-
648606
-    if (dstring && *dstring) {
648606
-	char *domain, *de;
648606
-	const char * langval;
648606
-	char * msgkey;
648606
-	const char * msgid;
648606
-
648606
-	rasprintf(&msgkey, "%s(%s)", headerGetString(h, RPMTAG_NAME), 
648606
-		  rpmTagGetName(tag));
648606
-
648606
-	/* change to en_US for msgkey -> msgid resolution */
648606
-	langval = getenv(language);
648606
-	(void) setenv(language, "en_US", 1);
648606
-        ++_nl_msg_cat_cntr;
648606
+    if (rc) {
648606
+	char *de, *dstring = rpmExpand(_macro_i18ndomains, NULL);
648606
+	const char *domain;
648606
 
648606
-	msgid = NULL;
648606
 	for (domain = dstring; domain != NULL; domain = de) {
648606
+	    const char *msgid = td->data;
648606
+	    const char *msg = NULL;
648606
+
648606
 	    de = strchr(domain, ':');
648606
 	    if (de) *de++ = '\0';
648606
-	    msgid = dgettext(domain, msgkey);
648606
-	    if (msgid != msgkey) break;
648606
-	}
648606
-
648606
-	/* restore previous environment for msgid -> msgstr resolution */
648606
-	if (langval)
648606
-	    (void) setenv(language, langval, 1);
648606
-	else
648606
-	    unsetenv(language);
648606
-        ++_nl_msg_cat_cntr;
648606
-
648606
-	if (domain && msgid) {
648606
-	    td->data = dgettext(domain, msgid);
648606
-	    td->data = xstrdup(td->data); /* XXX xstrdup has side effects. */
648606
-	    td->count = 1;
648606
-	    td->flags = RPMTD_ALLOCED;
648606
+	    msg = dgettext(domain, td->data);
648606
+	    if (msg != msgid) {
648606
+		free(td->data);
648606
+		td->data = xstrdup(msg);
648606
+		break;
648606
+	    }
648606
 	}
648606
-	dstring = _free(dstring);
648606
-	free(msgkey);
648606
-	if (td->data)
648606
-	    return 1;
648606
+	free(dstring);
648606
     }
648606
-
648606
-    free(dstring);
648606
 #endif
648606
 
648606
-    rc = headerGet(h, tag, td, HEADERGET_ALLOC);
648606
     return rc;
648606
 }
648606