1 diff -ur -x Makefile -x Makefile.in -x configure -x po rpm-4.4.2.org/rpmio/Makefile.am rpm-4.4.2/rpmio/Makefile.am
2 --- rpm-4.4.2.org/rpmio/Makefile.am 2007-02-13 20:51:36.290623000 +0100
3 +++ rpm-4.4.2/rpmio/Makefile.am 2007-02-13 20:42:52.362623000 +0100
5 librpmio_la_SOURCES = \
6 LzmaDecode.c argv.c digest.c fts.c macro.c rpmdav.c \
7 rpmhook.c rpmio.c rpmlog.c rpmlua.c rpmmalloc.c \
8 - rpmpgp.c rpmrpc.c rpmsq.c rpmsw.c strcasecmp.c stubs.c url.c ugid.c
9 + rpmpgp.c rpmrpc.c rpmsq.c rpmsw.c strcasecmp.c strtolocale.c stubs.c url.c ugid.c
10 librpmio_la_LDFLAGS = -release 4.4 $(LDFLAGS) \
13 diff -ur -x Makefile -x Makefile.in -x configure -x po rpm-4.4.2.org/rpmio/rpmio.h rpm-4.4.2/rpmio/rpmio.h
14 --- rpm-4.4.2.org/rpmio/rpmio.h 2007-02-13 20:51:36.290623000 +0100
15 +++ rpm-4.4.2/rpmio/rpmio.h 2007-02-13 20:43:52.742623000 +0100
18 int xstrncasecmp(const char *s1, const char * s2, size_t n) /*@*/;
21 + * Force encoding of string.
23 +/*@only@*/ /*@null@*/
24 +const char * xstrtolocale(/*@only@*/ const char *str)
25 + /*@modifies *str @*/;
31 --- /dev/null 2007-02-07 08:10:39.238623000 +0100
32 +++ rpm-4.4.2/rpmio/strtolocale.c 2007-02-13 20:42:06.650623000 +0100
35 + * \file rpmio/strtolocale.c
39 +#include <langinfo.h>
43 +static char *locale_encoding = NULL;
44 +static int locale_encoding_is_utf8;
46 +const char * xstrtolocale(const char *str)
49 + size_t src_size, dest_size;
50 + char *result, *src, *dest;
52 + if (locale_encoding == NULL) {
53 + const char *encoding = nl_langinfo(CODESET);
54 + locale_encoding = xmalloc(strlen(encoding) + 11);
55 + sprintf(locale_encoding, "%s//TRANSLIT", encoding);
56 + locale_encoding_is_utf8 = strcasecmp(encoding, "UTF-8") == 0;
59 + if (!str || !*str || locale_encoding_is_utf8)
62 + cd = iconv_open(locale_encoding, "UTF-8");
63 + if (cd == (iconv_t)-1)
66 + src_size = strlen(str);
67 + dest_size = src_size + 1;
68 + result = xmalloc(dest_size);
72 + size_t status = iconv(cd, &src, &src_size, &dest, &dest_size);
73 + if (status == (size_t)-1) {
75 + if (errno != E2BIG) {
80 + dest_offset = dest - result;
82 + result = xrealloc(result, dest_offset + dest_size);
83 + dest = result + dest_offset;
84 + } else if (src_size == 0) {
85 + if (src == NULL) break;
91 + if (dest_size == 0) {
92 + size_t dest_offset = dest - result;
93 + result = xrealloc(result, dest_offset + 1);
94 + dest = result + dest_offset;
99 --- rpm-4.4.2.org/lib/formats.c 2005-01-26 05:46:54.000000000 +0100
100 +++ rpm-4.4.2/lib/formats.c 2007-02-13 20:50:01.082623000 +0100
103 unsigned long anint = 0;
110 case RPM_STRING_TYPE:
113 + /* XXX Force utf8 strings. */
115 + s = xstrtolocale(s);
119 { int cpl = b64encode_chars_per_line;
121 b64encode_chars_per_line = cpl;
130 /* XXX s was malloc'd */
132 - if (!strcmp(xtag, "base64"))
137 @@ -1077,6 +1083,7 @@
139 if (rc && (*data) != NULL) {
140 *data = xstrdup(*data);
141 + *data = xstrtolocale(*data);