}
/**
- * Check printf-style format.
+ * Check printf-style format. Returns number of expected arguments.
*/
static int internal_check_printf_format(const expression_t *fmt_expr,
const call_argument_t *arg,
const char *c = string;
const source_position_t *pos = &fmt_expr->base.source_position;
- unsigned num_fmt = 0;
+ unsigned num_fmt = 0;
+ unsigned num_args = 0;
char fmt;
for (fmt = *c; fmt != '\0'; fmt = *(++c)) {
if (fmt != '%')
continue;
++num_fmt;
+ ++num_args;
format_flags_t fmt_flags = FMT_FLAG_NONE;
if (fmt == '0') {
/* minimum field width */
if (fmt == '*') {
+ ++num_args;
fmt = *(++c);
if (arg == NULL) {
warningf(pos, "missing argument for '*' field width in conversion specification %u", num_fmt);
/* precision */
if (fmt == '.') {
+ ++num_args;
fmt = *(++c);
if (fmt == '*') {
fmt = *(++c);
if (c+1 < string + size) {
warningf(pos, "format string contains '\\0'");
}
- return num_fmt;
+ return num_args;
}
/**