added some more glibc functions
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15064 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -9,3 +9,4 @@ SubInclude HAIKU_TOP src system libroot posix glibc regex ;
|
||||
SubInclude HAIKU_TOP src system libroot posix glibc stdio-common ;
|
||||
SubInclude HAIKU_TOP src system libroot posix glibc stdlib ;
|
||||
SubInclude HAIKU_TOP src system libroot posix glibc wcsmbs ;
|
||||
SubInclude HAIKU_TOP src system libroot posix glibc wctype ;
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/* Copyright (C) 1995,1996,1997,2002,2003 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
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
#include <ieee754.h>
|
||||
#include <float.h>
|
||||
|
||||
/* Convert a multi-precision integer of the needed number of bits (53 for
|
||||
double) and an integral power of two to a `double' in IEEE754 double-
|
||||
precision format. */
|
||||
|
||||
double
|
||||
__mpn_construct_double (mp_srcptr frac_ptr, int expt, int negative)
|
||||
{
|
||||
union ieee754_double u;
|
||||
|
||||
u.ieee.negative = negative;
|
||||
u.ieee.exponent = expt + IEEE754_DOUBLE_BIAS;
|
||||
#if BITS_PER_MP_LIMB == 32
|
||||
u.ieee.mantissa1 = frac_ptr[0];
|
||||
u.ieee.mantissa0 = frac_ptr[1] & (((mp_limb_t) 1
|
||||
<< (DBL_MANT_DIG - 32)) - 1);
|
||||
#elif BITS_PER_MP_LIMB == 64
|
||||
u.ieee.mantissa1 = frac_ptr[0] & (((mp_limb_t) 1 << 32) - 1);
|
||||
u.ieee.mantissa0 = (frac_ptr[0] >> 32) & (((mp_limb_t) 1
|
||||
<< (DBL_MANT_DIG - 32)) - 1);
|
||||
#else
|
||||
#error "mp_limb size " BITS_PER_MP_LIMB "not accounted for"
|
||||
#endif
|
||||
|
||||
return u.d;
|
||||
}
|
||||
@@ -29,6 +29,7 @@ KernelMergeObject posix_gnu_arch_$(TARGET_ARCH).o :
|
||||
e_fmodf.S
|
||||
e_fmodl.c
|
||||
ldbl2mpn.c
|
||||
mpn2dbl.c
|
||||
mul.c
|
||||
mul_1.S
|
||||
mul_n.c
|
||||
@@ -79,6 +80,6 @@ KernelMergeObject posix_gnu_arch_$(TARGET_ARCH).o :
|
||||
;
|
||||
|
||||
SEARCH on [ FGristFiles
|
||||
cmp.c divrem.c mul.c mul_n.c dbl2mpn.c s_fpclassify.c s_fpclassifyf.c s_fpclassifyl.c s_modf.c s_modff.c s_modfl.c
|
||||
cmp.c divrem.c mul.c mul_n.c dbl2mpn.c mpn2dbl.c s_fpclassify.c s_fpclassifyf.c s_fpclassifyl.c s_modf.c s_modff.c s_modfl.c
|
||||
w_atan2.c w_atan2f.c w_atan2l.c w_fmod.c w_fmodl.c w_fmodf.c
|
||||
] = [ FDirName $(HAIKU_TOP) src system libroot posix glibc arch ] ;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#include <iconv/gconv.h>
|
||||
@@ -87,33 +87,33 @@ KernelMergeObject posix_gnu_libio.o :
|
||||
|
||||
# wide character
|
||||
|
||||
# <$(SOURCE_GRIST)>fputwc.c
|
||||
# <$(SOURCE_GRIST)>fputwc_u.c
|
||||
# <$(SOURCE_GRIST)>fwprintf.c
|
||||
<$(SOURCE_GRIST)>fputwc.c
|
||||
<$(SOURCE_GRIST)>fputwc_u.c
|
||||
<$(SOURCE_GRIST)>fwprintf.c
|
||||
# <$(SOURCE_GRIST)>fwscanf.c
|
||||
# <$(SOURCE_GRIST)>getwc.c
|
||||
# <$(SOURCE_GRIST)>getwc_u.c
|
||||
# <$(SOURCE_GRIST)>iofputws.c
|
||||
# <$(SOURCE_GRIST)>iofputws_u.c
|
||||
# <$(SOURCE_GRIST)>iogetwline.c
|
||||
# <$(SOURCE_GRIST)>ioungetwc.c
|
||||
<$(SOURCE_GRIST)>getwc.c
|
||||
<$(SOURCE_GRIST)>getwc_u.c
|
||||
<$(SOURCE_GRIST)>iofputws.c
|
||||
<$(SOURCE_GRIST)>iofputws_u.c
|
||||
<$(SOURCE_GRIST)>iogetwline.c
|
||||
<$(SOURCE_GRIST)>ioungetwc.c
|
||||
# <$(SOURCE_GRIST)>iovswscanf.c
|
||||
<$(SOURCE_GRIST)>iowpadn.c
|
||||
# <$(SOURCE_GRIST)>putwc.c
|
||||
# <$(SOURCE_GRIST)>putwc_u.c
|
||||
# <$(SOURCE_GRIST)>putwchar.c
|
||||
# <$(SOURCE_GRIST)>putwchar_u.c
|
||||
# <$(SOURCE_GRIST)>swprintf.c
|
||||
<$(SOURCE_GRIST)>putwc.c
|
||||
<$(SOURCE_GRIST)>putwc_u.c
|
||||
<$(SOURCE_GRIST)>putwchar.c
|
||||
<$(SOURCE_GRIST)>putwchar_u.c
|
||||
<$(SOURCE_GRIST)>swprintf.c
|
||||
# <$(SOURCE_GRIST)>swscanf.c
|
||||
# <$(SOURCE_GRIST)>vswprintf.c
|
||||
# <$(SOURCE_GRIST)>vwprintf.c
|
||||
<$(SOURCE_GRIST)>vswprintf.c
|
||||
<$(SOURCE_GRIST)>vwprintf.c
|
||||
# <$(SOURCE_GRIST)>vwscanf.c
|
||||
# <$(SOURCE_GRIST)>wfiledoalloc.c
|
||||
# <$(SOURCE_GRIST)>wfileops.c
|
||||
<$(SOURCE_GRIST)>wgenops.c
|
||||
# <$(SOURCE_GRIST)>wprintf.c
|
||||
<$(SOURCE_GRIST)>wprintf.c
|
||||
# <$(SOURCE_GRIST)>wscanf.c
|
||||
# <$(SOURCE_GRIST)>wstrops.c
|
||||
<$(SOURCE_GRIST)>wstrops.c
|
||||
:
|
||||
-fPIC -DPIC
|
||||
;
|
||||
|
||||
@@ -44,7 +44,7 @@ KernelMergeObject posix_gnu_stdio.o : #_common.o :
|
||||
# <$(SOURCE_GRIST)>vfprintf_stub.c
|
||||
# <$(SOURCE_GRIST)>vfscanf_stub.c
|
||||
<$(SOURCE_GRIST)>vfscanf.c
|
||||
# <$(SOURCE_GRIST)>vfwprintf.c
|
||||
<$(SOURCE_GRIST)>vfwprintf.c
|
||||
# <$(SOURCE_GRIST)>vfwscanf.c
|
||||
<$(SOURCE_GRIST)>vprintf.c
|
||||
:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991-1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991-1999, 2000, 2001, 2002 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
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <sys/param.h>
|
||||
#include "_itoa.h"
|
||||
#include <locale/localeinfo.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* This code is shared between the standard stdio implementation found
|
||||
in GNU C library and the libio implementation originally found in
|
||||
@@ -75,7 +76,7 @@
|
||||
# define PUT(F, S, N) _IO_sputn ((F), (S), (N))
|
||||
# define PAD(Padchar) \
|
||||
if (width > 0) \
|
||||
done += _IO_padn (s, (Padchar), width)
|
||||
done += INTUSE(_IO_padn) (s, (Padchar), width)
|
||||
# define PUTC(C, F) _IO_putc_unlocked (C, F)
|
||||
# define ORIENT if (s->_vtable_offset == 0 && _IO_fwide (s, -1) != -1)\
|
||||
return -1
|
||||
@@ -104,7 +105,6 @@
|
||||
# endif
|
||||
#else /* ! USE_IN_LIBIO */
|
||||
/* This code is for use in the GNU C library. */
|
||||
# include <stdio.h>
|
||||
# define ARGCHECK(S, Format) \
|
||||
do \
|
||||
{ \
|
||||
@@ -253,6 +253,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
|
||||
/* Buffer intermediate results. */
|
||||
CHAR_T work_buffer[1000];
|
||||
CHAR_T *workstart = NULL;
|
||||
CHAR_T *workend;
|
||||
|
||||
/* State for restartable multibyte character handling functions. */
|
||||
@@ -580,8 +581,10 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
else \
|
||||
if (is_long_num) \
|
||||
signed_number = args_value[fspec->data_arg].pa_long_int; \
|
||||
else \
|
||||
else if (!is_short) \
|
||||
signed_number = args_value[fspec->data_arg].pa_int; \
|
||||
else \
|
||||
signed_number = args_value[fspec->data_arg].pa_short_int; \
|
||||
\
|
||||
is_negative = signed_number < 0; \
|
||||
number.word = is_negative ? (- signed_number) : signed_number; \
|
||||
@@ -935,8 +938,6 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
*(long int *) va_arg (ap, void *) = done; \
|
||||
else if (is_char) \
|
||||
*(char *) va_arg (ap, void *) = done; \
|
||||
else if (is_long_num) \
|
||||
*(long int *) va_arg (ap, void *) = done; \
|
||||
else if (!is_short) \
|
||||
*(int *) va_arg (ap, void *) = done; \
|
||||
else \
|
||||
@@ -947,8 +948,6 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
*(long long int *) args_value[fspec->data_arg].pa_pointer = done; \
|
||||
else if (is_long_num) \
|
||||
*(long int *) args_value[fspec->data_arg].pa_pointer = done; \
|
||||
else if (is_long_num) \
|
||||
*(long int *) args_value[fspec->data_arg].pa_pointer = done; \
|
||||
else if (is_char) \
|
||||
*(char *) args_value[fspec->data_arg].pa_pointer = done; \
|
||||
else if (!is_short) \
|
||||
@@ -990,7 +989,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
if (!left) \
|
||||
PAD (L' '); \
|
||||
if (fspec == NULL) \
|
||||
outchar (va_arg (ap, wint_t)); \
|
||||
outchar (va_arg (ap, wchar_t)); \
|
||||
else \
|
||||
outchar (args_value[fspec->data_arg].pa_wchar); \
|
||||
if (left) \
|
||||
@@ -1036,14 +1035,18 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
const char *mbs = (const char *) string; \
|
||||
mbstate_t mbstate; \
|
||||
\
|
||||
len = prec != -1 ? prec : strlen (mbs); \
|
||||
len = prec != -1 ? (size_t) prec : strlen (mbs); \
|
||||
\
|
||||
/* Allocate dynamically an array which definitely is long \
|
||||
enough for the wide character version. */ \
|
||||
if (len < 8192 \
|
||||
|| ((string = (CHAR_T *) malloc (len * sizeof (wchar_t))) \
|
||||
== NULL)) \
|
||||
if (len < 8192) \
|
||||
string = (CHAR_T *) alloca (len * sizeof (wchar_t)); \
|
||||
else if ((string = (CHAR_T *) malloc (len * sizeof (wchar_t))) \
|
||||
== NULL) \
|
||||
{ \
|
||||
done = -1; \
|
||||
goto all_done; \
|
||||
} \
|
||||
else \
|
||||
string_malloced = 1; \
|
||||
\
|
||||
@@ -1077,7 +1080,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
outstring (string, len); \
|
||||
if (left) \
|
||||
PAD (L' '); \
|
||||
if (string_malloced) \
|
||||
if (__builtin_expect (string_malloced, 0)) \
|
||||
free (string); \
|
||||
} \
|
||||
break;
|
||||
@@ -1106,7 +1109,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
size_t len; \
|
||||
\
|
||||
memset (&mbstate, '\0', sizeof (mbstate_t)); \
|
||||
len = __wcrtomb (buf, (fspec == NULL ? va_arg (ap, wint_t) \
|
||||
len = __wcrtomb (buf, (fspec == NULL ? va_arg (ap, wchar_t) \
|
||||
: args_value[fspec->data_arg].pa_wchar), \
|
||||
&mbstate); \
|
||||
if (len == (size_t) -1) \
|
||||
@@ -1198,9 +1201,13 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
if (prec >= 0) \
|
||||
{ \
|
||||
/* The string `s2' might not be NUL terminated. */ \
|
||||
if (prec < 32768 \
|
||||
|| (string = (char *) malloc (prec)) == NULL) \
|
||||
if (prec < 32768) \
|
||||
string = (char *) alloca (prec); \
|
||||
else if ((string = (char *) malloc (prec)) == NULL) \
|
||||
{ \
|
||||
done = -1; \
|
||||
goto all_done; \
|
||||
} \
|
||||
else \
|
||||
string_malloced = 1; \
|
||||
len = __wcsrtombs (string, &s2, prec, &mbstate); \
|
||||
@@ -1212,9 +1219,13 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
{ \
|
||||
assert (__mbsinit (&mbstate)); \
|
||||
s2 = (const wchar_t *) string; \
|
||||
if (len + 1 < 32768 \
|
||||
|| (string = (char *) malloc (len + 1)) == NULL) \
|
||||
if (len + 1 < 32768) \
|
||||
string = (char *) alloca (len + 1); \
|
||||
else if ((string = (char *) malloc (len + 1)) == NULL) \
|
||||
{ \
|
||||
done = -1; \
|
||||
goto all_done; \
|
||||
} \
|
||||
else \
|
||||
string_malloced = 1; \
|
||||
(void) __wcsrtombs (string, &s2, len + 1, &mbstate); \
|
||||
@@ -1240,7 +1251,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
outstring (string, len); \
|
||||
if (left) \
|
||||
PAD (' '); \
|
||||
if (string_malloced) \
|
||||
if (__builtin_expect (string_malloced, 0)) \
|
||||
free (string); \
|
||||
} \
|
||||
break;
|
||||
@@ -1350,6 +1361,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
UCHAR_T pad = L_(' ');/* Padding character. */
|
||||
CHAR_T spec;
|
||||
|
||||
workstart = NULL;
|
||||
workend = &work_buffer[sizeof (work_buffer) / sizeof (CHAR_T)];
|
||||
|
||||
/* Get current character in format string. */
|
||||
@@ -1431,11 +1443,25 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
left = 1;
|
||||
}
|
||||
|
||||
if (width + 32 >= (int) (sizeof (work_buffer) / sizeof (work_buffer[0])))
|
||||
/* We have to use a special buffer. The "32" is just a safe
|
||||
bet for all the output which is not counted in the width. */
|
||||
workend = ((CHAR_T *) alloca ((width + 32) * sizeof (CHAR_T))
|
||||
+ (width + 32));
|
||||
if (width + 32 >= (int) (sizeof (work_buffer)
|
||||
/ sizeof (work_buffer[0])))
|
||||
{
|
||||
/* We have to use a special buffer. The "32" is just a safe
|
||||
bet for all the output which is not counted in the width. */
|
||||
if (width < (int) (32768 / sizeof (CHAR_T)))
|
||||
workend = ((CHAR_T *) alloca ((width + 32) * sizeof (CHAR_T))
|
||||
+ (width + 32));
|
||||
else
|
||||
{
|
||||
workstart = (CHAR_T *) malloc ((width + 32) * sizeof (CHAR_T));
|
||||
if (workstart == NULL)
|
||||
{
|
||||
done = -1;
|
||||
goto all_done;
|
||||
}
|
||||
workend = workstart + (width + 32);
|
||||
}
|
||||
}
|
||||
}
|
||||
JUMP (*f, step1_jumps);
|
||||
|
||||
@@ -1444,10 +1470,23 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
width = read_int (&f);
|
||||
|
||||
if (width + 32 >= (int) (sizeof (work_buffer) / sizeof (work_buffer[0])))
|
||||
/* We have to use a special buffer. The "32" is just a safe
|
||||
bet for all the output which is not counted in the width. */
|
||||
workend = ((CHAR_T *) alloca ((width + 32) * sizeof (CHAR_T))
|
||||
+ (width + 32));
|
||||
{
|
||||
/* We have to use a special buffer. The "32" is just a safe
|
||||
bet for all the output which is not counted in the width. */
|
||||
if (width < (int) (32768 / sizeof (CHAR_T)))
|
||||
workend = ((CHAR_T *) alloca ((width + 32) * sizeof (CHAR_T))
|
||||
+ (width + 32));
|
||||
else
|
||||
{
|
||||
workstart = (CHAR_T *) malloc ((width + 32) * sizeof (CHAR_T));
|
||||
if (workstart == NULL)
|
||||
{
|
||||
done = -1;
|
||||
goto all_done;
|
||||
}
|
||||
workend = workstart + (width + 32);
|
||||
}
|
||||
}
|
||||
if (*f == L_('$'))
|
||||
/* Oh, oh. The argument comes from a positional parameter. */
|
||||
goto do_positional;
|
||||
@@ -1476,7 +1515,20 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
prec = 0;
|
||||
if (prec > width
|
||||
&& prec + 32 > (int)(sizeof (work_buffer) / sizeof (work_buffer[0])))
|
||||
workend = alloca (spec + 32) + (spec + 32);
|
||||
{
|
||||
if (prec < (int) (32768 / sizeof (CHAR_T)))
|
||||
workend = alloca (prec + 32) + (prec + 32);
|
||||
else
|
||||
{
|
||||
workstart = (CHAR_T *) malloc ((prec + 32) * sizeof (CHAR_T));
|
||||
if (workstart == NULL)
|
||||
{
|
||||
done = -1;
|
||||
goto all_done;
|
||||
}
|
||||
workend = workstart + (prec + 32);
|
||||
}
|
||||
}
|
||||
JUMP (*f, step2_jumps);
|
||||
|
||||
/* Process 'h' modifier. There might another 'h' following. */
|
||||
@@ -1539,6 +1591,10 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
/* The format is correctly handled. */
|
||||
++nspecs_done;
|
||||
|
||||
if (__builtin_expect (workstart != NULL, 0))
|
||||
free (workstart);
|
||||
workstart = NULL;
|
||||
|
||||
/* Look for next format specifier. */
|
||||
#ifdef COMPILE_WPRINTF
|
||||
f = find_spec ((end_of_spec = ++f));
|
||||
@@ -1739,6 +1795,7 @@ do_positional:
|
||||
int use_outdigits = specs[nspecs_done].info.i18n;
|
||||
char pad = specs[nspecs_done].info.pad;
|
||||
CHAR_T spec = specs[nspecs_done].info.spec;
|
||||
CHAR_T *workstart = NULL;
|
||||
|
||||
/* Fill in last information. */
|
||||
if (specs[nspecs_done].width_arg != -1)
|
||||
@@ -1772,10 +1829,20 @@ do_positional:
|
||||
}
|
||||
|
||||
/* Maybe the buffer is too small. */
|
||||
if (MAX (prec, width) + 32 > (int) (sizeof (work_buffer) / sizeof (CHAR_T)))
|
||||
workend = ((CHAR_T *) alloca ((MAX (prec, width) + 32)
|
||||
* sizeof (CHAR_T))
|
||||
+ (MAX (prec, width) + 32));
|
||||
if (MAX (prec, width) + 32 > (int) (sizeof (work_buffer)
|
||||
/ sizeof (CHAR_T)))
|
||||
{
|
||||
if (MAX (prec, width) < (int) (32768 / sizeof (CHAR_T)))
|
||||
workend = ((CHAR_T *) alloca ((MAX (prec, width) + 32)
|
||||
* sizeof (CHAR_T))
|
||||
+ (MAX (prec, width) + 32));
|
||||
else
|
||||
{
|
||||
workstart = (CHAR_T *) malloc ((MAX (prec, width) + 32)
|
||||
* sizeof (CHAR_T));
|
||||
workend = workstart + (MAX (prec, width) + 32);
|
||||
}
|
||||
}
|
||||
|
||||
/* Process format specifiers. */
|
||||
while (1)
|
||||
@@ -1823,6 +1890,10 @@ do_positional:
|
||||
break;
|
||||
}
|
||||
|
||||
if (__builtin_expect (workstart != NULL, 0))
|
||||
free (workstart);
|
||||
workstart = NULL;
|
||||
|
||||
/* Write the following constant string. */
|
||||
outstring (specs[nspecs_done].end_of_fmt,
|
||||
specs[nspecs_done].next_fmt
|
||||
@@ -1831,6 +1902,8 @@ do_positional:
|
||||
}
|
||||
|
||||
all_done:
|
||||
if (__builtin_expect (workstart != NULL, 0))
|
||||
free (workstart);
|
||||
/* Unlock the stream. */
|
||||
#ifdef USE_IN_LIBIO
|
||||
_IO_funlockfile (s);
|
||||
@@ -2006,18 +2079,18 @@ _IO_helper_overflow (_IO_FILE *s, int c)
|
||||
static const struct _IO_jump_t _IO_helper_jumps =
|
||||
{
|
||||
JUMP_INIT_DUMMY,
|
||||
JUMP_INIT (finish, _IO_wdefault_finish),
|
||||
JUMP_INIT (finish, INTUSE(_IO_wdefault_finish)),
|
||||
JUMP_INIT (overflow, _IO_helper_overflow),
|
||||
JUMP_INIT (underflow, _IO_default_underflow),
|
||||
JUMP_INIT (uflow, _IO_default_uflow),
|
||||
JUMP_INIT (pbackfail, (_IO_pbackfail_t) _IO_wdefault_pbackfail),
|
||||
JUMP_INIT (xsputn, _IO_wdefault_xsputn),
|
||||
JUMP_INIT (xsgetn, _IO_wdefault_xsgetn),
|
||||
JUMP_INIT (uflow, INTUSE(_IO_default_uflow)),
|
||||
JUMP_INIT (pbackfail, (_IO_pbackfail_t) INTUSE(_IO_wdefault_pbackfail)),
|
||||
JUMP_INIT (xsputn, INTUSE(_IO_wdefault_xsputn)),
|
||||
JUMP_INIT (xsgetn, INTUSE(_IO_wdefault_xsgetn)),
|
||||
JUMP_INIT (seekoff, _IO_default_seekoff),
|
||||
JUMP_INIT (seekpos, _IO_default_seekpos),
|
||||
JUMP_INIT (setbuf,(_IO_setbuf_t) _IO_wdefault_setbuf),
|
||||
JUMP_INIT (setbuf, _IO_default_setbuf),
|
||||
JUMP_INIT (sync, _IO_default_sync),
|
||||
JUMP_INIT (doallocate, _IO_wdefault_doallocate),
|
||||
JUMP_INIT (doallocate, INTUSE(_IO_wdefault_doallocate)),
|
||||
JUMP_INIT (read, _IO_default_read),
|
||||
JUMP_INIT (write, _IO_default_write),
|
||||
JUMP_INIT (seek, _IO_default_seek),
|
||||
@@ -2028,18 +2101,18 @@ static const struct _IO_jump_t _IO_helper_jumps =
|
||||
static const struct _IO_jump_t _IO_helper_jumps =
|
||||
{
|
||||
JUMP_INIT_DUMMY,
|
||||
JUMP_INIT (finish, _IO_default_finish),
|
||||
JUMP_INIT (finish, INTUSE(_IO_default_finish)),
|
||||
JUMP_INIT (overflow, _IO_helper_overflow),
|
||||
JUMP_INIT (underflow, _IO_default_underflow),
|
||||
JUMP_INIT (uflow, _IO_default_uflow),
|
||||
JUMP_INIT (pbackfail, _IO_default_pbackfail),
|
||||
JUMP_INIT (xsputn, _IO_default_xsputn),
|
||||
JUMP_INIT (xsgetn, _IO_default_xsgetn),
|
||||
JUMP_INIT (uflow, INTUSE(_IO_default_uflow)),
|
||||
JUMP_INIT (pbackfail, INTUSE(_IO_default_pbackfail)),
|
||||
JUMP_INIT (xsputn, INTUSE(_IO_default_xsputn)),
|
||||
JUMP_INIT (xsgetn, INTUSE(_IO_default_xsgetn)),
|
||||
JUMP_INIT (seekoff, _IO_default_seekoff),
|
||||
JUMP_INIT (seekpos, _IO_default_seekpos),
|
||||
JUMP_INIT (setbuf, _IO_default_setbuf),
|
||||
JUMP_INIT (sync, _IO_default_sync),
|
||||
JUMP_INIT (doallocate, _IO_default_doallocate),
|
||||
JUMP_INIT (doallocate, INTUSE(_IO_default_doallocate)),
|
||||
JUMP_INIT (read, _IO_default_read),
|
||||
JUMP_INIT (write, _IO_default_write),
|
||||
JUMP_INIT (seek, _IO_default_seek),
|
||||
@@ -2083,7 +2156,11 @@ buffered_vfprintf (register _IO_FILE *s, const CHAR_T *format,
|
||||
_IO_JUMPS (&helper._f) = (struct _IO_jump_t *) &_IO_helper_jumps;
|
||||
|
||||
/* Now print to helper instead. */
|
||||
#if defined USE_IN_LIBIO && !defined COMPILE_WPRINTF
|
||||
result = INTUSE(_IO_vfprintf) (hp, format, args);
|
||||
#else
|
||||
result = vfprintf (hp, format, args);
|
||||
#endif
|
||||
|
||||
/* Lock stream. */
|
||||
__libc_cleanup_region_start (1, (void (*) (void *)) &_IO_funlockfile, s);
|
||||
@@ -2186,6 +2263,8 @@ strong_alias (_IO_vfwprintf, __vfwprintf);
|
||||
weak_alias (_IO_vfwprintf, vfwprintf);
|
||||
# else
|
||||
strong_alias (_IO_vfprintf, vfprintf);
|
||||
libc_hidden_def (vfprintf)
|
||||
INTDEF(_IO_vfprintf)
|
||||
# endif
|
||||
# else
|
||||
# if defined __ELF__ || defined __GNU_LIBRARY__
|
||||
|
||||
@@ -2,6 +2,7 @@ SubDir HAIKU_TOP src system libroot posix glibc stdlib ;
|
||||
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include arch $(TARGET_ARCH) ;
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include ;
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc locale ;
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc ;
|
||||
|
||||
KernelMergeObject posix_gnu_stdlib.o :
|
||||
@@ -17,6 +18,9 @@ KernelMergeObject posix_gnu_stdlib.o :
|
||||
lcong48_r.c
|
||||
lrand48.c
|
||||
lrand48_r.c
|
||||
mblen.c
|
||||
mbstowcs.c
|
||||
mbtowc.c
|
||||
mrand48.c
|
||||
mrand48_r.c
|
||||
nrand48.c
|
||||
@@ -25,5 +29,7 @@ KernelMergeObject posix_gnu_stdlib.o :
|
||||
seed48_r.c
|
||||
srand48.c
|
||||
srand48_r.c
|
||||
wcstombs.c
|
||||
wctomb.c
|
||||
: -fPIC -DPIC
|
||||
;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991,1997,1998,1999,2000,2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1997, 1998, 1999, 2000 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,15 +40,13 @@ mblen (const char *s, size_t n)
|
||||
not. */
|
||||
if (s == NULL)
|
||||
{
|
||||
const struct gconv_fcts *fcts;
|
||||
|
||||
/* Get the conversion functions. */
|
||||
fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
|
||||
/* Make sure we use the correct value. */
|
||||
update_conversion_ptrs ();
|
||||
|
||||
/* Reset the state. */
|
||||
memset (&state, '\0', sizeof state);
|
||||
|
||||
result = fcts->towc->__stateful;
|
||||
result = __wcsmbs_gconv_fcts.towc->__stateful;
|
||||
}
|
||||
else if (*s == '\0')
|
||||
/* According to the ISO C 89 standard this is the expected behaviour. */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1992, 1995-1999, 2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 92, 95, 96, 97, 98, 99 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
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
|
||||
/* Common state for all non-restartable conversion functions. */
|
||||
mbstate_t __no_r_state attribute_hidden;
|
||||
mbstate_t __no_r_state;
|
||||
|
||||
/* Convert the multibyte character at S, which is no longer
|
||||
than N characters, to its `wchar_t' representation, placing
|
||||
@@ -44,16 +44,14 @@ mbtowc (wchar_t *pwc, const char *s, size_t n)
|
||||
not. */
|
||||
if (s == NULL)
|
||||
{
|
||||
const struct gconv_fcts *fcts;
|
||||
|
||||
/* Get the conversion functions. */
|
||||
fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
|
||||
/* Make sure we use the correct value. */
|
||||
update_conversion_ptrs ();
|
||||
|
||||
/* This is an extension in the Unix standard which does not directly
|
||||
violate ISO C. */
|
||||
memset (&__no_r_state, '\0', sizeof __no_r_state);
|
||||
|
||||
result = fcts->towc->__stateful;
|
||||
result = __wcsmbs_gconv_fcts.towc->__stateful;
|
||||
}
|
||||
else if (*s == '\0')
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Read decimal floating point numbers.
|
||||
This file is part of the GNU C Library.
|
||||
Copyright (C) 1995-2002, 2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995,96,97,98,99,2000,2001 Free Software Foundation, Inc.
|
||||
Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@@ -64,11 +64,9 @@
|
||||
/* The gmp headers need some configuration frobs. */
|
||||
#define HAVE_ALLOCA 1
|
||||
|
||||
/* Include gmp-mparam.h first, such that definitions of _SHORT_LIMB
|
||||
and _LONG_LONG_LIMB in it can take effect into gmp.h. */
|
||||
#include <gmp-mparam.h>
|
||||
#include <gmp.h>
|
||||
#include <gmp-impl.h>
|
||||
#include <gmp-mparam.h>
|
||||
#include <longlong.h>
|
||||
#include "fpioconst.h"
|
||||
|
||||
@@ -159,7 +157,7 @@ extern FLOAT MPN2FLOAT (mp_srcptr mpn, int exponent, int negative);
|
||||
# define MAX_FAC_PER_LIMB 1000000000UL
|
||||
#elif BITS_PER_MP_LIMB == 64
|
||||
# define MAX_DIG_PER_LIMB 19
|
||||
# define MAX_FAC_PER_LIMB 10000000000000000000ULL
|
||||
# define MAX_FAC_PER_LIMB 10000000000000000000UL
|
||||
#else
|
||||
# error "mp_limb_t size " BITS_PER_MP_LIMB "not accounted for"
|
||||
#endif
|
||||
@@ -168,14 +166,14 @@ extern FLOAT MPN2FLOAT (mp_srcptr mpn, int exponent, int negative);
|
||||
/* Local data structure. */
|
||||
static const mp_limb_t _tens_in_limb[MAX_DIG_PER_LIMB + 1] =
|
||||
{ 0, 10, 100,
|
||||
1000, 10000, 100000L,
|
||||
1000000L, 10000000L, 100000000L,
|
||||
1000000000L
|
||||
1000, 10000, 100000,
|
||||
1000000, 10000000, 100000000,
|
||||
1000000000
|
||||
#if BITS_PER_MP_LIMB > 32
|
||||
, 10000000000ULL, 100000000000ULL,
|
||||
1000000000000ULL, 10000000000000ULL, 100000000000000ULL,
|
||||
1000000000000000ULL, 10000000000000000ULL, 100000000000000000ULL,
|
||||
1000000000000000000ULL, 10000000000000000000ULL
|
||||
, 10000000000U, 100000000000U,
|
||||
1000000000000U, 10000000000000U, 100000000000000U,
|
||||
1000000000000000U, 10000000000000000U, 100000000000000000U,
|
||||
1000000000000000000U, 10000000000000000000U
|
||||
#endif
|
||||
#if BITS_PER_MP_LIMB > 64
|
||||
#error "Need to expand tens_in_limb table to" MAX_DIG_PER_LIMB
|
||||
@@ -558,8 +556,7 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM)
|
||||
/* Return 0.0 if no legal string is found.
|
||||
No character is used even if a sign was found. */
|
||||
#ifdef USE_WIDE_CHAR
|
||||
if (c == (wint_t) decimal
|
||||
&& (wint_t) cp[1] >= L'0' && (wint_t) cp[1] <= L'9')
|
||||
if (c == decimal && cp[1] >= L'0' && cp[1] <= L'9')
|
||||
{
|
||||
/* We accept it. This funny construct is here only to indent
|
||||
the code directly. */
|
||||
@@ -651,7 +648,7 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM)
|
||||
|
||||
/* Ignore leading zeroes. This helps us to avoid useless computations. */
|
||||
#ifdef USE_WIDE_CHAR
|
||||
while (c == L'0' || ((wint_t) thousands != L'\0' && c == (wint_t) thousands))
|
||||
while (c == L'0' || (thousands != L'\0' && c == thousands))
|
||||
c = *++cp;
|
||||
#else
|
||||
if (thousands == NULL)
|
||||
@@ -678,19 +675,17 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM)
|
||||
/* If no other digit but a '0' is found the result is 0.0.
|
||||
Return current read pointer. */
|
||||
if ((c < L_('0') || c > L_('9'))
|
||||
&& (base == 16 && (c < (CHAR_TYPE) TOLOWER (L_('a'))
|
||||
|| c > (CHAR_TYPE) TOLOWER (L_('f'))))
|
||||
&& (base == 16 && (c < TOLOWER (L_('a')) || c > TOLOWER (L_('f'))))
|
||||
#ifdef USE_WIDE_CHAR
|
||||
&& c != (wint_t) decimal
|
||||
&& c != decimal
|
||||
#else
|
||||
&& ({ for (cnt = 0; decimal[cnt] != '\0'; ++cnt)
|
||||
if (decimal[cnt] != cp[cnt])
|
||||
break;
|
||||
decimal[cnt] != '\0'; })
|
||||
#endif
|
||||
&& (base == 16 && (cp == start_of_digits
|
||||
|| (CHAR_TYPE) TOLOWER (c) != L_('p')))
|
||||
&& (base != 16 && (CHAR_TYPE) TOLOWER (c) != L_('e')))
|
||||
&& (base == 16 && (cp == start_of_digits || TOLOWER (c) != L_('p')))
|
||||
&& (base != 16 && TOLOWER (c) != L_('e')))
|
||||
{
|
||||
tp = correctly_grouped_prefix (start_of_digits, cp, thousands, grouping);
|
||||
/* If TP is at the start of the digits, there was no correctly
|
||||
@@ -705,13 +700,12 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM)
|
||||
while (1)
|
||||
{
|
||||
if ((c >= L_('0') && c <= L_('9'))
|
||||
|| (base == 16 && (wint_t) TOLOWER (c) >= L_('a')
|
||||
&& (wint_t) TOLOWER (c) <= L_('f')))
|
||||
|| (base == 16 && TOLOWER (c) >= L_('a') && TOLOWER (c) <= L_('f')))
|
||||
++dig_no;
|
||||
else
|
||||
{
|
||||
#ifdef USE_WIDE_CHAR
|
||||
if ((wint_t) thousands == L'\0' || c != (wint_t) thousands)
|
||||
if (thousands == L'\0' || c != thousands)
|
||||
/* Not a digit or separator: end of the integer part. */
|
||||
break;
|
||||
#else
|
||||
@@ -771,7 +765,7 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM)
|
||||
numbers like `16.' i.e. with decimal but without trailing digits. */
|
||||
if (
|
||||
#ifdef USE_WIDE_CHAR
|
||||
c == (wint_t) decimal
|
||||
c == decimal
|
||||
#else
|
||||
({ for (cnt = 0; decimal[cnt] != '\0'; ++cnt)
|
||||
if (decimal[cnt] != cp[cnt])
|
||||
@@ -1193,10 +1187,10 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM)
|
||||
ceil(BITS / 3) =: N
|
||||
digits we should have enough bits for the result. The remaining
|
||||
decimal digits give us the information that more bits are following.
|
||||
This can be used while rounding. (Two added as a safety margin.) */
|
||||
if (dig_no - int_no > (MANT_DIG - bits + 2) / 3 + 2)
|
||||
This can be used while rounding. (One added as a safety margin.) */
|
||||
if (dig_no - int_no > (MANT_DIG - bits + 2) / 3 + 1)
|
||||
{
|
||||
dig_no = int_no + (MANT_DIG - bits + 2) / 3 + 2;
|
||||
dig_no = int_no + (MANT_DIG - bits + 2) / 3 + 1;
|
||||
more_bits = 1;
|
||||
}
|
||||
else
|
||||
@@ -1474,6 +1468,9 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM)
|
||||
#else
|
||||
for (i = RETURN_LIMB_SIZE; i > empty; --i)
|
||||
retval[i] = retval[i - empty];
|
||||
#endif
|
||||
#if RETURN_LIMB_SIZE > 1
|
||||
retval[1] = 0;
|
||||
#endif
|
||||
for (i = numsize; i > 0; --i)
|
||||
num[i + empty] = num[i - 1];
|
||||
@@ -1563,10 +1560,6 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM)
|
||||
|
||||
/* NOTREACHED */
|
||||
}
|
||||
#if defined _LIBC \
|
||||
&& !(defined USE_IN_EXTENDED_LOCALE_MODEL && defined USE_WIDE_CHAR)
|
||||
libc_hidden_def (INTERNAL (STRTOF))
|
||||
#endif
|
||||
|
||||
/* External user entry point. */
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1992, 1995-1999, 2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 92, 95, 96, 97, 98, 99 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
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <wcsmbs/wcsmbsload.h>
|
||||
|
||||
|
||||
extern mbstate_t __no_r_state attribute_hidden; /* Defined in mbtowc.c. */
|
||||
extern mbstate_t __no_r_state; /* Defined in mbtowc.c. */
|
||||
|
||||
/* Convert WCHAR into its multibyte character representation,
|
||||
putting this in S and returning its length.
|
||||
@@ -40,18 +40,15 @@ wctomb (char *s, wchar_t wchar)
|
||||
not. */
|
||||
if (s == NULL)
|
||||
{
|
||||
const struct gconv_fcts *fcts;
|
||||
|
||||
/* Get the conversion functions. */
|
||||
fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
|
||||
/* Make sure we use the correct value. */
|
||||
update_conversion_ptrs ();
|
||||
|
||||
/* This is an extension in the Unix standard which does not directly
|
||||
violate ISO C. */
|
||||
memset (&__no_r_state, '\0', sizeof __no_r_state);
|
||||
|
||||
return fcts->tomb->__stateful;
|
||||
return __wcsmbs_gconv_fcts.tomb->__stateful;
|
||||
}
|
||||
|
||||
return __wcrtomb (s, wchar, &__no_r_state);
|
||||
}
|
||||
libc_hidden_def (wctomb)
|
||||
|
||||
@@ -7,22 +7,59 @@ SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc libio ;
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc wcsmbs ;
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc iconv ;
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc locale ;
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc stdlib ;
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc ;
|
||||
|
||||
SubDirCcFlags -D_GNU_SOURCE -DUSE_IN_LIBIO ;
|
||||
|
||||
# ToDo: for now, all wide character functions are disabled
|
||||
|
||||
KernelMergeObject posix_gnu_wcsmbs.o :
|
||||
btowc.c
|
||||
mbrlen.c
|
||||
mbrtowc.c
|
||||
mbsinit.c
|
||||
mbsnrtowcs.c
|
||||
mbsrtowcs.c
|
||||
# mbsrtowcs_l.c
|
||||
wcpcpy.c
|
||||
wcpncpy.c
|
||||
wcrtomb.c
|
||||
wcscasecmp.c
|
||||
# wcscasecmp_l.c
|
||||
wcscat.c
|
||||
wcschr.c
|
||||
wcschrnul.c
|
||||
wcscmp.c
|
||||
# wcscoll.c
|
||||
wcscpy.c
|
||||
wcscspn.c
|
||||
wcsdup.c
|
||||
wcslen.c
|
||||
wcsmbsload.c
|
||||
wcsncase.c
|
||||
wcsncat.c
|
||||
wcsncmp.c
|
||||
wcsncpy.c
|
||||
wcsnlen.c
|
||||
wcspbrk.c
|
||||
wcsrchr.c
|
||||
wcsrtombs.c
|
||||
wcsspn.c
|
||||
wcsstr.c
|
||||
# wcstod.c
|
||||
# wcstof.c
|
||||
wcstok.c
|
||||
# wcstold.c
|
||||
wcswidth.c
|
||||
# wcsxfrm.c
|
||||
wctob.c
|
||||
wcwidth.c
|
||||
wmemchr.c
|
||||
wmemcmp.c
|
||||
wmemcpy.c
|
||||
wmempcpy.c
|
||||
wmemmove.c
|
||||
wmempcpy.c
|
||||
wmemset.c
|
||||
: -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.
|
||||
Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
|
||||
|
||||
@@ -30,58 +30,44 @@ wint_t
|
||||
__btowc (c)
|
||||
int c;
|
||||
{
|
||||
const struct gconv_fcts *fcts;
|
||||
wchar_t result;
|
||||
struct __gconv_step_data data;
|
||||
unsigned char inbuf[1];
|
||||
const unsigned char *inptr = inbuf;
|
||||
size_t dummy;
|
||||
int status;
|
||||
|
||||
/* If the parameter does not fit into one byte or it is the EOF value
|
||||
we can give the answer now. */
|
||||
if (c < SCHAR_MIN || c > UCHAR_MAX || c == EOF)
|
||||
return WEOF;
|
||||
|
||||
/* Get the conversion functions. */
|
||||
fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
|
||||
/* Tell where we want the result. */
|
||||
data.__outbuf = (unsigned char *) &result;
|
||||
data.__outbufend = data.__outbuf + sizeof (wchar_t);
|
||||
data.__invocation_counter = 0;
|
||||
data.__internal_use = 1;
|
||||
data.__flags = __GCONV_IS_LAST;
|
||||
data.__statep = &data.__state;
|
||||
data.__trans = NULL;
|
||||
|
||||
if (__builtin_expect (fcts->towc_nsteps == 1, 1)
|
||||
&& __builtin_expect (fcts->towc->__btowc_fct != NULL, 1))
|
||||
{
|
||||
/* Use the shortcut function. */
|
||||
return DL_CALL_FCT (fcts->towc->__btowc_fct,
|
||||
(fcts->towc, (unsigned char) c));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Fall back to the slow but generic method. */
|
||||
wchar_t result;
|
||||
struct __gconv_step_data data;
|
||||
unsigned char inbuf[1];
|
||||
const unsigned char *inptr = inbuf;
|
||||
size_t dummy;
|
||||
int status;
|
||||
/* Make sure we start in the initial state. */
|
||||
memset (&data.__state, '\0', sizeof (mbstate_t));
|
||||
|
||||
/* Tell where we want the result. */
|
||||
data.__outbuf = (unsigned char *) &result;
|
||||
data.__outbufend = data.__outbuf + sizeof (wchar_t);
|
||||
data.__invocation_counter = 0;
|
||||
data.__internal_use = 1;
|
||||
data.__flags = __GCONV_IS_LAST;
|
||||
data.__statep = &data.__state;
|
||||
data.__trans = NULL;
|
||||
/* Make sure we use the correct function. */
|
||||
update_conversion_ptrs ();
|
||||
|
||||
/* Make sure we start in the initial state. */
|
||||
memset (&data.__state, '\0', sizeof (mbstate_t));
|
||||
/* Create the input string. */
|
||||
inbuf[0] = c;
|
||||
|
||||
/* Create the input string. */
|
||||
inbuf[0] = c;
|
||||
status = DL_CALL_FCT (__wcsmbs_gconv_fcts.towc->__fct,
|
||||
(__wcsmbs_gconv_fcts.towc, &data, &inptr, inptr + 1,
|
||||
NULL, &dummy, 0, 1));
|
||||
/* The conversion failed. */
|
||||
if (status != __GCONV_OK && status != __GCONV_FULL_OUTPUT
|
||||
&& status != __GCONV_EMPTY_INPUT)
|
||||
result = WEOF;
|
||||
|
||||
status = DL_CALL_FCT (fcts->towc->__fct,
|
||||
(fcts->towc, &data, &inptr, inptr + 1,
|
||||
NULL, &dummy, 0, 1));
|
||||
|
||||
if (status != __GCONV_OK && status != __GCONV_FULL_OUTPUT
|
||||
&& status != __GCONV_EMPTY_INPUT)
|
||||
/* The conversion failed. */
|
||||
result = WEOF;
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
weak_alias (__btowc, btowc)
|
||||
|
||||
@@ -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 <drepper@gnu.org>, 1996.
|
||||
|
||||
@@ -32,16 +32,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
size_t
|
||||
attribute_hidden
|
||||
__mbsrtowcs_l (dst, src, len, ps, l)
|
||||
wchar_t *dst;
|
||||
const char **src;
|
||||
size_t len;
|
||||
mbstate_t *ps;
|
||||
__locale_t l;
|
||||
#else
|
||||
/* This is the private state used if PS is NULL. */
|
||||
static mbstate_t state;
|
||||
|
||||
@@ -51,35 +41,25 @@ __mbsrtowcs (dst, src, len, ps)
|
||||
const char **src;
|
||||
size_t len;
|
||||
mbstate_t *ps;
|
||||
#endif
|
||||
{
|
||||
struct __gconv_step_data data;
|
||||
size_t result;
|
||||
int status;
|
||||
struct __gconv_step *towc;
|
||||
size_t non_reversible;
|
||||
const struct gconv_fcts *fcts;
|
||||
|
||||
/* Tell where we want the result. */
|
||||
data.__invocation_counter = 0;
|
||||
data.__internal_use = 1;
|
||||
data.__flags = __GCONV_IS_LAST;
|
||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
data.__statep = ps;
|
||||
#else
|
||||
data.__statep = ps ?: &state;
|
||||
#endif
|
||||
data.__trans = NULL;
|
||||
|
||||
/* Get the conversion functions. */
|
||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
fcts = get_gconv_fcts (l->__locales[LC_CTYPE]);
|
||||
#else
|
||||
fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
|
||||
#endif
|
||||
/* Make sure we use the correct function. */
|
||||
update_conversion_ptrs ();
|
||||
|
||||
/* Get the structure with the function pointers. */
|
||||
towc = fcts->towc;
|
||||
towc = __wcsmbs_gconv_fcts.towc;
|
||||
|
||||
/* We have to handle DST == NULL special. */
|
||||
if (dst == NULL)
|
||||
@@ -162,6 +142,4 @@ __mbsrtowcs (dst, src, len, ps)
|
||||
|
||||
return result;
|
||||
}
|
||||
#ifndef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
weak_alias (__mbsrtowcs, mbsrtowcs)
|
||||
#endif
|
||||
|
||||
@@ -38,5 +38,4 @@
|
||||
|
||||
#ifndef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
weak_alias (__wcscoll, wcscoll)
|
||||
libc_hidden_weak (wcscoll)
|
||||
#endif
|
||||
|
||||
@@ -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 <drepper@gnu.ai.mit.edu>, 1996.
|
||||
|
||||
@@ -35,7 +35,6 @@ wctob (c)
|
||||
wchar_t *inptr = inbuf;
|
||||
size_t dummy;
|
||||
int status;
|
||||
const struct gconv_fcts *fcts;
|
||||
|
||||
if (c == WEOF)
|
||||
return EOF;
|
||||
@@ -52,14 +51,14 @@ wctob (c)
|
||||
/* Make sure we start in the initial state. */
|
||||
memset (&data.__state, '\0', sizeof (mbstate_t));
|
||||
|
||||
/* Get the conversion functions. */
|
||||
fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
|
||||
/* Make sure we use the correct function. */
|
||||
update_conversion_ptrs ();
|
||||
|
||||
/* Create the input string. */
|
||||
inbuf[0] = c;
|
||||
|
||||
status = DL_CALL_FCT (fcts->tomb->__fct,
|
||||
(fcts->tomb, &data,
|
||||
status = DL_CALL_FCT (__wcsmbs_gconv_fcts.tomb->__fct,
|
||||
(__wcsmbs_gconv_fcts.tomb, &data,
|
||||
(const unsigned char **) &inptr,
|
||||
(const unsigned char *) &inbuf[1],
|
||||
NULL, &dummy, 0, 1));
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
SubDir HAIKU_TOP src system libroot posix glibc wctype ;
|
||||
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include arch
|
||||
$(TARGET_ARCH) ;
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include ;
|
||||
#SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc libio ;
|
||||
#SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc wcsmbs ;
|
||||
#SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc iconv ;
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc locale ;
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc ;
|
||||
|
||||
KernelMergeObject posix_gnu_wctype.o :
|
||||
iswctype.c
|
||||
wcfuncs.c
|
||||
wctrans.c
|
||||
wctype.c
|
||||
: -fPIC -DPIC
|
||||
;
|
||||
@@ -0,0 +1,36 @@
|
||||
/* Copyright (C) 1996, 2000 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#include "wchar-lookup.h"
|
||||
|
||||
|
||||
int
|
||||
__iswctype (wint_t wc, wctype_t desc)
|
||||
{
|
||||
/* If the user passes in an invalid DESC valid (the one returned from
|
||||
`wctype' in case of an error) simply return 0. */
|
||||
if (desc == (wctype_t) 0)
|
||||
return 0;
|
||||
|
||||
return wctype_table_lookup ((const char *) desc, wc);
|
||||
}
|
||||
weak_alias (__iswctype, iswctype)
|
||||
@@ -0,0 +1,76 @@
|
||||
/* Copyright (C) 1996,1997,1998,1999,2000,2001 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
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <wctype.h>
|
||||
#include <locale/localeinfo.h>
|
||||
|
||||
#include "wchar-lookup.h"
|
||||
|
||||
/* These are not exported. */
|
||||
extern const char *__ctype32_wctype[12];
|
||||
extern const char *__ctype32_wctrans[2];
|
||||
|
||||
/* Provide real-function versions of all the wctype macros. */
|
||||
|
||||
#define func(name, type) \
|
||||
extern int __##name (wint_t __wc); \
|
||||
int \
|
||||
__##name (wint_t wc) \
|
||||
{ \
|
||||
return wctype_table_lookup (__ctype32_wctype[type], wc); \
|
||||
} \
|
||||
weak_alias (__##name, name)
|
||||
|
||||
#undef iswalnum
|
||||
func (iswalnum, __ISwalnum)
|
||||
#undef iswalpha
|
||||
func (iswalpha, __ISwalpha)
|
||||
#undef iswblank
|
||||
func (iswblank, __ISwblank)
|
||||
#undef iswcntrl
|
||||
func (iswcntrl, __ISwcntrl)
|
||||
#undef iswdigit
|
||||
func (iswdigit, __ISwdigit)
|
||||
#undef iswlower
|
||||
func (iswlower, __ISwlower)
|
||||
#undef iswgraph
|
||||
func (iswgraph, __ISwgraph)
|
||||
#undef iswprint
|
||||
func (iswprint, __ISwprint)
|
||||
#undef iswpunct
|
||||
func (iswpunct, __ISwpunct)
|
||||
#undef iswspace
|
||||
func (iswspace, __ISwspace)
|
||||
#undef iswupper
|
||||
func (iswupper, __ISwupper)
|
||||
#undef iswxdigit
|
||||
func (iswxdigit, __ISwxdigit)
|
||||
|
||||
wint_t
|
||||
(towlower) (wc)
|
||||
wint_t wc;
|
||||
{
|
||||
return wctrans_table_lookup (__ctype32_wctrans[__TOW_tolower], wc);
|
||||
}
|
||||
|
||||
wint_t
|
||||
(towupper) (wc)
|
||||
wint_t wc;
|
||||
{
|
||||
return wctrans_table_lookup (__ctype32_wctrans[__TOW_toupper], wc);
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/* Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Bruno Haible <haible@clisp.cons.org>, 2000.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Tables indexed by a wide character are compressed through the use
|
||||
of a multi-level lookup. The compression effect comes from blocks
|
||||
that don't need particular data and from blocks that can share their
|
||||
data. */
|
||||
|
||||
/* Bit tables are accessed by cutting wc in four blocks of bits:
|
||||
- the high 32-q-p bits,
|
||||
- the next q bits,
|
||||
- the next p bits,
|
||||
- the next 5 bits.
|
||||
|
||||
+------------------+-----+-----+-----+
|
||||
wc = + 32-q-p-5 | q | p | 5 |
|
||||
+------------------+-----+-----+-----+
|
||||
|
||||
p and q are variable. For 16-bit Unicode it is sufficient to
|
||||
choose p and q such that q+p+5 <= 16.
|
||||
|
||||
The table contains the following uint32_t words:
|
||||
- q+p+5,
|
||||
- s = upper exclusive bound for wc >> (q+p+5),
|
||||
- p+5,
|
||||
- 2^q-1,
|
||||
- 2^p-1,
|
||||
- 1st-level table: s offsets, pointing into the 2nd-level table,
|
||||
- 2nd-level table: k*2^q offsets, pointing into the 3rd-level table,
|
||||
- 3rd-level table: j*2^p words, each containing 32 bits of data.
|
||||
*/
|
||||
|
||||
static __inline int
|
||||
wctype_table_lookup (const char *table, uint32_t wc)
|
||||
{
|
||||
uint32_t shift1 = ((const uint32_t *) table)[0];
|
||||
uint32_t index1 = wc >> shift1;
|
||||
uint32_t bound = ((const uint32_t *) table)[1];
|
||||
if (index1 < bound)
|
||||
{
|
||||
uint32_t lookup1 = ((const uint32_t *) table)[5 + index1];
|
||||
if (lookup1 != 0)
|
||||
{
|
||||
uint32_t shift2 = ((const uint32_t *) table)[2];
|
||||
uint32_t mask2 = ((const uint32_t *) table)[3];
|
||||
uint32_t index2 = (wc >> shift2) & mask2;
|
||||
uint32_t lookup2 = ((const uint32_t *)(table + lookup1))[index2];
|
||||
if (lookup2 != 0)
|
||||
{
|
||||
uint32_t mask3 = ((const uint32_t *) table)[4];
|
||||
uint32_t index3 = (wc >> 5) & mask3;
|
||||
uint32_t lookup3 = ((const uint32_t *)(table + lookup2))[index3];
|
||||
|
||||
return (lookup3 >> (wc & 0x1f)) & 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Byte tables are similar to bit tables, except that the addressing
|
||||
unit is a single byte, and no 5 bits are used as a word index. */
|
||||
|
||||
static __inline int
|
||||
wcwidth_table_lookup (const char *table, uint32_t wc)
|
||||
{
|
||||
uint32_t shift1 = ((const uint32_t *) table)[0];
|
||||
uint32_t index1 = wc >> shift1;
|
||||
uint32_t bound = ((const uint32_t *) table)[1];
|
||||
if (index1 < bound)
|
||||
{
|
||||
uint32_t lookup1 = ((const uint32_t *) table)[5 + index1];
|
||||
if (lookup1 != 0)
|
||||
{
|
||||
uint32_t shift2 = ((const uint32_t *) table)[2];
|
||||
uint32_t mask2 = ((const uint32_t *) table)[3];
|
||||
uint32_t index2 = (wc >> shift2) & mask2;
|
||||
uint32_t lookup2 = ((const uint32_t *)(table + lookup1))[index2];
|
||||
if (lookup2 != 0)
|
||||
{
|
||||
uint32_t mask3 = ((const uint32_t *) table)[4];
|
||||
uint32_t index3 = wc & mask3;
|
||||
uint8_t lookup3 = ((const uint8_t *)(table + lookup2))[index3];
|
||||
|
||||
return lookup3;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
/* Mapping tables are similar to bit tables, except that the
|
||||
addressing unit is a single signed 32-bit word, containing the
|
||||
difference between the desired result and the argument, and no 5
|
||||
bits are used as a word index. */
|
||||
|
||||
static __inline uint32_t
|
||||
wctrans_table_lookup (const char *table, uint32_t wc)
|
||||
{
|
||||
uint32_t shift1 = ((const uint32_t *) table)[0];
|
||||
uint32_t index1 = wc >> shift1;
|
||||
uint32_t bound = ((const uint32_t *) table)[1];
|
||||
if (index1 < bound)
|
||||
{
|
||||
uint32_t lookup1 = ((const uint32_t *) table)[5 + index1];
|
||||
if (lookup1 != 0)
|
||||
{
|
||||
uint32_t shift2 = ((const uint32_t *) table)[2];
|
||||
uint32_t mask2 = ((const uint32_t *) table)[3];
|
||||
uint32_t index2 = (wc >> shift2) & mask2;
|
||||
uint32_t lookup2 = ((const uint32_t *)(table + lookup1))[index2];
|
||||
if (lookup2 != 0)
|
||||
{
|
||||
uint32_t mask3 = ((const uint32_t *) table)[4];
|
||||
uint32_t index3 = wc & mask3;
|
||||
int32_t lookup3 = ((const int32_t *)(table + lookup2))[index3];
|
||||
|
||||
return wc + lookup3;
|
||||
}
|
||||
}
|
||||
}
|
||||
return wc;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/* Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include <wctype.h>
|
||||
#include "../locale/localeinfo.h"
|
||||
|
||||
wctrans_t
|
||||
wctrans (const char *property)
|
||||
{
|
||||
const char *names;
|
||||
size_t cnt;
|
||||
size_t i;
|
||||
|
||||
names = _NL_CURRENT (LC_CTYPE, _NL_CTYPE_MAP_NAMES);
|
||||
cnt = 0;
|
||||
while (names[0] != '\0')
|
||||
{
|
||||
if (strcmp (property, names) == 0)
|
||||
break;
|
||||
|
||||
names = strchr (names, '\0') + 1;
|
||||
++cnt;
|
||||
}
|
||||
|
||||
if (names[0] == '\0')
|
||||
return 0;
|
||||
|
||||
i = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_OFFSET) + cnt;
|
||||
return (wctrans_t) _nl_current_LC_CTYPE->values[i].string;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/* Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <endian.h>
|
||||
#include <string.h>
|
||||
#include <wctype.h>
|
||||
#include <locale/localeinfo.h>
|
||||
|
||||
wctype_t
|
||||
__wctype (const char *property)
|
||||
{
|
||||
const char *names;
|
||||
unsigned int result;
|
||||
size_t proplen = strlen (property);
|
||||
size_t i;
|
||||
|
||||
names = _NL_CURRENT (LC_CTYPE, _NL_CTYPE_CLASS_NAMES);
|
||||
for (result = 0; ; result++)
|
||||
{
|
||||
size_t nameslen = strlen (names);
|
||||
|
||||
if (proplen == nameslen && memcmp (property, names, proplen) == 0)
|
||||
break;
|
||||
|
||||
names += nameslen + 1;
|
||||
if (names[0] == '\0')
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_CLASS_OFFSET) + result;
|
||||
return (wctype_t) _nl_current_LC_CTYPE->values[i].string;
|
||||
}
|
||||
weak_alias (__wctype, wctype)
|
||||
@@ -14,7 +14,7 @@ KernelMergeObject posix_stdlib.o :
|
||||
heapsort.c
|
||||
merge.c
|
||||
mktemp.c
|
||||
multibyte.c
|
||||
# multibyte.c
|
||||
qsort.c
|
||||
radixsort.c
|
||||
rand.c
|
||||
|
||||
Reference in New Issue
Block a user