diff options
author | Joe Orton <joe@manyfish.uk> | 2020-12-06 15:35:17 +0000 |
---|---|---|
committer | Joe Orton <joe@manyfish.uk> | 2020-12-06 15:35:17 +0000 |
commit | d54b0b78a2d97c798e3171bfc7138c1928e6f5e3 (patch) | |
tree | 89228eec76eb9858b039074990674dd27e9074eb | |
parent | 18b17372a2eb873c9647f0f65f2ba1227139c5bb (diff) | |
download | neon-git-d54b0b78a2d97c798e3171bfc7138c1928e6f5e3.tar.gz |
* src/ne_string.c (hex_chars): Use lowercase.
(HEX2ASC): Avoid duplication, use hex_chars array.
* test/string-tests.c (qappend): Extend tests.
-rw-r--r-- | src/ne_string.c | 9 | ||||
-rw-r--r-- | test/string-tests.c | 1 |
2 files changed, 3 insertions, 7 deletions
diff --git a/src/ne_string.c b/src/ne_string.c index fd7883e..89b89ca 100644 --- a/src/ne_string.c +++ b/src/ne_string.c @@ -281,7 +281,7 @@ static const unsigned char ascii_quote[256] = { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }; -static const char hex_chars[16] = "0123456789ABCDEF"; +static const char hex_chars[16] = "0123456789abcdef"; /* Return the expected number of bytes needed to append the string * beginning at byte 's', where 'send' points to the last byte after @@ -656,12 +656,7 @@ char *ne_vstrhash(unsigned int flags, va_list ap) } #endif -static const char hexmap[16] = { - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' -}; - -#define HEX2ASC(a) (hexmap[((unsigned)(a)) & 0xf]) +#define HEX2ASC(a) (hex_chars[((unsigned char)(a)) & 0xf]) char *ne__strhash2hex(const unsigned char *digest, size_t len, unsigned int flags) diff --git a/test/string-tests.c b/test/string-tests.c index 294e581..a82f84f 100644 --- a/test/string-tests.c +++ b/test/string-tests.c @@ -622,6 +622,7 @@ static int qappend(void) { "b", 2, "b\\x00" }, { "alpha\0alpha", 11, "alpha\\x00alpha" }, { "a\tb", 3, "a\\x09b" }, + { "foo\x7f" "bar", 7, "foo\\x7fbar" }, { NULL } }; unsigned n; |