[1/3] Fix fcvt to only show 'ndigit' past decimal

Message ID 20191218060049.660325-1-keithp@keithp.com
State Superseded
Headers show
Series
  • [1/3] Fix fcvt to only show 'ndigit' past decimal
Related show

Commit Message

Keith Packard Dec. 18, 2019, 6 a.m.
Even if the number is really small and this means showing *no* digits.
This makes newlib match glibc, and the fcvt posix man page.

Signed-off-by: Keith Packard <keithp@keithp.com>

---
 newlib/libc/stdlib/ecvtbuf.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

-- 
2.24.0

Comments

Corinna Vinschen Dec. 18, 2019, 8:53 a.m. | #1
Hi Keith,

On Dec 17 22:00, Keith Packard wrote:
> Even if the number is really small and this means showing *no* digits.

> This makes newlib match glibc, and the fcvt posix man page.

> 

> Signed-off-by: Keith Packard <keithp@keithp.com>

> ---

>  newlib/libc/stdlib/ecvtbuf.c | 9 +--------

>  1 file changed, 1 insertion(+), 8 deletions(-)

> 

> diff --git a/newlib/libc/stdlib/ecvtbuf.c b/newlib/libc/stdlib/ecvtbuf.c

> index e3d7b55d8..0a5d41a0f 100644

> --- a/newlib/libc/stdlib/ecvtbuf.c

> +++ b/newlib/libc/stdlib/ecvtbuf.c

> @@ -235,14 +235,7 @@ fcvtbuf (double invalue,

>  

>    save = fcvt_buf;

>  

> -  if (invalue < 1.0 && invalue > -1.0)

> -    {

> -      p = _dtoa_r (reent, invalue, 2, ndigit, decpt, sign, &end);

> -    }

> -  else

> -    {

> -      p = _dtoa_r (reent, invalue, 3, ndigit, decpt, sign, &end);

> -    }

> +  p = _dtoa_r (invalue, 3, ndigit, decpt, sign, &end);

                ^^^^^
There's a reent ptr missing in this call.  I'm puzzled that this
compiled for you.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
Keith Packard Dec. 18, 2019, 4:48 p.m. | #2
Corinna Vinschen <vinschen@redhat.com> writes:

> There's a reent ptr missing in this call.  I'm puzzled that this

> compiled for you.


I'm rebasing fixes from a version of this code which uses TLS instead of
reent as I don't have any way of running the tests using the newlib
codebase. I messed up the rebase this time. Just trying to keep the two
versions in sync by sending all of my fixes along.

Sorry for wasting your time! The next version has actually been
compiled...

-- 
-keith
Corinna Vinschen Dec. 18, 2019, 7:57 p.m. | #3
On Dec 18 08:48, Keith Packard wrote:
> Corinna Vinschen <vinschen@redhat.com> writes:

> 

> > There's a reent ptr missing in this call.  I'm puzzled that this

> > compiled for you.

> 

> I'm rebasing fixes from a version of this code which uses TLS instead of

> reent as I don't have any way of running the tests using the newlib

> codebase. I messed up the rebase this time. Just trying to keep the two

> versions in sync by sending all of my fixes along.

> 

> Sorry for wasting your time! The next version has actually been

> compiled...


No worries, I pushed all three patches now.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

Patch

diff --git a/newlib/libc/stdlib/ecvtbuf.c b/newlib/libc/stdlib/ecvtbuf.c
index e3d7b55d8..0a5d41a0f 100644
--- a/newlib/libc/stdlib/ecvtbuf.c
+++ b/newlib/libc/stdlib/ecvtbuf.c
@@ -235,14 +235,7 @@  fcvtbuf (double invalue,
 
   save = fcvt_buf;
 
-  if (invalue < 1.0 && invalue > -1.0)
-    {
-      p = _dtoa_r (reent, invalue, 2, ndigit, decpt, sign, &end);
-    }
-  else
-    {
-      p = _dtoa_r (reent, invalue, 3, ndigit, decpt, sign, &end);
-    }
+  p = _dtoa_r (invalue, 3, ndigit, decpt, sign, &end);
 
   /* Now copy */