Browse Source

teach gdtoa & its subroutines that malloc can fail; in which case

ecvt, fcvt, gcvt, *printf, strtof, strtod, strtold act per ieee
1003.1.  after these massive changes, remove unused files which
would not work now.  reported by Maksymilian Arciemowicz;  ok theo
OPENBSD_4_7
martynas 15 years ago
parent
commit
f30cf48cfa
2 changed files with 6 additions and 2 deletions
  1. +3
    -1
      src/lib/libc/stdlib/ecvt.c
  2. +3
    -1
      src/lib/libc/stdlib/gcvt.c

+ 3
- 1
src/lib/libc/stdlib/ecvt.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: ecvt.c,v 1.6 2006/10/29 18:45:56 deraadt Exp $ */
/* $OpenBSD: ecvt.c,v 1.7 2009/10/16 12:15:03 martynas Exp $ */
/* /*
* Copyright (c) 2002, 2006 Todd C. Miller <Todd.Miller@courtesan.com> * Copyright (c) 2002, 2006 Todd C. Miller <Todd.Miller@courtesan.com>
@ -62,6 +62,8 @@ __cvt(double value, int ndigit, int *decpt, int *sign, int fmode, int pad)
*rve = '\0'; *rve = '\0';
} else { } else {
p = __dtoa(value, fmode + 2, ndigit, decpt, sign, &rve); p = __dtoa(value, fmode + 2, ndigit, decpt, sign, &rve);
if (p == NULL)
return (NULL);
if (*decpt == 9999) { if (*decpt == 9999) {
/* Infinity or Nan, convert to inf or nan like printf */ /* Infinity or Nan, convert to inf or nan like printf */
*decpt = 0; *decpt = 0;


+ 3
- 1
src/lib/libc/stdlib/gcvt.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: gcvt.c,v 1.10 2006/10/29 18:45:56 deraadt Exp $ */
/* $OpenBSD: gcvt.c,v 1.11 2009/10/16 12:15:03 martynas Exp $ */
/* /*
* Copyright (c) 2002, 2003, 2006 Todd C. Miller <Todd.Miller@courtesan.com> * Copyright (c) 2002, 2003, 2006 Todd C. Miller <Todd.Miller@courtesan.com>
@ -42,6 +42,8 @@ gcvt(double value, int ndigit, char *buf)
} }
digits = __dtoa(value, 2, ndigit, &decpt, &sign, NULL); digits = __dtoa(value, 2, ndigit, &decpt, &sign, NULL);
if (digits == NULL)
return (NULL);
if (decpt == 9999) { if (decpt == 9999) {
/* /*
* Infinity or NaN, convert to inf or nan with sign. * Infinity or NaN, convert to inf or nan with sign.


Loading…
Cancel
Save