aboutsummaryrefslogtreecommitdiff
path: root/libio/iofwide.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 /libio/iofwide.c
parent7d58530341304d403a6626d7f7a1913165fe2f32 (diff)
downloadglibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.zip
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.gz
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.bz2
2.5-18.1
Diffstat (limited to 'libio/iofwide.c')
-rw-r--r--libio/iofwide.c75
1 files changed, 51 insertions, 24 deletions
diff --git a/libio/iofwide.c b/libio/iofwide.c
index 0312421..a993668 100644
--- a/libio/iofwide.c
+++ b/libio/iofwide.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -40,6 +40,7 @@
# include <wcsmbs/wcsmbsload.h>
# include <iconv/gconv_int.h>
# include <shlib-compat.h>
+# include <sysdep.h>
#endif
@@ -68,7 +69,7 @@ static int do_always_noconv (struct _IO_codecvt *codecvt);
/* The functions used in `codecvt' for libio are always the same. */
-struct _IO_codecvt __libio_codecvt =
+const struct _IO_codecvt __libio_codecvt =
{
.__codecvt_destr = NULL, /* Destructor, never used. */
.__codecvt_do_out = do_out,
@@ -82,7 +83,7 @@ struct _IO_codecvt __libio_codecvt =
#ifdef _LIBC
-struct __gconv_trans_data __libio_translit attribute_hidden =
+const struct __gconv_trans_data __libio_translit attribute_hidden =
{
.__trans_fct = __gconv_transliterate
};
@@ -126,12 +127,11 @@ _IO_fwide (fp, mode)
selected locale for LC_CTYPE. */
#ifdef _LIBC
{
- struct gconv_fcts fcts;
-
/* Clear the state. We start all over again. */
memset (&fp->_wide_data->_IO_state, '\0', sizeof (__mbstate_t));
memset (&fp->_wide_data->_IO_last_state, '\0', sizeof (__mbstate_t));
+ struct gconv_fcts fcts;
__wcsmbs_clone_conv (&fcts);
assert (fcts.towc_nsteps == 1);
assert (fcts.tomb_nsteps == 1);
@@ -159,7 +159,8 @@ _IO_fwide (fp, mode)
cc->__cd_out.__cd.__data[0].__statep = &fp->_wide_data->_IO_state;
/* And now the transliteration. */
- cc->__cd_out.__cd.__data[0].__trans = &__libio_translit;
+ cc->__cd_out.__cd.__data[0].__trans
+ = (struct __gconv_trans_data *) &__libio_translit;
}
#else
# ifdef _GLIBCPP_USE_WCHAR_T
@@ -228,17 +229,23 @@ do_out (struct _IO_codecvt *codecvt, __mbstate_t *statep,
size_t dummy;
const unsigned char *from_start_copy = (unsigned char *) from_start;
- codecvt->__cd_out.__cd.__data[0].__outbuf = to_start;
- codecvt->__cd_out.__cd.__data[0].__outbufend = to_end;
+ codecvt->__cd_out.__cd.__data[0].__outbuf = (unsigned char *) to_start;
+ codecvt->__cd_out.__cd.__data[0].__outbufend = (unsigned char *) to_end;
codecvt->__cd_out.__cd.__data[0].__statep = statep;
- status = DL_CALL_FCT (gs->__fct,
+ __gconv_fct fct = gs->__fct;
+#ifdef PTR_DEMANGLE
+ if (gs->__shlib_handle != NULL)
+ PTR_DEMANGLE (fct);
+#endif
+
+ status = DL_CALL_FCT (fct,
(gs, codecvt->__cd_out.__cd.__data, &from_start_copy,
(const unsigned char *) from_end, NULL,
&dummy, 0, 0));
*from_stop = (wchar_t *) from_start_copy;
- *to_stop = codecvt->__cd_out.__cd.__data[0].__outbuf;
+ *to_stop = (char *) codecvt->__cd_out.__cd.__data[0].__outbuf;
switch (status)
{
@@ -294,15 +301,21 @@ do_unshift (struct _IO_codecvt *codecvt, __mbstate_t *statep,
int status;
size_t dummy;
- codecvt->__cd_out.__cd.__data[0].__outbuf = to_start;
- codecvt->__cd_out.__cd.__data[0].__outbufend = to_end;
+ codecvt->__cd_out.__cd.__data[0].__outbuf = (unsigned char *) to_start;
+ codecvt->__cd_out.__cd.__data[0].__outbufend = (unsigned char *) to_end;
codecvt->__cd_out.__cd.__data[0].__statep = statep;
- status = DL_CALL_FCT (gs->__fct,
+ __gconv_fct fct = gs->__fct;
+#ifdef PTR_DEMANGLE
+ if (gs->__shlib_handle != NULL)
+ PTR_DEMANGLE (fct);
+#endif
+
+ status = DL_CALL_FCT (fct,
(gs, codecvt->__cd_out.__cd.__data, NULL, NULL,
NULL, &dummy, 1, 0));
- *to_stop = codecvt->__cd_out.__cd.__data[0].__outbuf;
+ *to_stop = (char *) codecvt->__cd_out.__cd.__data[0].__outbuf;
switch (status)
{
@@ -357,15 +370,22 @@ do_in (struct _IO_codecvt *codecvt, __mbstate_t *statep,
size_t dummy;
const unsigned char *from_start_copy = (unsigned char *) from_start;
- codecvt->__cd_in.__cd.__data[0].__outbuf = (char *) to_start;
- codecvt->__cd_in.__cd.__data[0].__outbufend = (char *) to_end;
+ codecvt->__cd_in.__cd.__data[0].__outbuf = (unsigned char *) to_start;
+ codecvt->__cd_in.__cd.__data[0].__outbufend = (unsigned char *) to_end;
codecvt->__cd_in.__cd.__data[0].__statep = statep;
- status = DL_CALL_FCT (gs->__fct,
+ __gconv_fct fct = gs->__fct;
+#ifdef PTR_DEMANGLE
+ if (gs->__shlib_handle != NULL)
+ PTR_DEMANGLE (fct);
+#endif
+
+ status = DL_CALL_FCT (fct,
(gs, codecvt->__cd_in.__cd.__data, &from_start_copy,
- from_end, NULL, &dummy, 0, 0));
+ (const unsigned char *) from_end, NULL,
+ &dummy, 0, 0));
- *from_stop = from_start_copy;
+ *from_stop = (const char *) from_start_copy;
*to_stop = (wchar_t *) codecvt->__cd_in.__cd.__data[0].__outbuf;
switch (status)
@@ -454,13 +474,20 @@ do_length (struct _IO_codecvt *codecvt, __mbstate_t *statep,
int status;
size_t dummy;
- codecvt->__cd_in.__cd.__data[0].__outbuf = (char *) to_buf;
- codecvt->__cd_in.__cd.__data[0].__outbufend = (char *) &to_buf[max];
+ codecvt->__cd_in.__cd.__data[0].__outbuf = (unsigned char *) to_buf;
+ codecvt->__cd_in.__cd.__data[0].__outbufend = (unsigned char *) &to_buf[max];
codecvt->__cd_in.__cd.__data[0].__statep = statep;
- status = DL_CALL_FCT (gs->__fct,
- (gs, codecvt->__cd_in.__cd.__data, &cp, from_end,
- NULL, &dummy, 0, 0));
+ __gconv_fct fct = gs->__fct;
+#ifdef PTR_DEMANGLE
+ if (gs->__shlib_handle != NULL)
+ PTR_DEMANGLE (fct);
+#endif
+
+ status = DL_CALL_FCT (fct,
+ (gs, codecvt->__cd_in.__cd.__data, &cp,
+ (const unsigned char *) from_end, NULL,
+ &dummy, 0, 0));
result = cp - (const unsigned char *) from_start;
#else