Commit 388ef3dd authored by Geoff Simmons's avatar Geoff Simmons

define a constant used by both url.c and hex.c

parent 92f12dfe
......@@ -46,12 +46,12 @@ const char hex_alphabet[][16] = {
* into 55 bytes (cacheline friendly).
*/
const uint8_t nibble[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 10, 11, 12,
13, 14, 15, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 10,
11, 12, 13, 14, 15
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
ILL, ILL, ILL, ILL, ILL, ILL, ILL, 10, 11, 12,
13, 14, 15, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, 10,
11, 12, 13, 14, 15
};
size_t
......
......@@ -28,6 +28,8 @@
#include <stdint.h>
#define ILL (0xff)
/* These are defined in hex.c */
extern const char hex_alphabet[][16];
......
......@@ -148,7 +148,7 @@ url_decode(const enum encoding dec, char *restrict const buf,
break;
case PERCENT:
if (isoutofrange(*s)
|| (nib = nibble[*s - '0']) == 0xff) {
|| (nib = nibble[*s - '0']) == ILL) {
errno = EINVAL;
return -1;
}
......@@ -160,7 +160,7 @@ url_decode(const enum encoding dec, char *restrict const buf,
return -1;
}
if (isoutofrange(*s)
|| (nib2 = nibble[*s - '0']) == 0xff) {
|| (nib2 = nibble[*s - '0']) == ILL) {
errno = EINVAL;
return -1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment