summaryrefslogtreecommitdiffstats
path: root/usr.bin/printf
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2005-04-11 10:57:54 +0000
committerstefanf <stefanf@FreeBSD.org>2005-04-11 10:57:54 +0000
commitaed8bcfc2b5d64c8beec781cdd789d9b41450170 (patch)
tree10060c42754b06996866508ec7c11e3cae1ace95 /usr.bin/printf
parentce0cfd9c63389ae4c2fcbaa8afbbe5e60d543849 (diff)
downloadFreeBSD-src-aed8bcfc2b5d64c8beec781cdd789d9b41450170.zip
FreeBSD-src-aed8bcfc2b5d64c8beec781cdd789d9b41450170.tar.gz
Replace buggy for-loops to skip certain character with strspn(). If *fmt was
'\0' (eg in the invocation 'printf %'), the for-loop would miss the terminating null character. MFC after: 1 week
Diffstat (limited to 'usr.bin/printf')
-rw-r--r--usr.bin/printf/printf.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c
index 64206a4..64aa07a 100644
--- a/usr.bin/printf/printf.c
+++ b/usr.bin/printf/printf.c
@@ -179,7 +179,7 @@ next: for (start = fmt;; ++fmt) {
}
/* skip to field width */
- for (; strchr(skip1, *fmt); ++fmt);
+ fmt += strspn(fmt, skip1);
if (*fmt == '*') {
if (getint(&fieldwidth))
return (1);
@@ -189,7 +189,7 @@ next: for (start = fmt;; ++fmt) {
havewidth = 0;
/* skip to possible '.', get following precision */
- for (; strchr(skip2, *fmt); ++fmt);
+ fmt += strspn(fmt, skip2);
}
if (*fmt == '.') {
/* precision present? */
@@ -203,7 +203,7 @@ next: for (start = fmt;; ++fmt) {
haveprec = 0;
/* skip to conversion char */
- for (; strchr(skip2, *fmt); ++fmt);
+ fmt += strspn(fmt, skip2);
}
} else
haveprec = 0;
OpenPOWER on IntegriCloud