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
This commit is contained in:
parent
d6bd5ec90c
commit
0ba01198fc
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=144902
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user