diff options
author | 2006-01-10 16:18:37 +0000 | |
---|---|---|
committer | 2006-01-10 16:18:37 +0000 | |
commit | 3a59a6c96182ff79ee1922910eb653501cf17bd7 (patch) | |
tree | 2fb4d53f4201c76cebf8006b5a5c210812fce4f4 /lib/libc/stdlib/gcvt.c | |
parent | The attributes cache broke the set community filterset because community_set() (diff) | |
download | wireguard-openbsd-3a59a6c96182ff79ee1922910eb653501cf17bd7.tar.xz wireguard-openbsd-3a59a6c96182ff79ee1922910eb653501cf17bd7.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 'lib/libc/stdlib/gcvt.c')
-rw-r--r-- | lib/libc/stdlib/gcvt.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/libc/stdlib/gcvt.c b/lib/libc/stdlib/gcvt.c index 9ba932e1237..bc6295c03de 100644 --- a/lib/libc/stdlib/gcvt.c +++ b/lib/libc/stdlib/gcvt.c @@ -1,7 +1,7 @@ -/* $OpenBSD: gcvt.c,v 1.8 2006/01/10 02:23:02 millert Exp $ */ +/* $OpenBSD: gcvt.c,v 1.9 2006/01/10 16:18:37 millert Exp $ */ /* - * Copyright (c) 2002, 2003 Todd C. Miller <Todd.Miller@courtesan.com> + * Copyright (c) 2002, 2003, 2006 Todd C. Miller <Todd.Miller@courtesan.com> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -42,8 +42,12 @@ gcvt(double value, int ndigit, char *buf) digits = __dtoa(value, 2, ndigit, &decpt, &sign, NULL); if (decpt == 9999) { - /* Infinity or NaN, assume buffer is at least ndigit long. */ - snprintf(buf, ndigit + 1, "%s%s", sign ? "-" : "", digits); + /* + * Infinity or NaN, convert to inf or nan with sign. + * We assume the buffer is at least ndigit long. + */ + snprintf(buf, ndigit + 1, "%s%s", sign ? "-" : "", + *digits == 'I' ? "inf" : "nan"); return (buf); } |