From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 126973 invoked by alias); 6 Sep 2018 12:21:55 -0000 Mailing-List: contact newlib-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-cvs-owner@sourceware.org Received: (qmail 126954 invoked by uid 9078); 6 Sep 2018 12:21:54 -0000 Date: Thu, 06 Sep 2018 12:21:00 -0000 Message-ID: <20180906122154.126952.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] stdlib: Use __get_numeric_locale instead of __localeconv_l for decimal_point X-Act-Checkin: newlib-cygwin X-Git-Author: Keith Packard X-Git-Refname: refs/heads/master X-Git-Oldrev: 28ecec475ff423b368bcca329f42cfed29308d61 X-Git-Newrev: 3b6994ec5f5fb47ba87fb3dae154cad21017b30d X-SW-Source: 2018-q3/txt/msg00118.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=3b6994ec5f5fb47ba87fb3dae154cad21017b30d commit 3b6994ec5f5fb47ba87fb3dae154cad21017b30d Author: Keith Packard Date: Wed Sep 5 21:25:01 2018 -0700 stdlib: Use __get_numeric_locale instead of __localeconv_l for decimal_point The string/float conversion functions need to get the locale decimal point. Instead of calling __localeconv_l (which copies locale data into lconv form from __get_numeric_locale), use __get_numeric_locale directly. Signed-off-by: Keith Packard Diff: --- newlib/libc/stdlib/gdtoa-gethex.c | 4 ++-- newlib/libc/stdlib/strtod.c | 6 +++--- newlib/libc/stdlib/strtodg.c | 6 +++--- newlib/libc/stdlib/wcstod.c | 6 +++--- newlib/libc/stdlib/wcstold.c | 5 +++-- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/newlib/libc/stdlib/gdtoa-gethex.c b/newlib/libc/stdlib/gdtoa-gethex.c index d160015..e0c2fff 100644 --- a/newlib/libc/stdlib/gdtoa-gethex.c +++ b/newlib/libc/stdlib/gdtoa-gethex.c @@ -149,8 +149,8 @@ gethex (struct _reent *ptr, const char **sp, const FPI *fpi, int esign, havedig, irv, k, n, nbits, up, zret; __ULong L, lostbits, *x; Long e, e1; - unsigned char *decimalpoint = (unsigned char *) - __localeconv_l (loc)->decimal_point; + const unsigned char *decimalpoint = (unsigned char *) + __get_numeric_locale(loc)->decimal_point; size_t decp_len = strlen ((const char *) decimalpoint); unsigned char decp_end = decimalpoint[decp_len - 1]; diff --git a/newlib/libc/stdlib/strtod.c b/newlib/libc/stdlib/strtod.c index 2a76b10..8bb75ef 100644 --- a/newlib/libc/stdlib/strtod.c +++ b/newlib/libc/stdlib/strtod.c @@ -263,8 +263,8 @@ _strtod_l (struct _reent *ptr, const char *__restrict s00, char **__restrict se, #ifdef Honor_FLT_ROUNDS int rounding; #endif - struct lconv *lconv = __localeconv_l (loc); - int dec_len = strlen (lconv->decimal_point); + const char *decimal_point = __get_numeric_locale(loc)->decimal_point; + int dec_len = strlen (decimal_point); delta = bs = bd = NULL; sign = nz0 = nz = decpt = 0; @@ -344,7 +344,7 @@ _strtod_l (struct _reent *ptr, const char *__restrict s00, char **__restrict se, else z = 10*z + c - '0'; nd0 = nd; - if (strncmp (s, lconv->decimal_point, dec_len) == 0) + if (strncmp (s, decimal_point, dec_len) == 0) { decpt = 1; c = *(s += dec_len); diff --git a/newlib/libc/stdlib/strtodg.c b/newlib/libc/stdlib/strtodg.c index c8e581c..0133159 100644 --- a/newlib/libc/stdlib/strtodg.c +++ b/newlib/libc/stdlib/strtodg.c @@ -419,8 +419,8 @@ _strtodg_l (struct _reent *p, const char *s00, char **se, FPI *fpi, Long *exp, Long L; __ULong y, z; _Bigint *ab, *bb, *bb1, *bd, *bd0, *bs, *delta, *rvb, *rvb0; - struct lconv *lconv = __localeconv_l (loc); - int dec_len = strlen (lconv->decimal_point); + const char *decimal_point = __get_numeric_locale(loc)->decimal_point; + int dec_len = strlen (decimal_point); irv = STRTOG_Zero; denorm = sign = nz0 = nz = 0; @@ -479,7 +479,7 @@ _strtodg_l (struct _reent *p, const char *s00, char **se, FPI *fpi, Long *exp, z = 10*z + c - '0'; nd0 = nd; #ifdef USE_LOCALE - if (strncmp (s, lconv->decimal_point, dec_len) == 0) + if (strncmp (s, decimal_point, dec_len) == 0) #else if (c == '.') #endif diff --git a/newlib/libc/stdlib/wcstod.c b/newlib/libc/stdlib/wcstod.c index 810c5b3..375ffe2 100644 --- a/newlib/libc/stdlib/wcstod.c +++ b/newlib/libc/stdlib/wcstod.c @@ -188,6 +188,7 @@ _wcstod_l (struct _reent *ptr, const wchar_t *nptr, wchar_t **endptr, * corresponding position in the wide char string. */ if (endptr != NULL) { + const char *decimal_point = __get_numeric_locale(loc)->decimal_point; /* The only valid multibyte char in a float converted by strtod/wcstod is the radix char. What we do here is, figure out if the radix char was in the valid leading @@ -198,10 +199,9 @@ _wcstod_l (struct _reent *ptr, const wchar_t *nptr, wchar_t **endptr, just one byte long. The resulting difference (end - buf) is then equivalent to the number of valid wide characters in the input string. */ - len = strlen (__localeconv_l (loc)->decimal_point); + len = strlen (decimal_point); if (len > 1) { - char *d = strstr (buf, - __localeconv_l (loc)->decimal_point); + char *d = strstr (buf, decimal_point); if (d && d < end) end -= len - 1; } diff --git a/newlib/libc/stdlib/wcstold.c b/newlib/libc/stdlib/wcstold.c index 4876e11..673d928 100644 --- a/newlib/libc/stdlib/wcstold.c +++ b/newlib/libc/stdlib/wcstold.c @@ -83,6 +83,7 @@ wcstold_l (const wchar_t *__restrict nptr, wchar_t **__restrict endptr, if (endptr != NULL) { + const char *decimal_point = __get_numeric_locale(loc)->decimal_point; /* The only valid multibyte char in a float converted by strtold/wcstold is the radix char. What we do here is, figure out if the radix char was in the valid leading @@ -93,10 +94,10 @@ wcstold_l (const wchar_t *__restrict nptr, wchar_t **__restrict endptr, just one byte long. The resulting difference (end - buf) is then equivalent to the number of valid wide characters in the input string. */ - len = strlen (__localeconv_l (loc)->decimal_point); + len = strlen (decimal_point); if (len > 1) { - char *d = strstr (buf, __localeconv_l (loc)->decimal_point); + char *d = strstr (buf, decimal_point); if (d && d < end) end -= len - 1;