From: Sebastian Harl Date: Mon, 10 Feb 2014 18:10:52 +0000 (+0100) Subject: data: Format binary bytes as \xXX rather than \XX. X-Git-Tag: sysdb-0.1.0~212 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ba1b44ead51bba4204c1edaadb59a9ce30d1de27;p=sysdb.git data: Format binary bytes as \xXX rather than \XX. --- diff --git a/src/core/data.c b/src/core/data.c index 8f4330e..735639d 100644 --- a/src/core/data.c +++ b/src/core/data.c @@ -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]; diff --git a/t/core/data_test.c b/t/core/data_test.c index fb3b114..e4ead2f 100644 --- a/t/core/data_test.c +++ b/t/core/data_test.c @@ -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);