- fixup rpm translation lookup to match Fedora specspo (#436941)

This commit is contained in:
Panu Matilainen 2009-02-05 13:58:38 +00:00
parent 95c99ce423
commit 4b92b8006c
2 changed files with 104 additions and 1 deletions

View File

@ -0,0 +1,96 @@
diff --git a/lib/tagexts.c b/lib/tagexts.c
index 501d8ac..cf71639 100644
--- a/lib/tagexts.c
+++ b/lib/tagexts.c
@@ -460,12 +460,6 @@ static int filerequireTag(Header h, rpmtd td)
}
/* I18N look aside diversions */
-
-#if defined(ENABLE_NLS)
-extern int _nl_msg_cat_cntr; /* XXX GNU gettext voodoo */
-#endif
-static const char * const language = "LANGUAGE";
-
static const char * const _macro_i18ndomains = "%{?_i18ndomains}";
/**
@@ -477,63 +471,27 @@ static const char * const _macro_i18ndomains = "%{?_i18ndomains}";
*/
static int i18nTag(Header h, rpmTag tag, rpmtd td)
{
- char * dstring = rpmExpand(_macro_i18ndomains, NULL);
- int rc;
+ int rc = headerGet(h, tag, td, HEADERGET_ALLOC);
+ if (rc) {
+ char *de, *dstring = rpmExpand(_macro_i18ndomains, NULL);
+ const char *domain;
- td->type = RPM_STRING_TYPE;
- td->data = NULL;
- td->count = 0;
-
- if (dstring && *dstring) {
- char *domain, *de;
- const char * langval;
- char * msgkey;
- const char * msgid;
- const char * n;
- int xx;
-
- xx = headerNVR(h, &n, NULL, NULL);
- rasprintf(&msgkey, "%s(%s)", n, rpmTagGetName(tag));
-
- /* change to en_US for msgkey -> msgid resolution */
- langval = getenv(language);
- (void) setenv(language, "en_US", 1);
-#if defined(ENABLE_NLS)
- ++_nl_msg_cat_cntr;
-#endif
-
- msgid = NULL;
for (domain = dstring; domain != NULL; domain = de) {
+ const char *msgid = td->data;
+ const char *msg = NULL;
+
de = strchr(domain, ':');
if (de) *de++ = '\0';
- msgid = dgettext(domain, msgkey);
- if (msgid != msgkey) break;
- }
-
- /* restore previous environment for msgid -> msgstr resolution */
- if (langval)
- (void) setenv(language, langval, 1);
- else
- unsetenv(language);
-#if defined(ENABLE_NLS)
- ++_nl_msg_cat_cntr;
-#endif
-
- if (domain && msgid) {
- td->data = dgettext(domain, msgid);
- td->data = xstrdup(td->data); /* XXX xstrdup has side effects. */
- td->count = 1;
- td->flags = RPMTD_ALLOCED;
+ msg = dgettext(domain, td->data);
+ if (msg != msgid) {
+ free(td->data);
+ td->data = xstrdup(msg);
+ break;
+ }
}
- dstring = _free(dstring);
- free(msgkey);
- if (td->data)
- return 1;
+ free(dstring);
}
-
- dstring = _free(dstring);
-
- rc = headerGet(h, tag, td, HEADERGET_DEFAULT);
+
return rc;
}

View File

@ -18,7 +18,7 @@
Summary: The RPM package management system
Name: rpm
Version: %{rpmver}
Release: 0.%{snapver}.3%{?dist}
Release: 0.%{snapver}.4%{?dist}
Group: System Environment/Base
Url: http://www.rpm.org/
Source0: http://rpm.org/releases/testing/%{name}-%{srcver}.tar.bz2
@ -30,6 +30,9 @@ Source10: desktop-file.prov
Patch0: rpm-4.5.90-devel-autodep.patch
Patch1: rpm-4.5.90-pkgconfig-path.patch
Patch2: rpm-4.5.90-gstreamer-provides.patch
# Fedora specspo is setup differently than what rpm expects, considering
# this as Fedora-specific patch for now
Patch3: rpm-4.6.0-fedora-specspo.patch
# Patches already in upstream
Patch200: rpm-4.6.0-rc1-defaultdocdir.patch
@ -166,6 +169,7 @@ that will manipulate RPM packages and databases.
%patch0 -p1 -b .devel-autodep
%patch1 -p1 -b .pkgconfig-path
%patch2 -p1 -b .gstreamer-prov
%patch3 -p1 -b .fedora-specspo
# upstream but not on 4.6.x branch yet, oops
%patch200 -p1 -b .defaultdocdir
@ -370,6 +374,9 @@ exit 0
%doc doc/librpm/html/*
%changelog
* Thu Feb 05 2009 Panu Matilainen <pmatilai@redhat.com> - 4.6.0-0.rc4.4
- fixup rpm translation lookup to match Fedora specspo (#436941)
* Wed Feb 04 2009 Panu Matilainen <pmatilai@redhat.com> - 4.6.0-0.rc4.3
- extract mimehandler provides from .desktop files
- preliminaries for extracting font provides (not enabled yet)