From 0ecb606cb6cf65de1d9fc8a919bceb4be476c602 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 12 Jul 2007 18:26:36 +0000 Subject: 2.5-18.1 --- wcsmbs/wctob.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'wcsmbs/wctob.c') diff --git a/wcsmbs/wctob.c b/wcsmbs/wctob.c index b85ba6dd8f..cbaac53367 100644 --- a/wcsmbs/wctob.c +++ b/wcsmbs/wctob.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2000, 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 1996-2000, 2002, 2003, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -24,12 +24,14 @@ #include #include +#include + int wctob (c) wint_t c; { - char buf[MB_LEN_MAX]; + unsigned char buf[MB_LEN_MAX]; struct __gconv_step_data data; wchar_t inbuf[1]; wchar_t *inptr = inbuf; @@ -40,6 +42,11 @@ wctob (c) if (c == WEOF) return EOF; + /* We know that only ASCII compatible encodings are used for the + locale and that the wide character encoding is ISO 10646. */ + if (c >= L'\0' && c <= L'\x7f') + return (int) c; + /* Tell where we want the result. */ data.__outbuf = buf; data.__outbufend = buf + MB_LEN_MAX; @@ -59,7 +66,12 @@ wctob (c) inbuf[0] = c; const unsigned char *argptr = (const unsigned char *) inptr; - status = DL_CALL_FCT (fcts->tomb->__fct, + __gconv_fct fct = fcts->tomb->__fct; +#ifdef PTR_DEMANGLE + if (fcts->tomb->__shlib_handle != NULL) + PTR_DEMANGLE (fct); +#endif + status = DL_CALL_FCT (fct, (fcts->tomb, &data, &argptr, argptr + sizeof (inbuf[0]), NULL, &dummy, 0, 1)); @@ -69,5 +81,5 @@ wctob (c) || data.__outbuf != (unsigned char *) (buf + 1)) return EOF; - return (unsigned char) buf[0]; + return buf[0]; } -- cgit v1.2.3