From 80f30d4de0087b1cc769bd532fc1d6d5b47a669f Mon Sep 17 00:00:00 2001 From: kleink Date: Wed, 28 Nov 2001 11:58:22 +0000 Subject: [PATCH] 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. --- lib/libc/stdio/vfprintf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index 479083c4d77a..f042f3838290 100644 --- a/lib/libc/stdio/vfprintf.c +++ b/lib/libc/stdio/vfprintf.c @@ -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 @@ cvt(value, ndigits, flags, sign, decpt, ch, length) 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') {