Code

data: Format binary bytes as \xXX rather than \XX.
authorSebastian Harl <sh@tokkee.org>
Mon, 10 Feb 2014 18:10:52 +0000 (19:10 +0100)
committerSebastian Harl <sh@tokkee.org>
Mon, 10 Feb 2014 18:10:52 +0000 (19:10 +0100)
src/core/data.c
t/core/data_test.c

index 8f4330eabccf173a2ddca0b6721dab2594295f70..735639dcc450f2761dbf0179a70a27d7de784c81 100644 (file)
@@ -124,7 +124,8 @@ sdb_data_format(sdb_data_t *datum, sdb_strbuf_t *buf)
                                                '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
 
                                        tmp[pos] = '\\';
-                                       ++pos;
+                                       tmp[pos + 1] = 'x';
+                                       pos += 2;
 
                                        if (byte > 0xf) {
                                                tmp[pos] = hex[byte >> 4];
index fb3b1145bac8001458b95b598a348c92dc15ca20..e4ead2fe12711484bd5f5c4a42d46076e989c29f 100644 (file)
@@ -175,7 +175,8 @@ START_TEST(test_format)
        fail_unless(! check,
                        "sdb_data_format(BINARY) = %d; expected: 0", check);
        string = sdb_strbuf_string(buf);
-       expected = "\"\\62\\69\\6e\\61\\72\\79\\0\\63\\72\\61\\70\\42\"";
+       expected =
+               "\"\\x62\\x69\\x6e\\x61\\x72\\x79\\x0\\x63\\x72\\x61\\x70\\x42\"";
        fail_unless(! strcmp(string, expected),
                        "sdb_data_format() used wrong format: %s; expected: %s",
                        string, expected);