libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 4153c1cd4c234226f5075e4115606d8fc4549ad4
parent 3cd82965442c3550a861d87e55d5ab664a579520
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Tue, 27 Sep 2022 20:36:56 +0300

mhd_str: minor refactoring for compact code

Diffstat:
Msrc/microhttpd/mhd_str.c | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/microhttpd/mhd_str.c b/src/microhttpd/mhd_str.c @@ -1168,12 +1168,8 @@ MHD_str_to_uvalue_n_ (const char *str, { size_t i; uint64_t res; - int digit; const uint64_t max_v_div_b = max_val / base; const uint64_t max_v_mod_b = max_val % base; - /* 'digit->value' must be function, not macro */ - int (*const dfunc)(char) = (base == 16) ? - toxdigitvalue : todigitvalue; if (! str || ! out_val || ((base != 16) && (base != 10)) ) @@ -1181,8 +1177,13 @@ MHD_str_to_uvalue_n_ (const char *str, res = 0; i = 0; - while (maxlen > i && 0 <= (digit = dfunc (str[i]))) + while (maxlen > i) { + const int digit = (base == 16) ? + toxdigitvalue (str[i]) : todigitvalue (str[i]); + + if (0 > digit) + break; if ( ((max_v_div_b) < res) || (( (max_v_div_b) == res) && ( (max_v_mod_b) < (uint64_t) digit) ) ) return 0;