aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/printf/printf.c
diff options
context:
space:
mode:
authorPedro F. Giffuni <pfg@FreeBSD.org>2014-05-11 17:28:57 +0000
committerPedro F. Giffuni <pfg@FreeBSD.org>2014-05-11 17:28:57 +0000
commit30238f4963dbdd5884065eebe514cbd46e247af4 (patch)
treef79d334dae29315166b83e6a9b51e42e47801a6f /usr.bin/printf/printf.c
parent0d1381bb569d8b1d52217e9a92a8278dca1f4c15 (diff)
Notes
Diffstat (limited to 'usr.bin/printf/printf.c')
-rw-r--r--usr.bin/printf/printf.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c
index 055657fe057a..7a7e055ae4fe 100644
--- a/usr.bin/printf/printf.c
+++ b/usr.bin/printf/printf.c
@@ -101,6 +101,8 @@ static void usage(void);
static const char digits[] = "0123456789";
+static char end_fmt[1];
+
static int myargc;
static char **myargv;
static char **gargv;
@@ -171,11 +173,11 @@ main(int argc, char *argv[])
fmt += 2;
} else {
fmt = printf_doformat(fmt, &rval);
- if (fmt == NULL) {
+ if (fmt == NULL || fmt == end_fmt) {
#ifdef SHELL
INTON;
#endif
- return (1);
+ return (fmt == NULL ? 1 : rval);
}
end = 0;
}
@@ -372,7 +374,7 @@ printf_doformat(char *fmt, int *rval)
fputs(p, stdout);
free(p);
if (getout)
- exit(*rval);
+ return (end_fmt);
break;
}
case 'c': {