printf(1): warn about incomplete uses n$
Reviewed by: jilles Obtained from: Illumos MFC after: 2 weeks
This commit is contained in:
parent
eb0a187849
commit
4aa1792423
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=266690
@ -248,7 +248,7 @@ printf_doformat(char *fmt, int *rval)
|
||||
}
|
||||
|
||||
/* skip to field width */
|
||||
while (strchr(skip1, *fmt) != NULL) {
|
||||
while (*fmt && strchr(skip1, *fmt) != NULL) {
|
||||
*dptr++ = *fmt++;
|
||||
*dptr = 0;
|
||||
}
|
||||
@ -259,12 +259,19 @@ printf_doformat(char *fmt, int *rval)
|
||||
l = strspn(fmt, digits);
|
||||
if ((l > 0) && (fmt[l] == '$')) {
|
||||
int idx = atoi(fmt);
|
||||
if (fargv == NULL) {
|
||||
warnx("incomplete use of n$");
|
||||
return (NULL);
|
||||
}
|
||||
if (idx <= myargc) {
|
||||
gargv = &myargv[idx - 1];
|
||||
} else {
|
||||
gargv = &myargv[myargc];
|
||||
}
|
||||
fmt += l + 1;
|
||||
} else if (fargv != NULL) {
|
||||
warnx("incomplete use of n$");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (getint(&fieldwidth))
|
||||
@ -296,12 +303,19 @@ printf_doformat(char *fmt, int *rval)
|
||||
l = strspn(fmt, digits);
|
||||
if ((l > 0) && (fmt[l] == '$')) {
|
||||
int idx = atoi(fmt);
|
||||
if (fargv == NULL) {
|
||||
warnx("incomplete use of n$");
|
||||
return (NULL);
|
||||
}
|
||||
if (idx <= myargc) {
|
||||
gargv = &myargv[idx - 1];
|
||||
} else {
|
||||
gargv = &myargv[myargc];
|
||||
}
|
||||
fmt += l + 1;
|
||||
} else if (fargv != NULL) {
|
||||
warnx("incomplete use of n$");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (getint(&precision))
|
||||
|
Loading…
Reference in New Issue
Block a user