diff options
| author | kre <kre@NetBSD.org> | 2019-07-21 15:25:39 +0000 |
|---|---|---|
| committer | kre <kre@NetBSD.org> | 2019-07-21 15:25:39 +0000 |
| commit | f7137fdf8a6a3cfa4fd08b92c56ccb1ec9b3eefe (patch) | |
| tree | 52f022cdb9914af49560b267dda583e94a341982 /usr.bin/printf | |
| parent | 3f78675053eb613d2fb259c55ef7b0343c2f34b7 (diff) | |
Stop assuming that printf handles options in any way at all
(it doesn't - that is, shouldn't) which includes processing -- as an
"end of options". The first arg is (always) the format string.
Remove call to getopt() (but still do associated changes to argc/argv)
Note: for now this is #if 0's out instead of being deleted, the old
code should be fully removed sometime soon.
Problem pointed out on tech-userlevel by Thierry Laronde.
Diffstat (limited to 'usr.bin/printf')
| -rw-r--r-- | usr.bin/printf/printf.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c index 4d88e7d30fc..72a0d8af92c 100644 --- a/usr.bin/printf/printf.c +++ b/usr.bin/printf/printf.c @@ -1,4 +1,4 @@ -/* $NetBSD: printf.c,v 1.48 2019/01/27 12:03:09 kre Exp $ */ +/* $NetBSD: printf.c,v 1.49 2019/07/21 15:25:39 kre Exp $ */ /* * Copyright (c) 1989, 1993 @@ -41,7 +41,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\ #if 0 static char sccsid[] = "@(#)printf.c 8.2 (Berkeley) 3/22/95"; #else -__RCSID("$NetBSD: printf.c,v 1.48 2019/01/27 12:03:09 kre Exp $"); +__RCSID("$NetBSD: printf.c,v 1.49 2019/07/21 15:25:39 kre Exp $"); #endif #endif /* not lint */ @@ -130,7 +130,7 @@ main(int argc, char *argv[]) char nextch; char *format; char ch; - int error, o; + int error; #if !defined(SHELL) && !defined(BUILTIN) (void)setlocale (LC_ALL, ""); @@ -138,6 +138,13 @@ main(int argc, char *argv[]) rval = 0; /* clear for builtin versions (avoid holdover) */ +#if 0 + int o; + + /* + * printf does not comply with Posix XBD 12.2 - there are no opts, + * not even the -- end of options marker. Do not run getoot(). + */ while ((o = getopt(argc, argv, "")) != -1) { switch (o) { case '?': @@ -148,6 +155,10 @@ main(int argc, char *argv[]) } argc -= optind; argv += optind; +#else + argc -= 1; + argv += 1; +#endif if (argc < 1) { usage(); |
