Re: [PATCH] Fix ecvt to pass tests
Corinna Vinschen <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
Hi Keith, On Dec 16 13:54, Keith Packard wrote: > Elide decimal point when no digits are right of that. Fix computation > of trailing zero length. > > Signed-off-by: Keith Packard <[email protected]> > --- > newlib/libc/stdlib/ecvtbuf.c | 17 +++++++++++++---- > 1 file changed, 13 insertions(+), 4 deletions(-) > > diff --git a/newlib/libc/stdlib/ecvtbuf.c b/newlib/libc/stdlib/ecvtbuf.c > index e3d7b55d8..d2ba6359d 100644 > --- a/newlib/libc/stdlib/ecvtbuf.c > +++ b/newlib/libc/stdlib/ecvtbuf.c > @@ -93,7 +93,8 @@ print_f (struct _reent *ptr, > { > if (p == start) > *buf++ = '0'; > - *buf++ = '.'; > + if (decpt < 0 && ndigit > 0) > + *buf++ = '.'; > while (decpt < 0 && ndigit > 0) > { > *buf++ = '0'; > @@ -148,11 +149,15 @@ print_e (struct _reent *ptr, > } > > *buf++ = *p++; > - if (dot || ndigit != 0) > - *buf++ = '.'; > + if (ndigit > 0) > + dot = 1; > > while (*p && ndigit > 0) > { > + if (dot) { > + *buf++ = '.'; > + dot = 0; > + } > *buf++ = *p++; > ndigit--; > } > @@ -168,6 +173,10 @@ print_e (struct _reent *ptr, > { > while (ndigit > 0) > { > + if (dot) { > + *buf++ = '.'; > + dot = 0; > + } > *buf++ = '0'; > ndigit--; > } > @@ -246,7 +255,7 @@ fcvtbuf (double invalue, > > /* Now copy */ > > - done = -*decpt; > + done = 0; > while (p < end) > { > *fcvt_buf++ = *p++; That last hunk is not immediately clear to me. Can you explain this a bit or even add some more text to the commit message? Thanks, Corinna -- Corinna Vinschen Cygwin Maintainer Red Hat
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAl34m7wACgkQ9TYGna5E T6C3qhAAktpith5N5TqVaOWK6pdpQzJ/2wfkTgn+s2QzLTefrezCEZ1jjssfYlvK Snx8gV3SuQf8l8+Xgbpl1SP9GoXNp38IFkvsYC5B8s7npoLJFdRLC7g3PfejOxkF +Q6V+g+ezlIUL04w9B3QsSl/onIakKS4jYAq8xHOkxzN0vR2TJvMw5ng7mFufov4 +TUclXzy2Ny/8Y1uAbc+CtlXhFEDRhqThggWhFxlLhJFthEgVmZTRuF5rJLhWvzm 5xpxIVmYu+PYl3qCZzpC1+a3VVxQj9BDQXzVi0i0iFdem962YJPh6WOVCPV+o5th 8xirh0jtAmfR9vDRT4gdTcH/ng0rB+OKPxeWCvVupkUiTBXXMQnLDiGTUB8Iw4hi oSxriu9MhrAWo7ZGARPe0YFF19ZRbK4evj6AI2Q0jcb70Ml7A01MturTvLbX0XzR ID68FSoG5QV5Grz98Z+07Oc+c0s/tF0LpcHZvySSfwHX8WeFShaE+nGFBCRcfHuZ VJHg/4IVmT8qASmnLGxMRRuKy/DeSkF+DXQOu4u4VDp1YpmdTs+s5jEyIFDKGvX4 aRuncVMbjet5umYLQzkMSST5otuFPRKA4oHVGqnlljZBCuZPuU5l1dgkFvrZDARD 1rDuZEx7jE2eaIAxgy+THnyu7soLU3PbDXARnjzN7gXcEWxTFQs= =IpkA -----END PGP SIGNATURE-----