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] Don't display trailing '.' in _dcvt Date: Wed, 18 Dec 2019 19:57:00 -0000 [thread overview] Message-ID: <20191218195703.125942.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=76dcfd0c4d31ef2658564ba2fac8b1852704c45a commit 76dcfd0c4d31ef2658564ba2fac8b1852704c45a Author: Keith Packard <keithp@keithp.com> Date: Tue Dec 17 22:00:49 2019 -0800 Don't display trailing '.' in _dcvt In the two helper functions that _dcvt calls for 'f' and 'e' mode, if there are no digits to display after the decimal point, don't add one. Signed-off-by: Keith Packard <keithp@keithp.com> Diff: --- newlib/libc/stdlib/ecvtbuf.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/newlib/libc/stdlib/ecvtbuf.c b/newlib/libc/stdlib/ecvtbuf.c index 228362e..0cb11f8 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--; }
reply other threads:[~2019-12-18 19:57 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=20191218195703.125942.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: linkBe 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).