diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2013-02-14 16:19:34 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2013-05-07 09:41:09 +1000 |
commit | d903d17d7f006fa333265b8476063b189c20d082 (patch) | |
tree | 891b7ac5a62518d466aaa4626548b19d5941d7a0 | |
parent | 58ef34ee6d0f68aa28f6f1a26e56f49ec85ed9bf (diff) |
os: support %c in pnprintf
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
-rw-r--r-- | os/log.c | 7 | ||||
-rw-r--r-- | test/signal-logging.c | 5 |
2 files changed, 12 insertions, 0 deletions
@@ -450,6 +450,13 @@ pnprintf(char *string, size_t size, const char *f, va_list args) string[s_idx++] = number[i]; } break; + case 'c': + { + char c = va_arg(args, int); + if (s_idx < size - 1) + string[s_idx++] = c; + } + break; case '%': string[s_idx++] = '%'; break; diff --git a/test/signal-logging.c b/test/signal-logging.c index 65baa456f..b45d8d4f3 100644 --- a/test/signal-logging.c +++ b/test/signal-logging.c @@ -201,6 +201,11 @@ static void logging_format(void) read_log_msg(logmsg); assert(strcmp(logmsg, "(EE) test %\n") == 0); + /* character */ + LogMessageVerbSigSafe(X_ERROR, -1, "test %c\n", 'a'); + read_log_msg(logmsg); + assert(strcmp(logmsg, "(EE) test a\n") == 0); + /* string substitution */ LogMessageVerbSigSafe(X_ERROR, -1, "%s\n", "substituted string"); read_log_msg(logmsg); |