From 37fd459046a5f2eb572387c5bf3780520feef6a2 Mon Sep 17 00:00:00 2001 From: "Tim J. Robbins" Date: Wed, 19 Jun 2002 08:16:14 +0000 Subject: [PATCH] Allow `%' to be written out with an octal escape (\45 or \045). PR: 39116 Submitted by: Egil Brendsdal MFC after: 1 week --- usr.bin/printf/printf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c index e0d1591b50c..90f363cbc8a 100644 --- a/usr.bin/printf/printf.c +++ b/usr.bin/printf/printf.c @@ -376,7 +376,11 @@ escape(fmt) value += *fmt - '0'; } --fmt; - *store = value; + if (value == '%') { + *store++ = '%'; + *store = '%'; + } else + *store = value; break; default: *store = *fmt;