From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125960 invoked by alias); 18 Dec 2019 19:57:03 -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 125943 invoked by uid 9078); 18 Dec 2019 19:57:03 -0000 Date: Wed, 18 Dec 2019 19:57:00 -0000 Message-ID: <20191218195703.125942.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] Don't display trailing '.' in _dcvt X-Act-Checkin: newlib-cygwin X-Git-Author: Keith Packard X-Git-Refname: refs/heads/master X-Git-Oldrev: 11f99384d2971356bab2fcac7e29792250abea73 X-Git-Newrev: 76dcfd0c4d31ef2658564ba2fac8b1852704c45a X-SW-Source: 2019-q4/txt/msg00030.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=76dcfd0c4d31ef2658564ba2fac8b1852704c45a commit 76dcfd0c4d31ef2658564ba2fac8b1852704c45a Author: Keith Packard 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 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--; }