]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/platform-bionic.git/blobdiff - libc/upstream-openbsd/lib/libc/stdio/vfprintf.c
Fix nan output in the printf family.
[android-sdk/platform-bionic.git] / libc / upstream-openbsd / lib / libc / stdio / vfprintf.c
index b4f8f296ce40f66331ccaf1904946b12f52dfe32..5f4fb7fa9bb561d578a0618cbd526ba407b0a93f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: vfprintf.c,v 1.63 2013/03/02 19:40:08 guenther Exp $  */
+/*     $OpenBSD: vfprintf.c,v 1.67 2014/12/21 00:23:30 daniel Exp $    */
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
  * All rights reserved.
@@ -216,11 +216,10 @@ __wcsconv(wchar_t *wcsarg, int prec)
 #include <locale.h>
 #include <math.h>
 #include "floatio.h"
+#include "gdtoa.h"
 
 #define        DEFPREC         6
 
-extern char *__dtoa(double, int, int, int *, int *, char **);
-extern void  __freedtoa(char *);
 static int exponent(char *, int, int);
 #endif /* FLOATING_POINT */
 
@@ -399,7 +398,7 @@ __vfprintf(FILE *fp, const char *fmt0, __va_list ap)
            flags&PTRINT ? GETARG(ptrdiff_t) : \
            flags&SIZEINT ? GETARG(ssize_t) : \
            flags&SHORTINT ? (short)GETARG(int) : \
-           flags&CHARINT ? (__signed char)GETARG(int) : \
+           flags&CHARINT ? (signed char)GETARG(int) : \
            GETARG(int)))
 #define        UARG() \
        ((uintmax_t)(flags&MAXINT ? GETARG(uintmax_t) : \
@@ -754,10 +753,9 @@ fp_common:
                        if (signflag)
                                sign = '-';
                        if (expt == INT_MAX) {  /* inf or nan */
-                               if (*cp == 'N') {
+                               if (*cp == 'N')
                                        cp = (ch >= 'a') ? "nan" : "NAN";
-                                       sign = '\0';
-                               } else
+                               else
                                        cp = (ch >= 'a') ? "inf" : "INF";
                                size = 3;
                                flags &= ~ZEROPAD;
@@ -802,6 +800,7 @@ fp_common:
                        }
                        break;
 #endif /* FLOATING_POINT */
+#ifndef NO_PRINTF_PERCENT_N
                case 'n':
                        if (flags & LLONGINT)
                                *GETARG(long long *) = ret;
@@ -810,7 +809,7 @@ fp_common:
                        else if (flags & SHORTINT)
                                *GETARG(short *) = ret;
                        else if (flags & CHARINT)
-                               *GETARG(__signed char *) = ret;
+                               *GETARG(signed char *) = ret;
                        else if (flags & PTRINT)
                                *GETARG(ptrdiff_t *) = ret;
                        else if (flags & SIZEINT)
@@ -820,6 +819,7 @@ fp_common:
                        else
                                *GETARG(int *) = ret;
                        continue;       /* no output */
+#endif /* NO_PRINTF_PERCENT_N */
                case 'O':
                        flags |= LONGINT;
                        /*FALLTHROUGH*/
@@ -1318,6 +1318,7 @@ reswitch: switch (ch) {
                                ADDTYPE(T_DOUBLE);
                        break;
 #endif /* FLOATING_POINT */
+#ifndef NO_PRINTF_PERCENT_N
                case 'n':
                        if (flags & LLONGINT)
                                ADDTYPE(TP_LLONG);
@@ -1334,6 +1335,7 @@ reswitch: switch (ch) {
                        else
                                ADDTYPE(TP_INT);
                        continue;       /* no output */
+#endif /* NO_PRINTF_PERCENT_N */
                case 'O':
                        flags |= LONGINT;
                        /*FALLTHROUGH*/