os: support %% in pnprintf
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
5ea21560dd
commit
58ef34ee6d
3
os/log.c
3
os/log.c
|
@ -450,6 +450,9 @@ pnprintf(char *string, size_t size, const char *f, va_list args)
|
||||||
string[s_idx++] = number[i];
|
string[s_idx++] = number[i];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case '%':
|
||||||
|
string[s_idx++] = '%';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
va_arg(args, char*);
|
va_arg(args, char*);
|
||||||
string[s_idx++] = '%';
|
string[s_idx++] = '%';
|
||||||
|
|
|
@ -196,6 +196,11 @@ static void logging_format(void)
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, "(EE) %s %d %u %% %p %i\n") == 0);
|
assert(strcmp(logmsg, "(EE) %s %d %u %% %p %i\n") == 0);
|
||||||
|
|
||||||
|
/* literal % */
|
||||||
|
LogMessageVerbSigSafe(X_ERROR, -1, "test %%\n");
|
||||||
|
read_log_msg(logmsg);
|
||||||
|
assert(strcmp(logmsg, "(EE) test %\n") == 0);
|
||||||
|
|
||||||
/* string substitution */
|
/* string substitution */
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%s\n", "substituted string");
|
LogMessageVerbSigSafe(X_ERROR, -1, "%s\n", "substituted string");
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
|
|
Loading…
Reference in New Issue