Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src/usr.bin/printf Pull up following revision(s) (requested b...



details:   https://anonhg.NetBSD.org/src/rev/9cad6819e187
branches:  netbsd-8
changeset: 851968:9cad6819e187
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Sep 01 06:28:23 2018 +0000

description:
Pull up following revision(s) (requested by kre in ticket #1002):

        usr.bin/printf/printf.1: revision 1.31 (via patch)
        usr.bin/printf/printf.c: revision 1.43

PR standards/53563

POSIX requires that signed numbers (strings preceded by '+' or '-')
be allowed as inputs to all of the integer format conversions, including
those which treat the data as unsigned.

Hence we do not need a variant function whose only difference from its
companion is to reject strings starting with '-' - instead we use
the primary function (getintmax()) for everything and remove getuintmax().

Minor update to the man page to indicate that the arg to all of the
integer conversions (diouxX) must be an integer constant (with an
optional sign) and to make it blatantly clear that %o is octal and
%u is unsigned decimal (for some reason those weren't explicitly stated
unlike d i x and X).  Delete "respectively", it is not needed (and does
not really apply).

XXX pullup -8

diffstat:

 usr.bin/printf/printf.c |  36 +++---------------------------------
 1 files changed, 3 insertions(+), 33 deletions(-)

diffs (71 lines):

diff -r b43425a8b8fc -r 9cad6819e187 usr.bin/printf/printf.c
--- a/usr.bin/printf/printf.c   Sat Sep 01 06:27:12 2018 +0000
+++ b/usr.bin/printf/printf.c   Sat Sep 01 06:28:23 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: printf.c,v 1.37.8.1 2018/07/13 15:58:25 martin Exp $   */
+/*     $NetBSD: printf.c,v 1.37.8.2 2018/09/01 06:28:23 martin Exp $   */
 
 /*
  * Copyright (c) 1989, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)printf.c   8.2 (Berkeley) 3/22/95";
 #else
-__RCSID("$NetBSD: printf.c,v 1.37.8.1 2018/07/13 15:58:25 martin Exp $");
+__RCSID("$NetBSD: printf.c,v 1.37.8.2 2018/09/01 06:28:23 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -72,7 +72,6 @@
 static double   getdouble(void);
 static int      getwidth(void);
 static intmax_t         getintmax(void);
-static uintmax_t getuintmax(void);
 static char    *getstr(void);
 static char    *mklong(const char *, char);
 static void      check_conversion(const char *, const char *);
@@ -286,7 +285,7 @@
                        case 'u':
                        case 'x':
                        case 'X': {
-                               uintmax_t p = getuintmax();
+                               uintmax_t p = (uintmax_t)getintmax();
                                char *f = mklong(start, ch);
                                PF(f, p);
                                if (error < 0)
@@ -633,35 +632,6 @@
        return val;
 }
 
-static uintmax_t
-getuintmax(void)
-{
-       uintmax_t val;
-       char *cp, *ep;
-
-       cp = *gargv;
-       if (cp == NULL)
-               return 0;
-       gargv++;
-
-       if (*cp == '\"' || *cp == '\'')
-               return (uintmax_t)*(cp + 1);
-
-       /* strtoumax won't error -ve values */
-       while (isspace(*(unsigned char *)cp))
-               cp++;
-       if (*cp == '-') {
-               warnx("%s: expected positive numeric value", cp);
-               rval = 1;
-               return 0;
-       }
-
-       errno = 0;
-       val = strtoumax(cp, &ep, 0);
-       check_conversion(cp, ep);
-       return val;
-}
-
 static double
 getdouble(void)
 {



Home | Main Index | Thread Index | Old Index