commit 5c67b788294e865cdcf9bbff113681e3112ef909
parent 56ed2afcad86cf6b4eee7c1369519583245bb652
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date: Sun, 27 Apr 2025 15:23:06 +0200
mhd_str: renamed functions for clarity + fixed FTBFS for compact code
Diffstat:
| M | src/mhd2/mhd_str.c | | | 66 | +++++++++++++++++++++++++++++++++--------------------------------- |
1 file changed, 33 insertions(+), 33 deletions(-)
diff --git a/src/mhd2/mhd_str.c b/src/mhd2/mhd_str.c
@@ -207,7 +207,7 @@ todigitvalue (char c)
* @return value of hexadecimal digit or -1 if @ c is not hexadecimal digit
*/
MHD_static_inline_ int
-toxdigitvalue (char c)
+xdigittovalue (char c)
{
#if ! defined(MHD_FAVOR_SMALL_CODE)
switch ((unsigned char) c)
@@ -539,7 +539,7 @@ toxdigitvalue (char c)
* @return hexadecimal digit
*/
MHD_static_inline_ char
-xdigittovalue (unsigned int v)
+valuetoxdigit (unsigned int v)
{
#if ! defined(MHD_FAVOR_SMALL_CODE)
static const char map_value_to_xdigit[16] =
@@ -553,9 +553,9 @@ xdigittovalue (unsigned int v)
mhd_assert (16 > v);
- if (xdigit <= 9)
- return '0' + (char) (xdigit);
- return 'A' + (char) (xdigit - 10);
+ if (v <= 9)
+ return '0' + (char) (v);
+ return 'A' + (char) (v - 10);
#endif /* MHD_FAVOR_SMALL_CODE */
}
@@ -683,7 +683,7 @@ charsequalcaseless (const char c1, const char c2)
* @param c character to convert
* @return value of hexadecimal digit or -1 if @ c is not hexadecimal digit
*/
-# define toxdigitvalue(c) (isasciidigit (c) ? (int) (((char) (c)) - '0') : \
+# define xdigittovalue(c) (isasciidigit (c) ? (int) (((char) (c)) - '0') : \
( (((char) (c)) >= 'A' && ((char) (c)) <= 'F') ? \
(int) (((unsigned char) (c)) - 'A' + 10) : \
( (((char) (c)) >= 'a' && ((char) (c)) <= 'f') ? \
@@ -702,7 +702,7 @@ static const char map_value_to_xdigit[16] =
* @param v the value to convert, must be less then 16
* @return hexadecimal digit
*/
-# define xdigittovalue(v) map_value_to_xdigit[v]
+# define valuetoxdigit(v) map_value_to_xdigit[v]
#else /* MHD_FAVOR_SMALL_CODE */
/**
* Convert 4 bit value to US-ASCII hexadecimal digit.
@@ -710,7 +710,7 @@ static const char map_value_to_xdigit[16] =
* @param v the value to convert, must be less then 16
* @return hexadecimal digit
*/
- # define xdigittovalue(v) \
+ # define valuetoxdigit(v) \
(char) ((v <= 9) ? ('0' + (char) v) : ('A' + (char) v - 10))
#endif /* MHD_FAVOR_SMALL_CODE */
@@ -1224,7 +1224,7 @@ mhd_strx_to_uint32 (const char *restrict str,
return 0;
res = 0;
- digit = toxdigitvalue (*str);
+ digit = xdigittovalue (*str);
while (digit >= 0)
{
uint_fast32_t prev_res = res;
@@ -1237,7 +1237,7 @@ mhd_strx_to_uint32 (const char *restrict str,
return 0;
str++;
- digit = toxdigitvalue (*str);
+ digit = xdigittovalue (*str);
}
if (str - start > 0)
@@ -1259,7 +1259,7 @@ mhd_strx_to_uint32_n (const char *restrict str,
res = 0;
i = 0;
- while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0)
+ while (i < maxlen && (digit = xdigittovalue (str[i])) >= 0)
{
uint_fast32_t prev_res = res;
@@ -1302,7 +1302,7 @@ mhd_strx_to_uint64 (const char *restrict str,
return 0;
res = 0;
- digit = toxdigitvalue (*str);
+ digit = xdigittovalue (*str);
while (digit >= 0)
{
uint_fast64_t prev_res = res;
@@ -1315,7 +1315,7 @@ mhd_strx_to_uint64 (const char *restrict str,
return 0;
str++;
- digit = toxdigitvalue (*str);
+ digit = xdigittovalue (*str);
}
if (str - start > 0)
@@ -1350,7 +1350,7 @@ mhd_strx_to_uint64_n (const char *restrict str,
res = 0;
i = 0;
- while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0)
+ while (i < maxlen && (digit = xdigittovalue (str[i])) >= 0)
{
uint_fast64_t prev_res = res;
@@ -1410,7 +1410,7 @@ mhd_str_to_uvalue_n (const char *restrict str,
while (maxlen > i)
{
const int digit = (base == 16) ?
- toxdigitvalue (str[i]) : todigitvalue (str[i]);
+ xdigittovalue (str[i]) : todigitvalue (str[i]);
if (0 > digit)
break;
@@ -1461,7 +1461,7 @@ mhd_uint32_to_strx (uint_fast32_t val,
while (o_pos < buf_size)
{
- buf[o_pos++] = xdigittovalue (xdigit);
+ buf[o_pos++] = valuetoxdigit (xdigit);
if (0 == digit_pos)
return o_pos;
digit_pos--;
@@ -1613,8 +1613,8 @@ mhd_bin_to_hex (const void *restrict bin,
for (i = 0; i < size; ++i)
{
const uint8_t b = ((const uint8_t *) bin)[i];
- hex[i * 2] = xdigittovalue (b >> 4);
- hex[i * 2 + 1] = xdigittovalue (b & 0x0Fu);
+ hex[i * 2] = valuetoxdigit (b >> 4);
+ hex[i * 2 + 1] = valuetoxdigit (b & 0x0Fu);
}
return i * 2;
}
@@ -1651,7 +1651,7 @@ mhd_hex_to_bin (const char *restrict hex,
{
/* Assume the first byte is encoded with single digit */
const char c2 = hex[r++];
- const int l = toxdigitvalue (c2);
+ const int l = xdigittovalue (c2);
if (0 > l)
return 0;
((uint8_t *) bin)[w++] = (uint8_t) ((unsigned int) l);
@@ -1660,8 +1660,8 @@ mhd_hex_to_bin (const char *restrict hex,
{
const char c1 = hex[r++];
const char c2 = hex[r++];
- const int h = toxdigitvalue (c1);
- const int l = toxdigitvalue (c2);
+ const int h = xdigittovalue (c1);
+ const int l = xdigittovalue (c2);
if ((0 > h) || (0 > l))
return 0;
((uint8_t *) bin)[w++] =
@@ -1708,8 +1708,8 @@ mhd_str_pct_decode_strict_n (const char *pct_encoded,
{
const char c1 = pct_encoded[++r];
const char c2 = pct_encoded[++r];
- const int h = toxdigitvalue (c1);
- const int l = toxdigitvalue (c2);
+ const int h = xdigittovalue (c1);
+ const int l = xdigittovalue (c2);
unsigned char out;
if ((0 > h) || (0 > l))
return 0;
@@ -1740,8 +1740,8 @@ mhd_str_pct_decode_strict_n (const char *pct_encoded,
{
const char c1 = pct_encoded[++r];
const char c2 = pct_encoded[++r];
- const int h = toxdigitvalue (c1);
- const int l = toxdigitvalue (c2);
+ const int h = xdigittovalue (c1);
+ const int l = xdigittovalue (c2);
unsigned char out;
if ((0 > h) || (0 > l))
return 0;
@@ -1792,8 +1792,8 @@ mhd_str_pct_decode_lenient_n (const char *pct_encoded,
{
const char c1 = pct_encoded[++r];
const char c2 = pct_encoded[++r];
- const int h = toxdigitvalue (c1);
- const int l = toxdigitvalue (c2);
+ const int h = xdigittovalue (c1);
+ const int l = xdigittovalue (c2);
unsigned char out;
if ((0 > h) || (0 > l))
{
@@ -1837,8 +1837,8 @@ mhd_str_pct_decode_lenient_n (const char *pct_encoded,
{
const char c1 = pct_encoded[++r];
const char c2 = pct_encoded[++r];
- const int h = toxdigitvalue (c1);
- const int l = toxdigitvalue (c2);
+ const int h = xdigittovalue (c1);
+ const int l = xdigittovalue (c2);
if ((0 > h) || (0 > l))
{
r -= 2;
@@ -1901,8 +1901,8 @@ mhd_str_pct_decode_in_place_strict (char *str)
return 0;
else
{
- const int h = toxdigitvalue (d1);
- const int l = toxdigitvalue (d2);
+ const int h = xdigittovalue (d1);
+ const int l = xdigittovalue (d2);
unsigned char out;
if ((0 > h) || (0 > l))
return 0;
@@ -1971,8 +1971,8 @@ mhd_str_pct_decode_in_place_lenient (char *restrict str,
}
else
{
- const int h = toxdigitvalue (d1);
- const int l = toxdigitvalue (d2);
+ const int h = xdigittovalue (d1);
+ const int l = xdigittovalue (d2);
unsigned char out;
if ((0 > h) || (0 > l))
{