[PATCH 2/4] os: support %% in pnprintf

Peter Hutterer peter.hutterer at who-t.net
Sun Apr 14 21:01:58 PDT 2013


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 os/log.c              | 3 +++
 test/signal-logging.c | 5 +++++
 2 files changed, 8 insertions(+)

diff --git a/os/log.c b/os/log.c
index c582aaa..4f30782 100644
--- a/os/log.c
+++ b/os/log.c
@@ -450,6 +450,9 @@ pnprintf(char *string, size_t size, const char *f, va_list args)
                     string[s_idx++] = number[i];
             }
             break;
+        case '%':
+            string[s_idx++] = '%';
+            break;
         default:
             va_arg(args, char*);
             string[s_idx++] = '%';
diff --git a/test/signal-logging.c b/test/signal-logging.c
index 9038cf8..65baa45 100644
--- a/test/signal-logging.c
+++ b/test/signal-logging.c
@@ -196,6 +196,11 @@ static void logging_format(void)
     read_log_msg(logmsg);
     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 */
     LogMessageVerbSigSafe(X_ERROR, -1, "%s\n", "substituted string");
     read_log_msg(logmsg);
-- 
1.8.1.4



More information about the xorg-devel mailing list