SHA256
6
0
forked from pool/rpm

Accepting request 18841 from Base:System

Copy from Base:System/rpm based on submit request 18841 from user mlschroe

OBS-URL: https://build.opensuse.org/request/show/18841
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/rpm?expand=0&rev=84
This commit is contained in:
OBS User autobuild
2009-08-28 13:54:03 +00:00
committed by Git OBS Bridge
parent bd5319d2fe
commit 25f00b6cb5
64 changed files with 3179 additions and 3463 deletions

View File

@@ -1,25 +1,23 @@
Convert changelog and i18n header elements to current locale.
[#43347], rh#140050
Already in rpm-4.4.7
Index: lib/formats.c
Index: lib/tagexts.c
===================================================================
--- lib/formats.c.orig
+++ lib/formats.c
--- lib/tagexts.c.orig
+++ lib/tagexts.c
@@ -2,6 +2,7 @@
* \file lib/formats.c
*/
+#include <wchar.h>
#include "system.h"
#include "rpmio_internal.h"
#include <rpmlib.h>
@@ -18,6 +19,114 @@
/*@access pgpDig @*/
/*@access pgpDigParams @*/
+static const char * strtolocale(const char *str)
#include <rpm/rpmtypes.h>
@@ -156,6 +157,114 @@ exit:
return rc;
}
+static char * strtolocale(char *str)
+{
+ wchar_t *wstr, *wp;
+ const unsigned char *cp;
@@ -101,7 +99,7 @@ Index: lib/formats.c
+ wstr = _free(wstr);
+ return str;
+ }
+ str = _free(str);
+ str = _free((char *)str);
+ memset(&ps, 0, sizeof(ps));
+ ccl = cca = 0;
+ for (wp = wstr; ; wp++) {
@@ -124,104 +122,79 @@ Index: lib/formats.c
+ }
+ }
+ wstr = _free(wstr);
+ return (const char *)cc;
+ return (char *)cc;
+}
+
/**
* Identify type of trigger.
* @param type tag type
@@ -1080,6 +1189,7 @@ static int i18nTag(Header h, int_32 tag,
* Retrieve mounted file system paths.
* @param h header
@@ -534,9 +643,43 @@ static int i18nTag(Header h, rpmTag tag,
dstring = _free(dstring);
if (rc && (*data) != NULL) {
*data = xstrdup(*data);
+ *data = strtolocale(*data);
*freeData = 1;
return 0;
}
@@ -1091,6 +1201,56 @@ static int i18nTag(Header h, int_32 tag,
}
/**
+ * Retrieve text and convert to locale.
+ */
+static int localeTag(Header h, int_32 tag, /*@out@*/ rpmTagType * type,
+ /*@out@*/ const void ** data, /*@out@*/ int_32 * count,
+ /*@out@*/ int * freeData)
+{
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
+ rpmTagType t;
+ char **d, **d2, *dp;
+ int rc, i, l;
+
+ rc = hge(h, tag, &t, (void **)&d, count);
+ if (!rc || d == NULL || *count == 0) {
+ *freeData = 0;
+ *data = NULL;
+ *count = 0;
+ return 1;
rc = headerGet(h, tag, td, HEADERGET_DEFAULT);
+ if (rc && td->data) {
+ td->data = xstrdup(td->data);
+ td->data = strtolocale(td->data);
+ td->flags = RPMTD_ALLOCED;
+ }
+ if (type)
+ *type = t;
+ if (t == RPM_STRING_TYPE) {
+ d = (char **)xstrdup((char *)d);
+ d = (char **)strtolocale((char *)d);
+ *freeData = 1;
+ } else if (t == RPM_STRING_ARRAY_TYPE) {
+ l = 0;
+ for (i = 0; i < *count; i++) {
+ d[i] = xstrdup(d[i]);
+ d[i] = (char *)strtolocale(d[i]);
+ l += strlen(d[i]) + 1;
+ }
+ d2 = xmalloc(*count * sizeof(char *) + l);
+ dp = (char *)(d2 + *count);
+ for (i = 0; i < *count; i++) {
+ d2[i] = dp;
+ strcpy(dp, d[i]);
+ dp += strlen(dp) + 1;
+ d[i] = _free(d[i]);
+ }
+ d = _free(d);
+ d = d2;
+ *freeData = 1;
+ } else
+ *freeData = 0;
+ *data = (void **)d;
+ return 0;
+ return rc;
+}
+
+
+/**
* Retrieve summary text.
* @param h header
* @retval *type tag type
@@ -1130,6 +1290,20 @@ static int descriptionTag(Header h, /*@o
return i18nTag(h, RPMTAG_DESCRIPTION, type, data, count, freeData);
+ * Retrieve text and convert to locale.
+ */
+static int localeTag(Header h, rpmTag tag, rpmtd td)
+{
+ int rc;
+ rc = headerGet(h, tag, td, HEADERGET_DEFAULT);
+ if (!rc)
+ return 0;
+ if (td->type == RPM_STRING_TYPE) {
+ td->data = xstrdup(td->data);
+ td->data = strtolocale(td->data);
+ td->flags = RPMTD_ALLOCED;
+ td->count = 1;
+ } else if (td->type == RPM_STRING_ARRAY_TYPE) {
+ char **arr;
+ int i;
+ arr = xmalloc(td->count * sizeof(*arr));
+ for (i = 0; i < td->count; i++) {
+ arr[i] = xstrdup(((char **)td->data)[i]);
+ arr[i] = strtolocale(arr[i]);
+ }
+ td->data = arr;
+ td->flags = RPMTD_ALLOCED | RPMTD_PTR_ALLOCED;
+ }
return rc;
}
+static int changelognameTag(Header h, /*@out@*/ rpmTagType * type,
+ /*@out@*/ const void ** data, /*@out@*/ int_32 * count,
+ /*@out@*/ int * freeData)
+
/**
* Retrieve summary text.
* @param h header
@@ -559,6 +702,16 @@ static int descriptionTag(Header h, rpmt
return i18nTag(h, RPMTAG_DESCRIPTION, td);
}
+static int changelognameTag(Header h, rpmtd td)
+{
+ return localeTag(h, RPMTAG_CHANGELOGNAME, type, data, count, freeData);
+ return localeTag(h, RPMTAG_CHANGELOGNAME, td);
+}
+
+static int changelogtextTag(Header h, /*@out@*/ rpmTagType * type,
+ /*@out@*/ const void ** data, /*@out@*/ int_32 * count,
+ /*@out@*/ int * freeData)
+static int changelogtextTag(Header h, rpmtd td)
+{
+ return localeTag(h, RPMTAG_CHANGELOGTEXT, type, data, count, freeData);
+ return localeTag(h, RPMTAG_CHANGELOGTEXT, td);
+}
+
/**
* Retrieve group text.
* @param h header
@@ -1155,6 +1329,8 @@ const struct headerSprintfExtension_s rp
{ HEADER_EXT_TAG, "RPMTAG_GROUP", { groupTag } },
{ HEADER_EXT_TAG, "RPMTAG_DESCRIPTION", { descriptionTag } },
{ HEADER_EXT_TAG, "RPMTAG_SUMMARY", { summaryTag } },
+ { HEADER_EXT_TAG, "RPMTAG_CHANGELOGNAME", { changelognameTag } },
+ { HEADER_EXT_TAG, "RPMTAG_CHANGELOGTEXT", { changelogtextTag } },
{ HEADER_EXT_TAG, "RPMTAG_FILECLASS", { fileclassTag } },
{ HEADER_EXT_TAG, "RPMTAG_FILECONTEXTS", { filecontextsTag } },
{ HEADER_EXT_TAG, "RPMTAG_FILENAMES", { filenamesTag } },
@@ -663,6 +816,8 @@ static const struct headerTagFunc_s rpmH
{ RPMTAG_LONGARCHIVESIZE, longarchivesizeTag },
{ RPMTAG_LONGSIZE, longsizeTag },
{ RPMTAG_LONGSIGSIZE, longsigsizeTag },
+ { RPMTAG_CHANGELOGNAME, changelognameTag },
+ { RPMTAG_CHANGELOGTEXT, changelogtextTag },
{ 0, NULL }
};