reversed back to GLibC 2.2.5

added to the build needed functions for printf_fp


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11646 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2005-03-10 19:11:14 +00:00
parent e207b59ec7
commit fde72c74cc
7 changed files with 219 additions and 248 deletions
+11 -2
View File
@@ -1,11 +1,11 @@
SubDir OBOS_TOP src kernel libroot posix glibc wcsmbs ; SubDir OBOS_TOP src kernel libroot posix glibc wcsmbs ;
SubDirHdrs $(OBOS_TOP) src kernel libroot posix glibc include arch $(OBOS_ARCH) ; SubDirHdrs $(OBOS_TOP) src kernel libroot posix glibc include arch $(OBOS_ARCH) ;
SubDirHdrs $(OBOS_TOP) src kernel libroot posix glibc wcsmbs ;
SubDirHdrs $(OBOS_TOP) src kernel libroot posix glibc include ; SubDirHdrs $(OBOS_TOP) src kernel libroot posix glibc include ;
SubDirHdrs $(OBOS_TOP) src kernel libroot posix glibc libio ;
SubDirHdrs $(OBOS_TOP) src kernel libroot posix glibc wcsmbs ;
SubDirHdrs $(OBOS_TOP) src kernel libroot posix glibc iconv ; SubDirHdrs $(OBOS_TOP) src kernel libroot posix glibc iconv ;
SubDirHdrs $(OBOS_TOP) src kernel libroot posix glibc locale ; SubDirHdrs $(OBOS_TOP) src kernel libroot posix glibc locale ;
SubDirHdrs $(OBOS_TOP) src kernel libroot posix glibc libio ;
SubDirHdrs $(OBOS_TOP) src kernel libroot posix glibc ; SubDirHdrs $(OBOS_TOP) src kernel libroot posix glibc ;
# ToDo: for now, all wide character functions are disabled # ToDo: for now, all wide character functions are disabled
@@ -14,5 +14,14 @@ KernelMergeObject posix_gnu_wcsmbs.o :
mbrlen.c mbrlen.c
mbrtowc.c mbrtowc.c
mbsinit.c mbsinit.c
mbsnrtowcs.c
wcrtomb.c
wcslen.c
wcsmbsload.c
wcsnlen.c
wcsrtombs.c
wmemcpy.c
wmempcpy.c
wmemmove.c
: -fPIC -DPIC : -fPIC -DPIC
; ;
@@ -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. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <[email protected]>, 1996. Contributed by Ulrich Drepper <[email protected]>, 1996.
@@ -51,7 +51,6 @@ __mbsnrtowcs (dst, src, nmc, len, ps)
int status; int status;
struct __gconv_step *towc; struct __gconv_step *towc;
size_t dummy; size_t dummy;
const struct gconv_fcts *fcts;
/* Tell where we want the result. */ /* Tell where we want the result. */
data.__invocation_counter = 0; data.__invocation_counter = 0;
@@ -64,11 +63,11 @@ __mbsnrtowcs (dst, src, nmc, len, ps)
return 0; return 0;
srcend = *src + __strnlen (*src, nmc - 1) + 1; srcend = *src + __strnlen (*src, nmc - 1) + 1;
/* Get the conversion functions. */ /* Make sure we use the correct function. */
fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE)); update_conversion_ptrs ();
/* Get the structure with the function pointers. */ /* Get the structure with the function pointers. */
towc = fcts->towc; towc = __wcsmbs_gconv_fcts.towc;
/* We have to handle DST == NULL special. */ /* We have to handle DST == NULL special. */
if (dst == NULL) if (dst == NULL)
+36 -95
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 1995-99,2000,01,02 Free Software Foundation, Inc. /* Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@@ -23,8 +23,6 @@
#ifndef _WCHAR_H #ifndef _WCHAR_H
#include <iconv/gconv.h>
#ifndef __need_mbstate_t #ifndef __need_mbstate_t
# define _WCHAR_H 1 # define _WCHAR_H 1
# include <features.h> # include <features.h>
@@ -60,10 +58,6 @@
member of the extended character set. */ member of the extended character set. */
# define _WINT_T # define _WINT_T
typedef unsigned int wint_t; typedef unsigned int wint_t;
#else
# ifdef __USE_GNU
__USING_NAMESPACE_STD(wint_t)
# endif
#endif #endif
@@ -87,13 +81,8 @@ typedef struct
defined. */ defined. */
#ifdef _WCHAR_H #ifdef _WCHAR_H
__BEGIN_NAMESPACE_C99
/* Public type. */ /* Public type. */
typedef __mbstate_t mbstate_t; typedef __mbstate_t mbstate_t;
__END_NAMESPACE_C99
#ifdef __USE_GNU
__USING_NAMESPACE_C99(mbstate_t)
#endif
#ifndef WCHAR_MIN #ifndef WCHAR_MIN
/* These constants might also be defined in <inttypes.h>. */ /* These constants might also be defined in <inttypes.h>. */
@@ -111,21 +100,13 @@ __USING_NAMESPACE_C99(mbstate_t)
# include <wctype.h> # include <wctype.h>
#endif #endif
__BEGIN_DECLS
__BEGIN_NAMESPACE_STD
/* This incomplete type is defined in <time.h> but needed here because /* This incomplete type is defined in <time.h> but needed here because
of `wcsftime'. */ of `wcsftime'. */
struct tm; struct tm;
/* XXX We have to clean this up at some point. Since tm is in the std
namespace but wcsftime is in __c99 the type wouldn't be found
without inserting it in the global namespace. */
__USING_NAMESPACE_STD(tm)
__END_NAMESPACE_STD
__BEGIN_NAMESPACE_C99 __BEGIN_DECLS
/* Copy SRC to DEST. */ /* Copy SRC to DEST. */
extern wchar_t *wcscpy (wchar_t *__restrict __dest, extern wchar_t *wcscpy (wchar_t *__restrict __dest,
__const wchar_t *__restrict __src) __THROW; __const wchar_t *__restrict __src) __THROW;
@@ -148,7 +129,6 @@ extern int wcscmp (__const wchar_t *__s1, __const wchar_t *__s2)
/* Compare N wide-characters of S1 and S2. */ /* Compare N wide-characters of S1 and S2. */
extern int wcsncmp (__const wchar_t *__s1, __const wchar_t *__s2, size_t __n) extern int wcsncmp (__const wchar_t *__s1, __const wchar_t *__s2, size_t __n)
__THROW __attribute_pure__; __THROW __attribute_pure__;
__END_NAMESPACE_C99
#ifdef __USE_GNU #ifdef __USE_GNU
/* Compare S1 and S2, ignoring case. */ /* Compare S1 and S2, ignoring case. */
@@ -162,14 +142,13 @@ extern int wcsncasecmp (__const wchar_t *__s1, __const wchar_t *__s2,
the provided locale and not the global locale. */ the provided locale and not the global locale. */
# include <xlocale.h> # include <xlocale.h>
extern int wcscasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2, extern int __wcscasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2,
__locale_t __loc) __THROW; __locale_t __loc) __THROW;
extern int wcsncasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2, extern int __wcsncasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2,
size_t __n, __locale_t __loc) __THROW; size_t __n, __locale_t __loc) __THROW;
#endif #endif
__BEGIN_NAMESPACE_C99
/* Compare S1 and S2, both interpreted as appropriate to the /* Compare S1 and S2, both interpreted as appropriate to the
LC_COLLATE category of the current locale. */ LC_COLLATE category of the current locale. */
extern int wcscoll (__const wchar_t *__s1, __const wchar_t *__s2) __THROW; extern int wcscoll (__const wchar_t *__s1, __const wchar_t *__s2) __THROW;
@@ -178,7 +157,6 @@ extern int wcscoll (__const wchar_t *__s1, __const wchar_t *__s2) __THROW;
`wcscoll' to the original strings. */ `wcscoll' to the original strings. */
extern size_t wcsxfrm (wchar_t *__restrict __s1, extern size_t wcsxfrm (wchar_t *__restrict __s1,
__const wchar_t *__restrict __s2, size_t __n) __THROW; __const wchar_t *__restrict __s2, size_t __n) __THROW;
__END_NAMESPACE_C99
#ifdef __USE_GNU #ifdef __USE_GNU
/* Similar to the two functions above but take the information from /* Similar to the two functions above but take the information from
@@ -186,27 +164,24 @@ __END_NAMESPACE_C99
/* Compare S1 and S2, both interpreted as appropriate to the /* Compare S1 and S2, both interpreted as appropriate to the
LC_COLLATE category of the given locale. */ LC_COLLATE category of the given locale. */
extern int wcscoll_l (__const wchar_t *__s1, __const wchar_t *__s2, extern int __wcscoll_l (__const wchar_t *__s1, __const wchar_t *__s2,
__locale_t __loc) __THROW; __locale_t __loc) __THROW;
/* Transform S2 into array pointed to by S1 such that if wcscmp is /* Transform S2 into array pointed to by S1 such that if wcscmp is
applied to two transformed strings the result is the as applying applied to two transformed strings the result is the as applying
`wcscoll' to the original strings. */ `wcscoll' to the original strings. */
extern size_t wcsxfrm_l (wchar_t *__s1, __const wchar_t *__s2, extern size_t __wcsxfrm_l (wchar_t *__s1, __const wchar_t *__s2,
size_t __n, __locale_t __loc) __THROW; size_t __n, __locale_t __loc) __THROW;
/* Duplicate S, returning an identical malloc'd string. */ /* Duplicate S, returning an identical malloc'd string. */
extern wchar_t *wcsdup (__const wchar_t *__s) __THROW __attribute_malloc__; extern wchar_t *wcsdup (__const wchar_t *__s) __THROW __attribute_malloc__;
#endif #endif
__BEGIN_NAMESPACE_C99
/* Find the first occurrence of WC in WCS. */ /* Find the first occurrence of WC in WCS. */
extern wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc) extern wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc)
__THROW __attribute_pure__; __THROW __attribute_pure__;
/* Find the last occurrence of WC in WCS. */ /* Find the last occurrence of WC in WCS. */
extern wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc) extern wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc)
__THROW __attribute_pure__; __THROW __attribute_pure__;
__END_NAMESPACE_C99
#ifdef __USE_GNU #ifdef __USE_GNU
/* This function is similar to `wcschr'. But it returns a pointer to /* This function is similar to `wcschr'. But it returns a pointer to
@@ -215,7 +190,6 @@ extern wchar_t *wcschrnul (__const wchar_t *__s, wchar_t __wc)
__THROW __attribute_pure__; __THROW __attribute_pure__;
#endif #endif
__BEGIN_NAMESPACE_C99
/* Return the length of the initial segmet of WCS which /* Return the length of the initial segmet of WCS which
consists entirely of wide characters not in REJECT. */ consists entirely of wide characters not in REJECT. */
extern size_t wcscspn (__const wchar_t *__wcs, __const wchar_t *__reject) extern size_t wcscspn (__const wchar_t *__wcs, __const wchar_t *__reject)
@@ -231,6 +205,12 @@ extern wchar_t *wcspbrk (__const wchar_t *__wcs, __const wchar_t *__accept)
extern wchar_t *wcsstr (__const wchar_t *__haystack, __const wchar_t *__needle) extern wchar_t *wcsstr (__const wchar_t *__haystack, __const wchar_t *__needle)
__THROW __attribute_pure__; __THROW __attribute_pure__;
#ifdef __USE_XOPEN
/* Another name for `wcsstr' from XPG4. */
extern wchar_t *wcswcs (__const wchar_t *__haystack, __const wchar_t *__needle)
__THROW __attribute_pure__;
#endif
/* Divide WCS into tokens separated by characters in DELIM. */ /* Divide WCS into tokens separated by characters in DELIM. */
extern wchar_t *wcstok (wchar_t *__restrict __s, extern wchar_t *wcstok (wchar_t *__restrict __s,
__const wchar_t *__restrict __delim, __const wchar_t *__restrict __delim,
@@ -238,13 +218,6 @@ extern wchar_t *wcstok (wchar_t *__restrict __s,
/* Return the number of wide characters in S. */ /* Return the number of wide characters in S. */
extern size_t wcslen (__const wchar_t *__s) __THROW __attribute_pure__; extern size_t wcslen (__const wchar_t *__s) __THROW __attribute_pure__;
__END_NAMESPACE_C99
#ifdef __USE_XOPEN
/* Another name for `wcsstr' from XPG4. */
extern wchar_t *wcswcs (__const wchar_t *__haystack, __const wchar_t *__needle)
__THROW __attribute_pure__;
#endif
#ifdef __USE_GNU #ifdef __USE_GNU
/* Return the number of wide characters in S, but at most MAXLEN. */ /* Return the number of wide characters in S, but at most MAXLEN. */
@@ -253,7 +226,6 @@ extern size_t wcsnlen (__const wchar_t *__s, size_t __maxlen)
#endif #endif
__BEGIN_NAMESPACE_C99
/* Search N wide characters of S for C. */ /* Search N wide characters of S for C. */
extern wchar_t *wmemchr (__const wchar_t *__s, wchar_t __c, size_t __n) extern wchar_t *wmemchr (__const wchar_t *__s, wchar_t __c, size_t __n)
__THROW __attribute_pure__; __THROW __attribute_pure__;
@@ -274,7 +246,6 @@ extern wchar_t *wmemmove (wchar_t *__s1, __const wchar_t *__s2, size_t __n)
/* Set N wide characters of S to C. */ /* Set N wide characters of S to C. */
extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW; extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW;
__END_NAMESPACE_C99
#ifdef __USE_GNU #ifdef __USE_GNU
/* Copy N wide characters of SRC to DEST and return pointer to following /* Copy N wide characters of SRC to DEST and return pointer to following
@@ -285,7 +256,6 @@ extern wchar_t *wmempcpy (wchar_t *__restrict __s1,
#endif #endif
__BEGIN_NAMESPACE_C99
/* Determine whether C constitutes a valid (one-byte) multibyte /* Determine whether C constitutes a valid (one-byte) multibyte
character. */ character. */
extern wint_t btowc (int __c) __THROW; extern wint_t btowc (int __c) __THROW;
@@ -313,7 +283,6 @@ extern size_t __mbrlen (__const char *__restrict __s, size_t __n,
mbstate_t *__restrict __ps) __THROW; mbstate_t *__restrict __ps) __THROW;
extern size_t mbrlen (__const char *__restrict __s, size_t __n, extern size_t mbrlen (__const char *__restrict __s, size_t __n,
mbstate_t *__restrict __ps) __THROW; mbstate_t *__restrict __ps) __THROW;
__END_NAMESPACE_C99
#ifdef __USE_EXTERN_INLINES #ifdef __USE_EXTERN_INLINES
/* Define inline function as optimization. */ /* Define inline function as optimization. */
@@ -323,7 +292,6 @@ extern __inline size_t mbrlen (__const char *__restrict __s, size_t __n,
? mbrtowc (NULL, __s, __n, __ps) : __mbrlen (__s, __n, NULL)); } ? mbrtowc (NULL, __s, __n, __ps) : __mbrlen (__s, __n, NULL)); }
#endif #endif
__BEGIN_NAMESPACE_C99
/* Write wide character representation of multibyte character string /* Write wide character representation of multibyte character string
SRC to DST. */ SRC to DST. */
extern size_t mbsrtowcs (wchar_t *__restrict __dst, extern size_t mbsrtowcs (wchar_t *__restrict __dst,
@@ -335,7 +303,6 @@ extern size_t mbsrtowcs (wchar_t *__restrict __dst,
extern size_t wcsrtombs (char *__restrict __dst, extern size_t wcsrtombs (char *__restrict __dst,
__const wchar_t **__restrict __src, size_t __len, __const wchar_t **__restrict __src, size_t __len,
mbstate_t *__restrict __ps) __THROW; mbstate_t *__restrict __ps) __THROW;
__END_NAMESPACE_C99
#ifdef __USE_GNU #ifdef __USE_GNU
@@ -365,7 +332,6 @@ extern int wcswidth (__const wchar_t *__s, size_t __n) __THROW;
#endif /* Use X/Open. */ #endif /* Use X/Open. */
__BEGIN_NAMESPACE_C99
/* Convert initial portion of the wide string NPTR to `double' /* Convert initial portion of the wide string NPTR to `double'
representation. */ representation. */
extern double wcstod (__const wchar_t *__restrict __nptr, extern double wcstod (__const wchar_t *__restrict __nptr,
@@ -391,23 +357,6 @@ extern unsigned long int wcstoul (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, int __base) wchar_t **__restrict __endptr, int __base)
__THROW; __THROW;
#if defined __USE_ISOC99 || (defined __GNUC__ && defined __USE_GNU)
/* Convert initial portion of wide string NPTR to `long int'
representation. */
__extension__
extern long long int wcstoll (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, int __base)
__THROW;
/* Convert initial portion of wide string NPTR to `unsigned long long int'
representation. */
__extension__
extern unsigned long long int wcstoull (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr,
int __base) __THROW;
#endif /* ISO C99 or GCC and GNU. */
__END_NAMESPACE_C99
#if defined __GNUC__ && defined __USE_GNU #if defined __GNUC__ && defined __USE_GNU
/* Convert initial portion of wide string NPTR to `long int' /* Convert initial portion of wide string NPTR to `long int'
representation. */ representation. */
@@ -424,6 +373,22 @@ extern unsigned long long int wcstouq (__const wchar_t *__restrict __nptr,
int __base) __THROW; int __base) __THROW;
#endif /* GCC and use GNU. */ #endif /* GCC and use GNU. */
#if defined __USE_ISOC99 || (defined __GNUC__ && defined __USE_GNU)
/* Convert initial portion of wide string NPTR to `long int'
representation. */
__extension__
extern long long int wcstoll (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, int __base)
__THROW;
/* Convert initial portion of wide string NPTR to `unsigned long long int'
representation. */
__extension__
extern unsigned long long int wcstoull (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr,
int __base) __THROW;
#endif /* ISO C99 or GCC and GNU. */
#ifdef __USE_GNU #ifdef __USE_GNU
/* The concept of one static locale per category is not very well /* The concept of one static locale per category is not very well
thought out. Many applications will need to process its data using thought out. Many applications will need to process its data using
@@ -442,34 +407,34 @@ extern unsigned long long int wcstouq (__const wchar_t *__restrict __nptr,
/* Special versions of the functions above which take the locale to /* Special versions of the functions above which take the locale to
use as an additional parameter. */ use as an additional parameter. */
extern long int wcstol_l (__const wchar_t *__restrict __nptr, extern long int __wcstol_l (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, int __base, wchar_t **__restrict __endptr, int __base,
__locale_t __loc) __THROW; __locale_t __loc) __THROW;
extern unsigned long int wcstoul_l (__const wchar_t *__restrict __nptr, extern unsigned long int __wcstoul_l (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, wchar_t **__restrict __endptr,
int __base, __locale_t __loc) __THROW; int __base, __locale_t __loc) __THROW;
__extension__ __extension__
extern long long int wcstoll_l (__const wchar_t *__restrict __nptr, extern long long int __wcstoll_l (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, wchar_t **__restrict __endptr,
int __base, __locale_t __loc) __THROW; int __base, __locale_t __loc) __THROW;
__extension__ __extension__
extern unsigned long long int wcstoull_l (__const wchar_t *__restrict __nptr, extern unsigned long long int __wcstoull_l (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, wchar_t **__restrict __endptr,
int __base, __locale_t __loc) int __base, __locale_t __loc)
__THROW; __THROW;
extern double wcstod_l (__const wchar_t *__restrict __nptr, extern double __wcstod_l (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, __locale_t __loc) wchar_t **__restrict __endptr, __locale_t __loc)
__THROW; __THROW;
extern float wcstof_l (__const wchar_t *__restrict __nptr, extern float __wcstof_l (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, __locale_t __loc) wchar_t **__restrict __endptr, __locale_t __loc)
__THROW; __THROW;
extern long double wcstold_l (__const wchar_t *__restrict __nptr, extern long double __wcstold_l (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, wchar_t **__restrict __endptr,
__locale_t __loc) __THROW; __locale_t __loc) __THROW;
#endif /* GNU */ #endif /* GNU */
@@ -520,7 +485,6 @@ extern unsigned long long int __wcstoull_internal (__const wchar_t *
#if defined __OPTIMIZE__ && __GNUC__ >= 2 #if defined __OPTIMIZE__ && __GNUC__ >= 2
/* Define inline functions which call the internal entry points. */ /* Define inline functions which call the internal entry points. */
__BEGIN_NAMESPACE_C99
extern __inline double wcstod (__const wchar_t *__restrict __nptr, extern __inline double wcstod (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr) __THROW wchar_t **__restrict __endptr) __THROW
@@ -533,7 +497,6 @@ extern __inline unsigned long int wcstoul (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, wchar_t **__restrict __endptr,
int __base) __THROW int __base) __THROW
{ return __wcstoul_internal (__nptr, __endptr, __base, 0); } { return __wcstoul_internal (__nptr, __endptr, __base, 0); }
__END_NAMESPACE_C99
# ifdef __USE_GNU # ifdef __USE_GNU
extern __inline float wcstof (__const wchar_t *__restrict __nptr, extern __inline float wcstof (__const wchar_t *__restrict __nptr,
@@ -573,7 +536,6 @@ extern wchar_t *wcpncpy (wchar_t *__dest, __const wchar_t *__src, size_t __n)
/* Wide character I/O functions. */ /* Wide character I/O functions. */
#if defined __USE_ISOC99 || defined __USE_UNIX98 #if defined __USE_ISOC99 || defined __USE_UNIX98
__BEGIN_NAMESPACE_C99
/* Select orientation for stream. */ /* Select orientation for stream. */
extern int fwide (__FILE *__fp, int __mode) __THROW; extern int fwide (__FILE *__fp, int __mode) __THROW;
@@ -619,13 +581,9 @@ extern int wscanf (__const wchar_t *__restrict __format, ...)
extern int swscanf (__const wchar_t *__restrict __s, extern int swscanf (__const wchar_t *__restrict __s,
__const wchar_t *__restrict __format, ...) __const wchar_t *__restrict __format, ...)
__THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */; __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
__END_NAMESPACE_C99
#endif /* Use ISO C99 and Unix98. */ #endif /* Use ISO C99 and Unix98. */
#ifdef __USE_ISOC99 #ifdef __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* Read formatted input from S into argument list ARG. */ /* Read formatted input from S into argument list ARG. */
extern int vfwscanf (__FILE *__restrict __s, extern int vfwscanf (__FILE *__restrict __s,
__const wchar_t *__restrict __format, __const wchar_t *__restrict __format,
@@ -640,12 +598,9 @@ extern int vswscanf (__const wchar_t *__restrict __s,
__const wchar_t *__restrict __format, __const wchar_t *__restrict __format,
__gnuc_va_list __arg) __gnuc_va_list __arg)
__THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */; __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
__END_NAMESPACE_C99
#endif /* Use ISO C99. */ #endif /* Use ISO C99. */
__BEGIN_NAMESPACE_C99
/* Read a character from STREAM. */ /* Read a character from STREAM. */
extern wint_t fgetwc (__FILE *__stream) __THROW; extern wint_t fgetwc (__FILE *__stream) __THROW;
extern wint_t getwc (__FILE *__stream) __THROW; extern wint_t getwc (__FILE *__stream) __THROW;
@@ -674,7 +629,6 @@ extern int fputws (__const wchar_t *__restrict __ws,
/* Push a character back onto the input buffer of STREAM. */ /* Push a character back onto the input buffer of STREAM. */
extern wint_t ungetwc (wint_t __wc, __FILE *__stream) __THROW; extern wint_t ungetwc (wint_t __wc, __FILE *__stream) __THROW;
__END_NAMESPACE_C99
#ifdef __USE_GNU #ifdef __USE_GNU
@@ -705,25 +659,12 @@ extern int fputws_unlocked (__const wchar_t *__restrict __ws,
#endif #endif
__BEGIN_NAMESPACE_C99
/* Format TP into S according to FORMAT. /* Format TP into S according to FORMAT.
Write no more than MAXSIZE wide characters and return the number Write no more than MAXSIZE wide characters and return the number
of wide characters written, or 0 if it would exceed MAXSIZE. */ of wide characters written, or 0 if it would exceed MAXSIZE. */
extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize, extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize,
__const wchar_t *__restrict __format, __const wchar_t *__restrict __format,
__const struct tm *__restrict __tp) __THROW; __const struct tm *__restrict __tp) __THROW;
__END_NAMESPACE_C99
# ifdef __USE_GNU
# include <xlocale.h>
/* Similar to `wcsftime' but takes the information from
the provided locale and not the global locale. */
extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
__const wchar_t *__restrict __format,
__const struct tm *__restrict __tp,
__locale_t __loc) __THROW;
# endif
/* The X/Open standard demands that most of the functions defined in /* The X/Open standard demands that most of the functions defined in
the <wctype.h> header must also appear here. This is probably the <wctype.h> header must also appear here. This is probably
@@ -1,4 +1,4 @@
/* Copyright (C) 1996,1997,1998,2000,2002 Free Software Foundation, Inc. /* Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <[email protected]>, 1996. Contributed by Ulrich Drepper <[email protected]>, 1996.
@@ -42,7 +42,6 @@ __wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
int status; int status;
size_t result; size_t result;
size_t dummy; size_t dummy;
const struct gconv_fcts *fcts;
/* Set information for this step. */ /* Set information for this step. */
data.__invocation_counter = 0; data.__invocation_counter = 0;
@@ -63,16 +62,16 @@ __wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
data.__outbuf = s; data.__outbuf = s;
data.__outbufend = s + MB_CUR_MAX; data.__outbufend = s + MB_CUR_MAX;
/* Get the conversion functions. */ /* Make sure we use the correct function. */
fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE)); update_conversion_ptrs ();
/* If WC is the NUL character we write into the output buffer the byte /* If WC is the NUL character we write into the output buffer the byte
sequence necessary for PS to get into the initial state, followed sequence necessary for PS to get into the initial state, followed
by a NUL byte. */ by a NUL byte. */
if (wc == L'\0') if (wc == L'\0')
{ {
status = DL_CALL_FCT (fcts->tomb->__fct, status = DL_CALL_FCT (__wcsmbs_gconv_fcts.tomb->__fct,
(fcts->tomb, &data, NULL, NULL, (__wcsmbs_gconv_fcts.tomb, &data, NULL, NULL,
NULL, &dummy, 1, 1)); NULL, &dummy, 1, 1));
if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT) if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT)
@@ -83,8 +82,8 @@ __wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
/* Do a normal conversion. */ /* Do a normal conversion. */
const unsigned char *inbuf = (const unsigned char *) &wc; const unsigned char *inbuf = (const unsigned char *) &wc;
status = DL_CALL_FCT (fcts->tomb->__fct, status = DL_CALL_FCT (__wcsmbs_gconv_fcts.tomb->__fct,
(fcts->tomb, &data, &inbuf, (__wcsmbs_gconv_fcts.tomb, &data, &inbuf,
inbuf + sizeof (wchar_t), NULL, &dummy, 0, 1)); inbuf + sizeof (wchar_t), NULL, &dummy, 0, 1));
} }
@@ -109,4 +108,3 @@ __wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
return result; return result;
} }
weak_alias (__wcrtomb, wcrtomb) weak_alias (__wcrtomb, wcrtomb)
libc_hidden_weak (wcrtomb)
@@ -1,4 +1,4 @@
/* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. /* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <[email protected]>, 1998. Contributed by Ulrich Drepper <[email protected]>, 1998.
@@ -26,6 +26,23 @@
#include <locale/localeinfo.h> #include <locale/localeinfo.h>
#include <wcsmbsload.h> #include <wcsmbsload.h>
#include <bits/libc-lock.h> #include <bits/libc-lock.h>
#include <iconv/gconv_int.h>
void
internal_function
__wcsmbs_load_conv (const struct locale_data *new_category)
{
}
static void __attribute__ ((unused))
free_mem (void)
{
}
/* Last loaded locale for LC_CTYPE. We initialize for the C locale
which is enabled at startup. */
extern const struct locale_data _nl_C_LC_CTYPE;
const struct locale_data *__wcsmbs_last_locale = &_nl_C_LC_CTYPE;
/* These are the descriptions for the default conversion functions. */ /* These are the descriptions for the default conversion functions. */
@@ -36,8 +53,7 @@ static struct __gconv_step to_wc =
.__counter = INT_MAX, .__counter = INT_MAX,
.__from_name = (char *) "ANSI_X3.4-1968//TRANSLIT", .__from_name = (char *) "ANSI_X3.4-1968//TRANSLIT",
.__to_name = (char *) "INTERNAL", .__to_name = (char *) "INTERNAL",
.__fct = __gconv_transform_ascii_internal, .__fct = NULL, // __gconv_transform_ascii_internal,
.__btowc_fct = __gconv_btwoc_ascii,
.__init_fct = NULL, .__init_fct = NULL,
.__end_fct = NULL, .__end_fct = NULL,
.__min_needed_from = 1, .__min_needed_from = 1,
@@ -55,8 +71,7 @@ static struct __gconv_step to_mb =
.__counter = INT_MAX, .__counter = INT_MAX,
.__from_name = (char *) "INTERNAL", .__from_name = (char *) "INTERNAL",
.__to_name = (char *) "ANSI_X3.4-1968//TRANSLIT", .__to_name = (char *) "ANSI_X3.4-1968//TRANSLIT",
.__fct = __gconv_transform_internal_ascii, .__fct = NULL, // __gconv_transform_internal_ascii,
.__btowc_fct = NULL,
.__init_fct = NULL, .__init_fct = NULL,
.__end_fct = NULL, .__end_fct = NULL,
.__min_needed_from = 4, .__min_needed_from = 4,
@@ -69,7 +84,7 @@ static struct __gconv_step to_mb =
/* For the default locale we only have to handle ANSI_X3.4-1968. */ /* For the default locale we only have to handle ANSI_X3.4-1968. */
const struct gconv_fcts __wcsmbs_gconv_fcts_c = struct gconv_fcts __wcsmbs_gconv_fcts =
{ {
.towc = &to_wc, .towc = &to_wc,
.towc_nsteps = 1, .towc_nsteps = 1,
@@ -77,10 +92,10 @@ const struct gconv_fcts __wcsmbs_gconv_fcts_c =
.tomb_nsteps = 1 .tomb_nsteps = 1
}; };
#if 0
struct __gconv_step * static inline struct __gconv_step *
attribute_hidden getfct (const char *to, const char *from, size_t *nstepsp)
__wcsmbs_getfct (const char *to, const char *from, size_t *nstepsp)
{ {
size_t nsteps; size_t nsteps;
struct __gconv_step *result; struct __gconv_step *result;
@@ -144,31 +159,46 @@ __wcsmbs_getfct (const char *to, const char *from, size_t *nstepsp)
}) })
/* Some of the functions here must not be used while setlocale is called. */ /* We must modify global data. */
__libc_lock_define (extern, __libc_setlocale_lock attribute_hidden) __libc_lock_define_initialized (static, lock)
/* Load conversion functions for the currently selected locale. */ /* Load conversion functions for the currently selected locale. */
void void
internal_function internal_function
__wcsmbs_load_conv (struct locale_data *new_category) __wcsmbs_load_conv (const struct locale_data *new_category)
{ {
/* Acquire the lock. */ /* Acquire the lock. */
__libc_lock_lock (__libc_setlocale_lock); __libc_lock_lock (lock);
/* We should repeat the test since while we waited some other thread /* We should repeat the test since while we waited some other thread
might have run this function. */ might have run this function. */
if (__builtin_expect (new_category->private.ctype == NULL, 1)) if (__builtin_expect (__wcsmbs_last_locale != new_category, 1))
{
if (new_category->name == _nl_C_name) /* Yes, pointer comparison. */
{
failed:
__wcsmbs_gconv_fcts.towc = &to_wc;
__wcsmbs_gconv_fcts.tomb = &to_mb;
}
else
{ {
/* We must find the real functions. */ /* We must find the real functions. */
const char *charset_name; const char *charset_name;
const char *complete_name; const char *complete_name;
struct gconv_fcts *new_fcts; struct __gconv_step *new_towc;
size_t new_towc_nsteps;
struct __gconv_step *new_tomb;
size_t new_tomb_nsteps;
int use_translit; int use_translit;
/* Allocate the gconv_fcts structure. */ /* Free the old conversions. */
new_fcts = malloc (sizeof *new_fcts); if (__wcsmbs_gconv_fcts.tomb != &to_mb)
if (new_fcts == NULL) __gconv_close_transform (__wcsmbs_gconv_fcts.tomb,
goto failed; __wcsmbs_gconv_fcts.tomb_nsteps);
if (__wcsmbs_gconv_fcts.towc != &to_wc)
__gconv_close_transform (__wcsmbs_gconv_fcts.towc,
__wcsmbs_gconv_fcts.towc_nsteps);
/* Get name of charset of the locale. */ /* Get name of charset of the locale. */
charset_name = new_category->values[_NL_ITEM_INDEX(CODESET)].string; charset_name = new_category->values[_NL_ITEM_INDEX(CODESET)].string;
@@ -184,34 +214,33 @@ __wcsmbs_load_conv (struct locale_data *new_category)
/* It is not necessary to use transliteration in this direction /* It is not necessary to use transliteration in this direction
since the internal character set is supposed to be able to since the internal character set is supposed to be able to
represent all others. */ represent all others. */
new_fcts->towc = __wcsmbs_getfct ("INTERNAL", complete_name, new_towc = getfct ("INTERNAL", complete_name, &new_towc_nsteps);
&new_fcts->towc_nsteps); new_tomb = (new_towc != NULL
new_fcts->tomb = (new_fcts->towc != NULL ? getfct (complete_name, "INTERNAL", &new_tomb_nsteps)
? __wcsmbs_getfct (complete_name, "INTERNAL",
&new_fcts->tomb_nsteps)
: NULL); : NULL);
/* If any of the conversion functions is not available we don't /* If any of the conversion functions is not available we don't
use any since this would mean we cannot convert back and use any since this would mean we cannot convert back and
forth.*/ forth.*/
if (new_fcts->tomb == NULL) if (new_towc == NULL || new_tomb == NULL)
{ {
if (new_fcts->towc != NULL) if (new_towc != NULL)
__gconv_close_transform (new_fcts->towc, new_fcts->towc_nsteps); __gconv_close_transform (new_towc, 1);
free (new_fcts); goto failed;
failed:
new_category->private.ctype = &__wcsmbs_gconv_fcts_c;
}
else
{
new_category->private.ctype = new_fcts;
new_category->private.cleanup = &_nl_cleanup_ctype;
}
} }
__libc_lock_unlock (__libc_setlocale_lock); __wcsmbs_gconv_fcts.tomb = new_tomb;
__wcsmbs_gconv_fcts.tomb_nsteps = new_tomb_nsteps;
__wcsmbs_gconv_fcts.towc = new_towc;
__wcsmbs_gconv_fcts.towc_nsteps = new_towc_nsteps;
}
/* Set last-used variable for current locale. */
__wcsmbs_last_locale = new_category;
}
__libc_lock_unlock (lock);
} }
@@ -220,19 +249,22 @@ void
internal_function internal_function
__wcsmbs_clone_conv (struct gconv_fcts *copy) __wcsmbs_clone_conv (struct gconv_fcts *copy)
{ {
const struct gconv_fcts *orig; /* First make sure the function table is up-to-date. */
update_conversion_ptrs ();
orig = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE)); /* Make sure the data structures remain the same until we are finished. */
__libc_lock_lock (lock);
/* Copy the data. */ /* Copy the data. */
*copy = *orig; *copy = __wcsmbs_gconv_fcts;
/* Now increment the usage counters. /* Now increment the usage counters. */
Note: This assumes copy->towc_nsteps == 1 and copy->tomb_nsteps == 1. */
if (copy->towc->__shlib_handle != NULL) if (copy->towc->__shlib_handle != NULL)
++copy->towc->__counter; ++copy->towc->__counter;
if (copy->tomb->__shlib_handle != NULL) if (copy->tomb->__shlib_handle != NULL)
++copy->tomb->__counter; ++copy->tomb->__counter;
__libc_lock_unlock (lock);
} }
@@ -241,10 +273,10 @@ int
internal_function internal_function
__wcsmbs_named_conv (struct gconv_fcts *copy, const char *name) __wcsmbs_named_conv (struct gconv_fcts *copy, const char *name)
{ {
copy->towc = __wcsmbs_getfct ("INTERNAL", name, &copy->towc_nsteps); copy->towc = getfct ("INTERNAL", name, &copy->towc_nsteps);
if (copy->towc != NULL) if (copy->towc != NULL)
{ {
copy->tomb = __wcsmbs_getfct (name, "INTERNAL", &copy->tomb_nsteps); copy->tomb = getfct (name, "INTERNAL", &copy->tomb_nsteps);
if (copy->tomb == NULL) if (copy->tomb == NULL)
__gconv_close_transform (copy->towc, copy->towc_nsteps); __gconv_close_transform (copy->towc, copy->towc_nsteps);
} }
@@ -252,18 +284,30 @@ __wcsmbs_named_conv (struct gconv_fcts *copy, const char *name)
return copy->towc == NULL || copy->tomb == NULL ? 1 : 0; return copy->towc == NULL || copy->tomb == NULL ? 1 : 0;
} }
void internal_function
_nl_cleanup_ctype (struct locale_data *locale)
{
const struct gconv_fcts *const data = locale->private.ctype;
if (data != NULL)
{
locale->private.ctype = NULL;
locale->private.cleanup = NULL;
/* Free the old conversions. */ /* Free all resources if necessary. */
__gconv_close_transform (data->tomb, data->tomb_nsteps); static void __attribute__ ((unused))
__gconv_close_transform (data->towc, data->towc_nsteps); free_mem (void)
free ((char *) data); {
if (__wcsmbs_gconv_fcts.tomb != &to_mb)
{
struct __gconv_step *old = __wcsmbs_gconv_fcts.tomb;
size_t nold = __wcsmbs_gconv_fcts.tomb_nsteps;
__wcsmbs_gconv_fcts.tomb = &to_mb;
__wcsmbs_gconv_fcts.tomb_nsteps = 1;
__gconv_release_cache (old, nold);
}
if (__wcsmbs_gconv_fcts.towc != &to_wc)
{
struct __gconv_step *old = __wcsmbs_gconv_fcts.towc;
size_t nold = __wcsmbs_gconv_fcts.towc_nsteps;
__wcsmbs_gconv_fcts.towc = &to_wc;
__wcsmbs_gconv_fcts.towc_nsteps = 1;
__gconv_release_cache (old, nold);
} }
} }
#endif
text_set_element (__libc_subfreeres, free_mem);
@@ -1,4 +1,4 @@
/* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. /* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <[email protected]>, 1998. Contributed by Ulrich Drepper <[email protected]>, 1998.
@@ -17,9 +17,6 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */ 02111-1307 USA. */
#ifndef _WCSMBSLOAD_H
#define _WCSMBSLOAD_H 1
#include <locale.h> #include <locale.h>
#include <wchar.h> #include <wchar.h>
#include <locale/localeinfo.h> #include <locale/localeinfo.h>
@@ -35,10 +32,15 @@ struct gconv_fcts
}; };
/* Set of currently active conversion functions. */ /* Set of currently active conversion functions. */
extern const struct gconv_fcts __wcsmbs_gconv_fcts_c attribute_hidden; extern struct gconv_fcts __wcsmbs_gconv_fcts;
/* Last loaded locale for LC_CTYPE. */
extern const struct locale_data *__wcsmbs_last_locale;
/* Load conversion functions for the currently selected locale. */ /* Load conversion functions for the currently selected locale. */
extern void __wcsmbs_load_conv (struct locale_data *new_category) extern void __wcsmbs_load_conv (const struct locale_data *new_category)
internal_function; internal_function;
/* Clone the current `__wcsmbs_load_conv' value. */ /* Clone the current `__wcsmbs_load_conv' value. */
@@ -49,33 +51,12 @@ extern void __wcsmbs_clone_conv (struct gconv_fcts *copy)
extern int __wcsmbs_named_conv (struct gconv_fcts *copy, const char *name) extern int __wcsmbs_named_conv (struct gconv_fcts *copy, const char *name)
internal_function; internal_function;
/* Function used for the `private.cleanup' hook. */
extern void _nl_cleanup_ctype (struct locale_data *)
internal_function attribute_hidden;
#include <iconv/gconv_int.h>
/* Load the function implementation if necessary. */
extern struct __gconv_step *__wcsmbs_getfct (const char *to, const char *from,
size_t *nstepsp)
attribute_hidden;
extern const struct locale_data _nl_C_LC_CTYPE attribute_hidden;
/* Check whether the LC_CTYPE locale changed since the last call. /* Check whether the LC_CTYPE locale changed since the last call.
Update the pointers appropriately. */ Update the pointers appropriately. */
static inline const struct gconv_fcts * static inline void
get_gconv_fcts (struct locale_data *data) update_conversion_ptrs (void)
{ {
if (__builtin_expect (data->private.u.ctype == NULL, 0)) if (__wcsmbs_last_locale != _nl_current_LC_CTYPE)
{ __wcsmbs_load_conv (_nl_current_LC_CTYPE);
if (__builtin_expect (data == &_nl_C_LC_CTYPE, 0))
return &__wcsmbs_gconv_fcts_c;
__wcsmbs_load_conv (data);
}
return data->private.u.ctype;
} }
#endif /* wcsmbsload.h */
@@ -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. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <[email protected]>, 1996. Contributed by Ulrich Drepper <[email protected]>, 1996.
@@ -45,7 +45,6 @@ __wcsrtombs (dst, src, len, ps)
int status; int status;
size_t result; size_t result;
struct __gconv_step *tomb; struct __gconv_step *tomb;
const struct gconv_fcts *fcts;
/* Tell where we want the result. */ /* Tell where we want the result. */
data.__invocation_counter = 0; data.__invocation_counter = 0;
@@ -54,11 +53,11 @@ __wcsrtombs (dst, src, len, ps)
data.__statep = ps ?: &state; data.__statep = ps ?: &state;
data.__trans = NULL; data.__trans = NULL;
/* Get the conversion functions. */ /* Make sure we use the correct function. */
fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE)); update_conversion_ptrs ();
/* Get the structure with the function pointers. */ /* Get the structure with the function pointers. */
tomb = fcts->tomb; tomb = __wcsmbs_gconv_fcts.tomb;
/* We have to handle DST == NULL special. */ /* We have to handle DST == NULL special. */
if (dst == NULL) if (dst == NULL)