libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

commit dc244b7b45b605ea23d8efff46cf65c3f286d915
parent cd7f2121e90572ca5c905fdbb65e28a4e6885186
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date:   Fri, 25 Apr 2025 18:31:05 +0200

mhd_str: cosmetics

Diffstat:
Msrc/mhd2/mhd_str.c | 69++++++++++++++++++++++++++++++++++++---------------------------------
1 file changed, 36 insertions(+), 33 deletions(-)

diff --git a/src/mhd2/mhd_str.c b/src/mhd2/mhd_str.c @@ -31,7 +31,6 @@ #include "mhd_assert.h" #include "mhd_limits.h" -#include "mhd_assert.h" #ifdef MHD_FAVOR_SMALL_CODE # ifdef MHD_static_inline_ @@ -560,7 +559,7 @@ charsequalcaseless (const char c1, const char c2) * @return boolean true if character is lower case letter, * boolean false otherwise */ -#define isasciilower(c) ((((char) (c)) >= 'a') && (((char) (c)) <= 'z')) +# define isasciilower(c) ((((char) (c)) >= 'a') && (((char) (c)) <= 'z')) /** @@ -570,7 +569,7 @@ charsequalcaseless (const char c1, const char c2) * @return boolean true if character is upper case letter, * boolean false otherwise */ -#define isasciiupper(c) ((((char) (c)) <= 'Z') && (((char) (c)) >= 'A')) +# define isasciiupper(c) ((((char) (c)) <= 'Z') && (((char) (c)) >= 'A')) /** @@ -580,7 +579,7 @@ charsequalcaseless (const char c1, const char c2) * @return boolean true if character is letter, boolean false * otherwise */ -#define isasciialpha(c) (isasciilower (c) || isasciiupper (c)) +# define isasciialpha(c) (isasciilower (c) || isasciiupper (c)) /** @@ -590,7 +589,7 @@ charsequalcaseless (const char c1, const char c2) * @return boolean true if character is decimal digit, boolean false * otherwise */ -#define isasciidigit(c) ((((char) (c)) <= '9') && (((char) (c)) >= '0')) +# define isasciidigit(c) ((((char) (c)) <= '9') && (((char) (c)) >= '0')) /** @@ -600,9 +599,9 @@ charsequalcaseless (const char c1, const char c2) * @return boolean true if character is hexadecimal digit, * boolean false otherwise */ -#define isasciixdigit(c) (isasciidigit ((c)) || \ - (((char) (c)) <= 'F' && ((char) (c)) >= 'A') || \ - (((char) (c)) <= 'f' && ((char) (c)) >= 'a')) +# define isasciixdigit(c) (isasciidigit ((c)) || \ + (((char) (c)) <= 'F' && ((char) (c)) >= 'A') || \ + (((char) (c)) <= 'f' && ((char) (c)) >= 'a')) /** @@ -612,7 +611,7 @@ charsequalcaseless (const char c1, const char c2) * @return boolean true if character is decimal digit or letter, * boolean false otherwise */ -#define isasciialnum(c) (isasciialpha (c) || isasciidigit (c)) +# define isasciialnum(c) (isasciialpha (c) || isasciidigit (c)) /** @@ -624,8 +623,8 @@ charsequalcaseless (const char c1, const char c2) * @param c character to convert * @return converted to lower case character */ -#define toasciilower(c) ((isasciiupper (c)) ? (((char) (c)) - 'A' + 'a') : \ - ((char) (c))) +# define toasciilower(c) ((isasciiupper (c)) ? (((char) (c)) - 'A' + 'a') : \ + ((char) (c))) /** @@ -637,8 +636,8 @@ charsequalcaseless (const char c1, const char c2) * @param c character to convert * @return converted to upper case character */ -#define toasciiupper(c) ((isasciilower (c)) ? (((char) (c)) - 'a' + 'A') : \ - ((char) (c))) +# define toasciiupper(c) ((isasciilower (c)) ? (((char) (c)) - 'a' + 'A') : \ + ((char) (c))) /** @@ -647,8 +646,8 @@ 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 todigitvalue(c) (isasciidigit (c) ? (int) (((char) (c)) - '0') : \ - (int) (-1)) +# define todigitvalue(c) (isasciidigit (c) ? (int) (((char) (c)) - '0') : \ + (int) (-1)) /** @@ -656,12 +655,12 @@ 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') : \ - ( (((char) (c)) >= 'A' && ((char) (c)) <= 'F') ? \ - (int) (((unsigned char) (c)) - 'A' + 10) : \ - ( (((char) (c)) >= 'a' && ((char) (c)) <= 'f') ? \ - (int) (((unsigned char) (c)) - 'a' + 10) : \ - (int) (-1) ))) +# define toxdigitvalue(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') ? \ + (int) (((unsigned char) (c)) - 'a' + 10) : \ + (int) (-1) ))) /** * Caseless compare two characters. @@ -670,7 +669,7 @@ charsequalcaseless (const char c1, const char c2) * @param c2 the second char to compare * @return boolean 'true' if chars are caseless equal, false otherwise */ -#define charsequalcaseless(c1, c2) \ +# define charsequalcaseless(c1, c2) \ ( ((c1) == (c2)) || \ ((((c1) - 'A' + 'a') == (c2)) ? \ isasciiupper (c1) : \ @@ -1614,9 +1613,9 @@ mhd_hex_to_bin (const char *restrict hex, const int l = toxdigitvalue (c2); if ((0 > h) || (0 > l)) return 0; - ((uint8_t *) bin)[w++] = (uint8_t) ( ((uint8_t) (((uint8_t) - ((unsigned int) h)) << 4)) - | ((uint8_t) ((unsigned int) l)) ); + ((uint8_t *) bin)[w++] = + (uint8_t) ( ((uint8_t) (((uint8_t) ((unsigned int) h)) << 4)) + | ((uint8_t) ((unsigned int) l)) ); } mhd_assert (len == r); mhd_assert ((len + 1) / 2 == w); @@ -1755,8 +1754,9 @@ mhd_str_pct_decode_lenient_n (const char *pct_encoded, else { out = - (unsigned char) (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4)) - | ((uint8_t) ((unsigned int) l))); + (unsigned char) + (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4)) + | ((uint8_t) ((unsigned int) l))); decoded[w] = (char) out; } } @@ -1799,8 +1799,9 @@ mhd_str_pct_decode_lenient_n (const char *pct_encoded, { unsigned char out; out = - (unsigned char) (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4)) - | ((uint8_t) ((unsigned int) l))); + (unsigned char) + (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4)) + | ((uint8_t) ((unsigned int) l))); decoded[w] = (char) out; } } @@ -1855,8 +1856,9 @@ mhd_str_pct_decode_in_place_strict (char *str) if ((0 > h) || (0 > l)) return 0; out = - (unsigned char) (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4)) - | ((uint8_t) ((unsigned int) l))); + (unsigned char) + (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4)) + | ((uint8_t) ((unsigned int) l))); str[w++] = (char) out; } } @@ -1931,8 +1933,9 @@ mhd_str_pct_decode_in_place_lenient (char *restrict str, continue; } out = - (unsigned char) (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4)) - | ((uint8_t) ((unsigned int) l))); + (unsigned char) + (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4)) + | ((uint8_t) ((unsigned int) l))); str[w++] = (char) out; continue; }