summaryrefslogtreecommitdiffstats
path: root/usr.bin/printf
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-06-19 09:42:20 +0000
committertjr <tjr@FreeBSD.org>2002-06-19 09:42:20 +0000
commitaff5678b6e0338a9e3059960ad3bf60e3d2bfa9e (patch)
tree4a625c317e25f38f703028c54340ea08482824d3 /usr.bin/printf
parent7aa1bb9d056544a059b4be0616b86179bc88e108 (diff)
downloadFreeBSD-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.c11
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
OpenPOWER on IntegriCloud