diff options
author | dds <dds@FreeBSD.org> | 2006-12-03 17:05:04 +0000 |
---|---|---|
committer | dds <dds@FreeBSD.org> | 2006-12-03 17:05:04 +0000 |
commit | 552b6c0ead97cdc98a42d8140db41253cd9bd97a (patch) | |
tree | 57cf956bbcefedbc658665723842ca2c43b105e0 /usr.bin/jot | |
parent | 86ce72fe0a64493ae3be04a15b9878da79a809c0 (diff) | |
download | FreeBSD-src-552b6c0ead97cdc98a42d8140db41253cd9bd97a.zip FreeBSD-src-552b6c0ead97cdc98a42d8140db41253cd9bd97a.tar.gz |
Correct handling of format strings with escaped % specifications.
Note: It would be nice to be able to implement getformat() using
fmtcheck(3), but fmtcheck does not distinguish between signed and
unsigned types, a facility jot needs to perform range checks on its
output.
Submitted by: Per Kristian Hove
MFC after: 2 weeks
Diffstat (limited to 'usr.bin/jot')
-rw-r--r-- | usr.bin/jot/jot.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/jot/jot.c b/usr.bin/jot/jot.c index c1c2de4..34ec76b 100644 --- a/usr.bin/jot/jot.c +++ b/usr.bin/jot/jot.c @@ -393,8 +393,11 @@ getformat(void) if (boring) /* no need to bother */ return; for (p = format; *p; p++) /* look for '%' */ - if (*p == '%' && *(p+1) != '%') /* leave %% alone */ - break; + if (*p == '%') + if (p[1] == '%') + p++; /* leave %% alone */ + else + break; sz = sizeof(format) - strlen(format) - 1; if (!*p && !chardata) { if (snprintf(p, sz, "%%.%df", prec) >= (int)sz) |