Add a warning when a single % is at the end of the format string

This commit is contained in:
Cary R 2021-01-25 21:48:00 -08:00
parent 7e40f5ac52
commit f8e82448be
1 changed files with 4 additions and 1 deletions

View File

@ -312,8 +312,11 @@ static unsigned int get_format_char(char **rtn, int ljust, int plus,
size = strlen(result) + 1; /* fallback value if errors */
switch (fmt) {
case '%':
case '\0':
vpi_printf("WARNING: %s:%d: a single %% at the end of format string "
"%s%s will be displayed as '%%'.\n",
info->filename, info->lineno, info->name, fmtb);
case '%':
if (ljust != 0 || plus != 0 || ld_zero != 0 || width != -1 ||
prec != -1) {
vpi_printf("WARNING: %s:%d: invalid format %s%s.\n",