[PATCH 3/4] os: support %c in pnprintf
Peter Hutterer
peter.hutterer at who-t.net
Sun Apr 14 21:01:59 PDT 2013
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
os/log.c | 7 +++++++
test/signal-logging.c | 5 +++++
2 files changed, 12 insertions(+)
diff --git a/os/log.c b/os/log.c
index 4f30782..074c69c 100644
--- a/os/log.c
+++ b/os/log.c
@@ -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 65baa45..b45d8d4 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);
--
1.8.1.4
More information about the xorg-devel
mailing list