From 1e745892f72a6490f4783b86b64e88e0c5c4bf61 Mon Sep 17 00:00:00 2001 From: millert <> Date: Tue, 10 Jan 2006 16:18:37 +0000 Subject: Return inf or nan as per printf() not Inf, Infinity or Nan (from dtoa) Remove an extraneous check for dtoa returning Inf/Nan --- src/lib/libc/stdlib/ecvt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/lib/libc/stdlib/ecvt.c') diff --git a/src/lib/libc/stdlib/ecvt.c b/src/lib/libc/stdlib/ecvt.c index 9289b3bf8a..eb0e428996 100644 --- a/src/lib/libc/stdlib/ecvt.c +++ b/src/lib/libc/stdlib/ecvt.c @@ -1,7 +1,7 @@ -/* $OpenBSD: ecvt.c,v 1.4 2005/08/08 08:05:36 espie Exp $ */ +/* $OpenBSD: ecvt.c,v 1.5 2006/01/10 16:18:37 millert Exp $ */ /* - * Copyright (c) 2002 Todd C. Miller + * Copyright (c) 2002, 2006 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -62,11 +62,11 @@ __cvt(double value, int ndigit, int *decpt, int *sign, int fmode, int pad) } else { p = __dtoa(value, fmode + 2, ndigit, decpt, sign, &rve); if (*decpt == 9999) { - /* Nan or Infinity */ + /* Infinity or Nan, convert to inf or nan like printf */ *decpt = 0; - return(p); + return(*p == 'I' ? "inf" : "nan"); } - /* make a local copy and adjust rve to be in terms of s */ + /* Make a local copy and adjust rve to be in terms of s */ if (pad && fmode) siz += *decpt; if ((s = (char *)malloc(siz)) == NULL) @@ -75,8 +75,8 @@ __cvt(double value, int ndigit, int *decpt, int *sign, int fmode, int pad) rve = s + (rve - p); } - /* Add trailing zeros (unless we got NaN or Inf) */ - if (pad && *decpt != 9999) { + /* Add trailing zeros */ + if (pad) { siz -= rve - s; while (--siz) *rve++ = '0'; -- cgit v1.2.3-55-g6feb