diff options
| author | millert <> | 2006-01-10 16:18:37 +0000 |
|---|---|---|
| committer | millert <> | 2006-01-10 16:18:37 +0000 |
| commit | 1e745892f72a6490f4783b86b64e88e0c5c4bf61 (patch) | |
| tree | 2ff2ecfba3f6646d719c4e3739c448131fbf9204 /src/lib/libc/stdlib/ecvt.c | |
| parent | 1fdb8b1f0e4af24cd5666eb62466dd2c91fe0353 (diff) | |
| download | openbsd-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/ecvt.c')
| -rw-r--r-- | src/lib/libc/stdlib/ecvt.c | 14 |
1 files changed, 7 insertions, 7 deletions
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 @@ | |||
| 1 | /* $OpenBSD: ecvt.c,v 1.4 2005/08/08 08:05:36 espie Exp $ */ | 1 | /* $OpenBSD: ecvt.c,v 1.5 2006/01/10 16:18:37 millert Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com> | 4 | * Copyright (c) 2002, 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 |
| @@ -62,11 +62,11 @@ __cvt(double value, int ndigit, int *decpt, int *sign, int fmode, int pad) | |||
| 62 | } else { | 62 | } else { |
| 63 | p = __dtoa(value, fmode + 2, ndigit, decpt, sign, &rve); | 63 | p = __dtoa(value, fmode + 2, ndigit, decpt, sign, &rve); |
| 64 | if (*decpt == 9999) { | 64 | if (*decpt == 9999) { |
| 65 | /* Nan or Infinity */ | 65 | /* Infinity or Nan, convert to inf or nan like printf */ |
| 66 | *decpt = 0; | 66 | *decpt = 0; |
| 67 | return(p); | 67 | return(*p == 'I' ? "inf" : "nan"); |
| 68 | } | 68 | } |
| 69 | /* make a local copy and adjust rve to be in terms of s */ | 69 | /* Make a local copy and adjust rve to be in terms of s */ |
| 70 | if (pad && fmode) | 70 | if (pad && fmode) |
| 71 | siz += *decpt; | 71 | siz += *decpt; |
| 72 | if ((s = (char *)malloc(siz)) == NULL) | 72 | if ((s = (char *)malloc(siz)) == NULL) |
| @@ -75,8 +75,8 @@ __cvt(double value, int ndigit, int *decpt, int *sign, int fmode, int pad) | |||
| 75 | rve = s + (rve - p); | 75 | rve = s + (rve - p); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | /* Add trailing zeros (unless we got NaN or Inf) */ | 78 | /* Add trailing zeros */ |
| 79 | if (pad && *decpt != 9999) { | 79 | if (pad) { |
| 80 | siz -= rve - s; | 80 | siz -= rve - s; |
| 81 | while (--siz) | 81 | while (--siz) |
| 82 | *rve++ = '0'; | 82 | *rve++ = '0'; |
