diff options
author | tjr <tjr@FreeBSD.org> | 2002-06-19 09:42:20 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-06-19 09:42:20 +0000 |
commit | aff5678b6e0338a9e3059960ad3bf60e3d2bfa9e (patch) | |
tree | 4a625c317e25f38f703028c54340ea08482824d3 /usr.bin/printf | |
parent | 7aa1bb9d056544a059b4be0616b86179bc88e108 (diff) | |
download | FreeBSD-src-aff5678b6e0338a9e3059960ad3bf60e3d2bfa9e.zip FreeBSD-src-aff5678b6e0338a9e3059960ad3bf60e3d2bfa9e.tar.gz |
Fix duplicate % in %b format introduced in rev 1.22.
Diffstat (limited to 'usr.bin/printf')
-rw-r--r-- | usr.bin/printf/printf.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c index 2887921..a63d6cd 100644 --- a/usr.bin/printf/printf.c +++ b/usr.bin/printf/printf.c @@ -89,7 +89,7 @@ static const char rcsid[] = } while (0) static int asciicode(void); -static int escape(char *); +static int escape(char *, int); static int getchr(void); static int getdouble(double *); static int getint(int *); @@ -143,7 +143,7 @@ main(argc, argv) skip1 = "#-+ 0"; skip2 = "0123456789"; - chopped = escape(fmt = format = *argv); /* backslash interpretation */ + chopped = escape(fmt = format = *argv, 1);/* backslash interpretation */ rval = 0; gargv = ++argv; for (;;) { @@ -230,7 +230,7 @@ next: for (start = fmt;; ++fmt) { warnx2("%s", strerror(ENOMEM), NULL); return (1); } - getout = escape(p); + getout = escape(p, 0); *(fmt - 1) = 's'; PF(start, p); *(fmt - 1) = 'b'; @@ -325,8 +325,9 @@ mkquad(str, ch) } static int -escape(fmt) +escape(fmt, percent) register char *fmt; + int percent; { register char *store; register int value, c; @@ -378,7 +379,7 @@ escape(fmt) value += *fmt - '0'; } --fmt; - if (value == '%') { + if (percent && value == '%') { *store++ = '%'; *store = '%'; } else |