public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: newlib-cvs@sourceware.org
Subject: [newlib-cygwin] stdlib: Use __get_numeric_locale instead of __localeconv_l for decimal_point
Date: Thu, 06 Sep 2018 12:21:00 -0000	[thread overview]
Message-ID: <20180906122154.126952.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=3b6994ec5f5fb47ba87fb3dae154cad21017b30d

commit 3b6994ec5f5fb47ba87fb3dae154cad21017b30d
Author: Keith Packard <keithp@keithp.com>
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 <keithp@keithp.com>

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;


                 reply	other threads:[~2018-09-06 12:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180906122154.126952.qmail@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=newlib-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).