Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/stdio Since we're returned the sign of a floating-p...



details:   https://anonhg.NetBSD.org/src/rev/439b2a209cfe
branches:  trunk
changeset: 518331:439b2a209cfe
user:      kleink <kleink%NetBSD.org@localhost>
date:      Wed Nov 28 11:58:22 2001 +0000

description:
Since we're returned the sign of a floating-point number by __dtoa(),
use that to decide whether to include a minus sign in the result.
Fixes printing -0.0, and thus PR lib/3137.

diffstat:

 lib/libc/stdio/vfprintf.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (33 lines):

diff -r 1b0e500ad2b5 -r 439b2a209cfe lib/libc/stdio/vfprintf.c
--- a/lib/libc/stdio/vfprintf.c Wed Nov 28 11:56:43 2001 +0000
+++ b/lib/libc/stdio/vfprintf.c Wed Nov 28 11:58:22 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfprintf.c,v 1.39 2001/11/27 18:05:30 augustss Exp $   */
+/*     $NetBSD: vfprintf.c,v 1.40 2001/11/28 11:58:22 kleink Exp $     */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -41,7 +41,7 @@
 #if 0
 static char *sccsid = "@(#)vfprintf.c  5.50 (Berkeley) 12/16/92";
 #else
-__RCSID("$NetBSD: vfprintf.c,v 1.39 2001/11/27 18:05:30 augustss Exp $");
+__RCSID("$NetBSD: vfprintf.c,v 1.40 2001/11/28 11:58:22 kleink Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -812,12 +812,12 @@
                mode = 2;               /* ndigits significant digits */
        }
 
-       if (value < 0) {
+       digits = __dtoa(value, mode, ndigits, decpt, &dsgn, &rve);
+       if (dsgn) {
                value = -value;
                *sign = '-';
        } else
                *sign = '\000';
-       digits = __dtoa(value, mode, ndigits, decpt, &dsgn, &rve);
        if ((ch != 'g' && ch != 'G') || flags & ALT) {  /* Print trailing zeros */
                bp = digits + ndigits;
                if (ch == 'f') {



Home | Main Index | Thread Index | Old Index