From 4454eadeb415e3d20150b067cb28a41eaa88b672 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Wed, 27 Feb 2008 15:53:54 +0000 Subject: [PATCH] first steps towards enabling support for wide chars in our libroot: reverted mbrtowc.c to glibc 2.2.5, added necessary iconv support to let it compile, added dl*** wrappers for needed glibc functions. Not sure it's the correct path, but let's try, at least. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24150 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/libroot/posix/dlfcn.c | 22 ++++++++++++++ src/system/libroot/posix/glibc/iconv/Jamfile | 1 + .../libroot/posix/glibc/wcsmbs/mbrtowc.c | 29 ++++--------------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/system/libroot/posix/dlfcn.c b/src/system/libroot/posix/dlfcn.c index 3c70dfbb46..11dddc2a5b 100644 --- a/src/system/libroot/posix/dlfcn.c +++ b/src/system/libroot/posix/dlfcn.c @@ -68,3 +68,25 @@ dlerror(void) return NULL; } + +// __libc_dl*** wrappers +// We use a mixed glibc / bsd libc, and glibc wants these +void * +__libc_dlopen(const char *name) +{ + return dlopen(name, 0); +} + + +void * +__libc_dlsym(void *handle, const char *name) +{ + return dlsym(handle, name); +} + + +void +__libc_dlclose(void *handle) +{ + dlclose(handle); +} diff --git a/src/system/libroot/posix/glibc/iconv/Jamfile b/src/system/libroot/posix/glibc/iconv/Jamfile index f64b5e5deb..95463a14ec 100644 --- a/src/system/libroot/posix/glibc/iconv/Jamfile +++ b/src/system/libroot/posix/glibc/iconv/Jamfile @@ -20,4 +20,5 @@ MergeObject posix_gnu_iconv.o : gconv_db.c # gconv_dl.c gconv_simple.c + gconv_trans.c ; diff --git a/src/system/libroot/posix/glibc/wcsmbs/mbrtowc.c b/src/system/libroot/posix/glibc/wcsmbs/mbrtowc.c index 7db3a4e1e9..965535fcd5 100644 --- a/src/system/libroot/posix/glibc/wcsmbs/mbrtowc.c +++ b/src/system/libroot/posix/glibc/wcsmbs/mbrtowc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996,1997,1998,1999,2000,2002 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -21,7 +21,7 @@ #include #include #include -//#include +#include #include @@ -35,19 +35,6 @@ static mbstate_t state; size_t __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) { - // ToDo: this is a dummy implementation to get it going - if (s == NULL) - n = 1, s = ""; - - if (pwc == NULL || n == 0) - return 0; - - if (ps == NULL) - ps = &state; - - pwc[0] = s[0]; - return s[0] == 0 ? 0 : 1; -#if 0 wchar_t buf[1]; struct __gconv_step_data data; int status; @@ -55,7 +42,6 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) size_t dummy; const unsigned char *inbuf; char *outbuf = (char *) (pwc ?: buf); - const struct gconv_fcts *fcts; /* Set information for this step. */ data.__invocation_counter = 0; @@ -77,13 +63,13 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) data.__outbuf = outbuf; data.__outbufend = outbuf + sizeof (wchar_t); - /* Get the conversion functions. */ - fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE)); + /* Make sure we use the correct function. */ + update_conversion_ptrs (); /* Do a normal conversion. */ inbuf = (const unsigned char *) s; - status = DL_CALL_FCT (fcts->towc->__fct, - (fcts->towc, &data, &inbuf, inbuf + n, + status = DL_CALL_FCT (__wcsmbs_gconv_fcts.towc->__fct, + (__wcsmbs_gconv_fcts.towc, &data, &inbuf, inbuf + n, NULL, &dummy, 0, 1)); /* There must not be any problems with the conversion but illegal input @@ -117,8 +103,5 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) } return result; -#endif } -libc_hidden_def (__mbrtowc) weak_alias (__mbrtowc, mbrtowc) -libc_hidden_weak (mbrtowc)