diff options
| author | Tim J. Robbins <tjr@FreeBSD.org> | 2002-06-19 09:42:20 +0000 |
|---|---|---|
| committer | Tim J. Robbins <tjr@FreeBSD.org> | 2002-06-19 09:42:20 +0000 |
| commit | 12e8db40674cd94dd7e9e7a4b680c6b2f0c6e3fe (patch) | |
| tree | 4a625c317e25f38f703028c54340ea08482824d3 /usr.bin/printf | |
| parent | a37313d23426c47e1813239ae8963bb2024ed621 (diff) | |
Notes
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 288792137fc06..a63d6cd21efeb 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 |
