Module Name: src
Committed By: martin
Date: Sat Sep 1 06:28:23 UTC 2018
Modified Files:
src/usr.bin/printf [netbsd-8]: printf.c
Log Message:
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
To generate a diff of this commit:
cvs rdiff -u -r1.37.8.1 -r1.37.8.2 src/usr.bin/printf/printf.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/printf/printf.c
diff -u src/usr.bin/printf/printf.c:1.37.8.1 src/usr.bin/printf/printf.c:1.37.8.2
--- src/usr.bin/printf/printf.c:1.37.8.1 Fri Jul 13 15:58:25 2018
+++ src/usr.bin/printf/printf.c Sat Sep 1 06:28:23 2018
@@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
#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 char getchr(void);
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 @@ int main(int argc, char *argv[])
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 @@ getintmax(void)
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)
{