summaryrefslogtreecommitdiff
path: root/libc/stdlib
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2003-08-24 03:49:13 +0000
committerManuel Novoa III <mjn3@codepoet.org>2003-08-24 03:49:13 +0000
commit50660812be5588036a14fc85af16bccef68fac02 (patch)
tree65f25cc1dda3c7efc76efee2c61b28973465db2a /libc/stdlib
parent02f74937667727e32c591afe42e90e2b515ab61e (diff)
Fix a few bugs in the new extended locale functions.
Move stub gettext functions to a stub libintl to make switching in gnu gettext easier. Also add a few gnu-isms. Change to using hidden names with global weak aliases for the extended locale functions, as expected by libstd++. Slightly rework the locale data generation stuff to allow pregenerated locale data to be used with buildroot.
Diffstat (limited to 'libc/stdlib')
-rw-r--r--libc/stdlib/stdlib.c48
-rw-r--r--libc/stdlib/strtod.c31
2 files changed, 54 insertions, 25 deletions
diff --git a/libc/stdlib/stdlib.c b/libc/stdlib/stdlib.c
index 68b1af8b7..c31f5f251 100644
--- a/libc/stdlib/stdlib.c
+++ b/libc/stdlib/stdlib.c
@@ -299,9 +299,11 @@ strong_alias(__XL(strtol),__XL(strtoll))
long __XL(strtol)(const char * __restrict str, char ** __restrict endptr,
int base __LOCALE_PARAM )
{
- return __XL(_stdlib_strto_l)(str, endptr, base, 1 __LOCALE_ARG );
+ return __XL_NPP(_stdlib_strto_l)(str, endptr, base, 1 __LOCALE_ARG );
}
+__XL_ALIAS(strtol)
+
#endif
/**********************************************************************/
#if defined(L_strtoll) || defined(L_strtoll_l)
@@ -319,10 +321,12 @@ long long __XL(strtoll)(const char * __restrict str,
char ** __restrict endptr, int base
__LOCALE_PARAM )
{
- return (long long) __XL(_stdlib_strto_ll)(str, endptr, base, 1
- __LOCALE_ARG );
+ return (long long) __XL_NPP(_stdlib_strto_ll)(str, endptr, base, 1
+ __LOCALE_ARG );
}
+__XL_ALIAS(strtoll)
+
#endif /* defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX) */
#endif
@@ -341,9 +345,11 @@ unsigned long __XL(strtoul)(const char * __restrict str,
char ** __restrict endptr, int base
__LOCALE_PARAM )
{
- return __XL(_stdlib_strto_l)(str, endptr, base, 0 __LOCALE_ARG );
+ return __XL_NPP(_stdlib_strto_l)(str, endptr, base, 0 __LOCALE_ARG );
}
+__XL_ALIAS(strtoul)
+
#endif
/**********************************************************************/
#if defined(L_strtoull) || defined(L_strtoull_l)
@@ -361,9 +367,11 @@ unsigned long long __XL(strtoull)(const char * __restrict str,
char ** __restrict endptr, int base
__LOCALE_PARAM )
{
- return __XL(_stdlib_strto_ll)(str, endptr, base, 0 __LOCALE_ARG );
+ return __XL_NPP(_stdlib_strto_ll)(str, endptr, base, 0 __LOCALE_ARG );
}
+__XL_ALIAS(strtoull)
+
#endif /* defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX) */
#endif
@@ -432,9 +440,9 @@ unsigned long _stdlib_strto_l(register const Wchar * __restrict str,
/* This is the main work fuction which handles both strtol (sflag = 1) and
* strtoul (sflag = 0). */
-unsigned long __XL(_stdlib_strto_l)(register const Wchar * __restrict str,
- Wchar ** __restrict endptr, int base,
- int sflag __LOCALE_PARAM )
+unsigned long __XL_NPP(_stdlib_strto_l)(register const Wchar * __restrict str,
+ Wchar ** __restrict endptr, int base,
+ int sflag __LOCALE_PARAM )
{
unsigned long number, cutoff;
#if _STRTO_ENDPTR
@@ -575,9 +583,9 @@ unsigned long long _stdlib_strto_ll(register const Wchar * __restrict str,
/* This is the main work fuction which handles both strtoll (sflag = 1) and
* strtoull (sflag = 0). */
-unsigned long long __XL(_stdlib_strto_ll)(register const Wchar * __restrict str,
- Wchar ** __restrict endptr, int base,
- int sflag __LOCALE_PARAM )
+unsigned long long __XL_NPP(_stdlib_strto_ll)(register const Wchar * __restrict str,
+ Wchar ** __restrict endptr, int base,
+ int sflag __LOCALE_PARAM )
{
unsigned long long number;
#if _STRTO_ENDPTR
@@ -956,9 +964,11 @@ strong_alias(__XL(wcstol),__XL(wcstoll))
long __XL(wcstol)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base __LOCALE_PARAM )
{
- return __XL(_stdlib_wcsto_l)(str, endptr, base, 1 __LOCALE_ARG );
+ return __XL_NPP(_stdlib_wcsto_l)(str, endptr, base, 1 __LOCALE_ARG );
}
+__XL_ALIAS(wcstol)
+
#endif
/**********************************************************************/
#if defined(L_wcstoll) || defined(L_wcstoll_l)
@@ -976,10 +986,12 @@ long long __XL(wcstoll)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base
__LOCALE_PARAM )
{
- return (long long) __XL(_stdlib_wcsto_ll)(str, endptr, base, 1
- __LOCALE_ARG );
+ return (long long) __XL_NPP(_stdlib_wcsto_ll)(str, endptr, base, 1
+ __LOCALE_ARG );
}
+__XL_ALIAS(wcstoll)
+
#endif /* defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX) */
#endif
@@ -998,9 +1010,11 @@ unsigned long __XL(wcstoul)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base
__LOCALE_PARAM )
{
- return __XL(_stdlib_wcsto_l)(str, endptr, base, 0 __LOCALE_ARG );
+ return __XL_NPP(_stdlib_wcsto_l)(str, endptr, base, 0 __LOCALE_ARG );
}
+__XL_ALIAS(wcstoul)
+
#endif
/**********************************************************************/
#if defined(L_wcstoull) || defined(L_wcstoull_l)
@@ -1018,9 +1032,11 @@ unsigned long long __XL(wcstoull)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base
__LOCALE_PARAM )
{
- return __XL(_stdlib_wcsto_ll)(str, endptr, base, 0 __LOCALE_ARG );
+ return __XL_NPP(_stdlib_wcsto_ll)(str, endptr, base, 0 __LOCALE_ARG );
}
+__XL_ALIAS(wcstoull)
+
#endif /* defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX) */
#endif
diff --git a/libc/stdlib/strtod.c b/libc/stdlib/strtod.c
index c4d95bab1..f7625c5ae 100644
--- a/libc/stdlib/strtod.c
+++ b/libc/stdlib/strtod.c
@@ -222,8 +222,8 @@ __fpmax_t __strtofpmax(const Wchar *str, Wchar **endptr, int exponent_power)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
-__fpmax_t __XL(__strtofpmax)(const Wchar *str, Wchar **endptr, int exponent_power
- __LOCALE_PARAM )
+__fpmax_t __XL_NPP(__strtofpmax)(const Wchar *str, Wchar **endptr, int exponent_power
+ __LOCALE_PARAM )
{
__fpmax_t number;
__fpmax_t p_base = 10; /* Adjusted to 16 in the hex case. */
@@ -522,6 +522,8 @@ extern void __fp_range_check(__fpmax_t y, __fpmax_t x)
#if defined(L_wcstof) || defined(L_wcstof_l)
#define strtof wcstof
#define strtof_l wcstof_l
+#define __strtof __wcstof
+#define __strtof_l __wcstof_l
#define __strtofpmax __wcstofpmax
#define __strtofpmax_l __wcstofpmax_l
#define Wchar wchar_t
@@ -533,12 +535,12 @@ extern void __fp_range_check(__fpmax_t y, __fpmax_t x)
float __XL(strtof)(const Wchar *str, Wchar **endptr __LOCALE_PARAM )
{
#if FPMAX_TYPE == 1
- return __XL(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
+ return __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
#else
__fpmax_t x;
float y;
- x = __XL(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
+ x = __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
y = (float) x;
__fp_range_check(y, x);
@@ -547,6 +549,8 @@ float __XL(strtof)(const Wchar *str, Wchar **endptr __LOCALE_PARAM )
#endif
}
+__XL_ALIAS(strtof)
+
#endif
#endif
/**********************************************************************/
@@ -556,6 +560,8 @@ float __XL(strtof)(const Wchar *str, Wchar **endptr __LOCALE_PARAM )
#if defined(L_wcstod) || defined(L_wcstod_l)
#define strtod wcstod
#define strtod_l wcstod_l
+#define __strtod __wcstod
+#define __strtod_l __wcstod_l
#define __strtofpmax __wcstofpmax
#define __strtofpmax_l __wcstofpmax_l
#define Wchar wchar_t
@@ -563,15 +569,16 @@ float __XL(strtof)(const Wchar *str, Wchar **endptr __LOCALE_PARAM )
#define Wchar char
#endif
-double __XL(strtod)(const Wchar *str, Wchar **endptr __LOCALE_PARAM )
+double __XL(strtod)(const Wchar *__restrict str,
+ Wchar **__restrict endptr __LOCALE_PARAM )
{
#if FPMAX_TYPE == 2
- return __XL(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
+ return __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
#else
__fpmax_t x;
double y;
- x = __XL(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
+ x = __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
y = (double) x;
__fp_range_check(y, x);
@@ -580,6 +587,8 @@ double __XL(strtod)(const Wchar *str, Wchar **endptr __LOCALE_PARAM )
#endif
}
+__XL_ALIAS(strtod)
+
#endif
#endif
/**********************************************************************/
@@ -589,6 +598,8 @@ double __XL(strtod)(const Wchar *str, Wchar **endptr __LOCALE_PARAM )
#if defined(L_wcstold) || defined(L_wcstold_l)
#define strtold wcstold
#define strtold_l wcstold_l
+#define __strtold __wcstold
+#define __strtold_l __wcstold_l
#define __strtofpmax __wcstofpmax
#define __strtofpmax_l __wcstofpmax_l
#define Wchar wchar_t
@@ -599,12 +610,12 @@ double __XL(strtod)(const Wchar *str, Wchar **endptr __LOCALE_PARAM )
long double __XL(strtold)(const Wchar *str, Wchar **endptr __LOCALE_PARAM )
{
#if FPMAX_TYPE == 3
- return __XL(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
+ return __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
#else
__fpmax_t x;
long double y;
- x = __XL(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
+ x = __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
y = (long double) x;
__fp_range_check(y, x);
@@ -613,6 +624,8 @@ long double __XL(strtold)(const Wchar *str, Wchar **endptr __LOCALE_PARAM )
#endif
}
+__XL_ALIAS(strtold)
+
#endif
#endif
/**********************************************************************/