aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/printf/printf.c
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2012-09-15 21:56:30 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2012-09-15 21:56:30 +0000
commit7cbda73825918d63360a7d815ff59341d1800d1a (patch)
tree8f1502baabb3376aec513c46c8781c9f452a7b3d /usr.bin/printf/printf.c
parentc99c0499e099a4c8225bba85447a145b2b08a9a2 (diff)
Notes
Diffstat (limited to 'usr.bin/printf/printf.c')
-rw-r--r--usr.bin/printf/printf.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c
index 89149dcda019..4b0934290bcc 100644
--- a/usr.bin/printf/printf.c
+++ b/usr.bin/printf/printf.c
@@ -64,6 +64,7 @@ static const char rcsid[] =
#define main printfcmd
#include "bltin/bltin.h"
#include "error.h"
+#include "options.h"
#endif
#define PF(f, func) do { \
@@ -101,15 +102,19 @@ int
main(int argc, char *argv[])
{
size_t len;
- int ch, chopped, end, rval;
+ int chopped, end, rval;
char *format, *fmt, *start;
-
#ifndef SHELL
+ int ch;
+
(void) setlocale(LC_ALL, "");
#endif
+
#ifdef SHELL
- optreset = 1; optind = 1; opterr = 0; /* initialize getopt */
-#endif
+ nextopt("");
+ argc -= argptr - argv;
+ argv = argptr;
+#else
while ((ch = getopt(argc, argv, "")) != -1)
switch (ch) {
case '?':
@@ -119,6 +124,7 @@ main(int argc, char *argv[])
}
argc -= optind;
argv += optind;
+#endif
if (argc < 1) {
usage();