summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/gcvt.c
diff options
context:
space:
mode:
authormillert <>2006-01-10 16:18:37 +0000
committermillert <>2006-01-10 16:18:37 +0000
commit1e745892f72a6490f4783b86b64e88e0c5c4bf61 (patch)
tree2ff2ecfba3f6646d719c4e3739c448131fbf9204 /src/lib/libc/stdlib/gcvt.c
parent1fdb8b1f0e4af24cd5666eb62466dd2c91fe0353 (diff)
downloadopenbsd-1e745892f72a6490f4783b86b64e88e0c5c4bf61.tar.gz
openbsd-1e745892f72a6490f4783b86b64e88e0c5c4bf61.tar.bz2
openbsd-1e745892f72a6490f4783b86b64e88e0c5c4bf61.zip
Return inf or nan as per printf() not Inf, Infinity or Nan (from dtoa)
Remove an extraneous check for dtoa returning Inf/Nan
Diffstat (limited to 'src/lib/libc/stdlib/gcvt.c')
-rw-r--r--src/lib/libc/stdlib/gcvt.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lib/libc/stdlib/gcvt.c b/src/lib/libc/stdlib/gcvt.c
index 9ba932e123..bc6295c03d 100644
--- a/src/lib/libc/stdlib/gcvt.c
+++ b/src/lib/libc/stdlib/gcvt.c
@@ -1,7 +1,7 @@
1/* $OpenBSD: gcvt.c,v 1.8 2006/01/10 02:23:02 millert Exp $ */ 1/* $OpenBSD: gcvt.c,v 1.9 2006/01/10 16:18:37 millert Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2002, 2003 Todd C. Miller <Todd.Miller@courtesan.com> 4 * Copyright (c) 2002, 2003, 2006 Todd C. Miller <Todd.Miller@courtesan.com>
5 * 5 *
6 * Permission to use, copy, modify, and distribute this software for any 6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above 7 * purpose with or without fee is hereby granted, provided that the above
@@ -42,8 +42,12 @@ gcvt(double value, int ndigit, char *buf)
42 42
43 digits = __dtoa(value, 2, ndigit, &decpt, &sign, NULL); 43 digits = __dtoa(value, 2, ndigit, &decpt, &sign, NULL);
44 if (decpt == 9999) { 44 if (decpt == 9999) {
45 /* Infinity or NaN, assume buffer is at least ndigit long. */ 45 /*
46 snprintf(buf, ndigit + 1, "%s%s", sign ? "-" : "", digits); 46 * Infinity or NaN, convert to inf or nan with sign.
47 * We assume the buffer is at least ndigit long.
48 */
49 snprintf(buf, ndigit + 1, "%s%s", sign ? "-" : "",
50 *digits == 'I' ? "inf" : "nan");
47 return (buf); 51 return (buf);
48 } 52 }
49 53