aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Barnes <craigbarnes@protonmail.com>2021-01-04 05:31:19 +0000
committerCraig Barnes <craigbarnes@protonmail.com>2021-01-04 05:31:19 +0000
commitb9a7cbf21daf00b21b2e2b516286761a39a9781b (patch)
tree8b5d34b91b45b26bfe5c288787c1b1f57be04f89
parenturi: use nibble2hex() instead of isxdigit(3) to check valid hex digits (diff)
uri: rename nibbletohex() function to hex2nibble()
It converts a hex digit to a nibble, not the other way around.
-rw-r--r--uri.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/uri.c b/uri.c
index 57852f1b..a0e3838a 100644
--- a/uri.c
+++ b/uri.c
@@ -16,7 +16,7 @@ enum {
};
static uint8_t
-nibble2hex(char c)
+hex2nibble(char c)
{
switch (c) {
case '0': case '1': case '2': case '3': case '4':
@@ -201,8 +201,8 @@ uri_parse(const char *uri, size_t len,
encoded_len -= prefix_len;
decoded_len += prefix_len;
- if (nibble2hex(next[1]) <= 15 && nibble2hex(next[2]) <= 15) {
- *p++ = nibble2hex(next[1]) << 4 | nibble2hex(next[2]);
+ if (hex2nibble(next[1]) <= 15 && hex2nibble(next[2]) <= 15) {
+ *p++ = hex2nibble(next[1]) << 4 | hex2nibble(next[2]);
decoded_len++;
encoded_len -= 3;
encoded = next + 3;