about summary refs log tree commit diff
path: root/wcsmbs/wctob.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
commit0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (patch)
tree2ea1f8305970753e4a657acb2ccc15ca3eec8e2c /wcsmbs/wctob.c
parent7d58530341304d403a6626d7f7a1913165fe2f32 (diff)
downloadglibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.gz
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.xz
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.zip
2.5-18.1
Diffstat (limited to 'wcsmbs/wctob.c')
-rw-r--r--wcsmbs/wctob.c20
1 files changed, 16 insertions, 4 deletions
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 <drepper@gnu.ai.mit.edu>, 1996.
 
@@ -24,12 +24,14 @@
 #include <wchar.h>
 #include <wcsmbsload.h>
 
+#include <sysdep.h>
+
 
 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];
 }