This is the mail archive of the
libc-alpha@sourceware.cygnus.com
mailing list for the glibc project.
gettext must normalize charset for gconv
- To: libc-alpha at sourceware dot cygnus dot com
- Subject: gettext must normalize charset for gconv
- From: Bruno Haible <haible at ilog dot fr>
- Date: Tue, 2 May 2000 15:42:18 +0200 (MET DST)
The automatic translation feature of gettext now works when intl/ is
compiled outside glibc, but not inside glibc. One of the reasons is that
__gconv_open, unlike iconv_open, wants charset identifiers ending in
two slashes and in upper case. Fortunately we already have a macro for
this, 'norm_add_slashes'. It only must be moved to gconv_int.h.
(wcsmbs/wcsmbsload.c and intl/gettextP.h include iconv/gconv_int.h.)
2000-05-01 Bruno Haible <clisp.cons.org>
* wcsmbs/wcsmbsload.c (norm_add_slashes): Move away.
* iconv/gconv_int.h (norm_add_slashes): Move to here.
* intl/loadmsgcat.c (_nl_load_domain): Normalize strings passed to
__gconv_open.
*** wcsmbs/wcsmbsload.c.bak Wed Jan 26 23:17:08 2000
--- wcsmbs/wcsmbsload.c Mon May 1 13:54:18 2000
***************
*** 132,165 ****
})
- /* The gconv functions expects the name to be complete, including the
- trailing shashes if necessary. */
- #define norm_add_slashes(str) \
- ({ \
- const char *cp = str; \
- char *result; \
- char *tmp; \
- size_t cnt = 0; \
- \
- while (*cp != '\0') \
- if (*cp++ == '/') \
- ++cnt; \
- \
- tmp = result = alloca (cp - str + 3); \
- cp = str; \
- while (*cp != '\0') \
- *tmp++ = _toupper (*cp++); \
- if (cnt < 2) \
- { \
- *tmp++ = '/'; \
- if (cnt < 1) \
- *tmp++ = '/'; \
- } \
- *tmp = '\0'; \
- result; \
- })
-
-
/* We must modify global data. */
__libc_lock_define_initialized (static, lock)
--- 132,137 ----
*** iconv/gconv_int.h.bak Fri Apr 21 18:12:51 2000
--- iconv/gconv_int.h Mon May 1 13:54:11 2000
***************
*** 100,105 ****
--- 100,133 ----
extern struct gconv_module *__gconv_modules_db;
+ /* The gconv functions expects the name to be in upper case and complete,
+ including the trailing slashes if necessary. */
+ #define norm_add_slashes(str) \
+ ({ \
+ const char *cp = (str); \
+ char *result; \
+ char *tmp; \
+ size_t cnt = 0; \
+ \
+ while (*cp != '\0') \
+ if (*cp++ == '/') \
+ ++cnt; \
+ \
+ tmp = result = alloca (cp - (str) + 3); \
+ cp = (str); \
+ while (*cp != '\0') \
+ *tmp++ = _toupper (*cp++); \
+ if (cnt < 2) \
+ { \
+ *tmp++ = '/'; \
+ if (cnt < 1) \
+ *tmp++ = '/'; \
+ } \
+ *tmp = '\0'; \
+ result; \
+ })
+
+
/* Return in *HANDLE decriptor for transformation from FROMSET to TOSET. */
extern int __gconv_open (const char *__toset, const char *__fromset,
__gconv_t *__handle, int flags)
*** intl/loadmsgcat.c.bak Fri Apr 28 12:38:31 2000
--- intl/loadmsgcat.c Mon May 1 13:55:18 2000
***************
*** 288,293 ****
--- 288,295 ----
outcharset = (*_nl_current[LC_CTYPE])->values[_NL_ITEM_INDEX (CODESET)].string;
# ifdef _LIBC
+ outcharset = norm_add_slashes (outcharset);
+ charset = norm_add_slashes (charset);
if (__gconv_open (outcharset, charset, &domain->conv,
GCONV_AVOID_NOCONV)
!= __GCONV_OK)