aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/mhd_str.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/mhd_str.c')
-rw-r--r--src/microhttpd/mhd_str.c369
1 files changed, 190 insertions, 179 deletions
diff --git a/src/microhttpd/mhd_str.c b/src/microhttpd/mhd_str.c
index 36a935a2..80f0b82e 100644
--- a/src/microhttpd/mhd_str.c
+++ b/src/microhttpd/mhd_str.c
@@ -117,8 +117,8 @@ _MHD_static_inline bool
117isasciixdigit (char c) 117isasciixdigit (char c)
118{ 118{
119 return isasciidigit (c) || 119 return isasciidigit (c) ||
120 ( (c >= 'A') && (c <= 'F') ) || 120 ( (c >= 'A') && (c <= 'F') ) ||
121 ( (c >= 'a') && (c <= 'f') ); 121 ( (c >= 'a') && (c <= 'f') );
122} 122}
123 123
124 124
@@ -181,7 +181,7 @@ _MHD_static_inline int
181todigitvalue (char c) 181todigitvalue (char c)
182{ 182{
183 if (isasciidigit (c)) 183 if (isasciidigit (c))
184 return (unsigned char)(c - '0'); 184 return (unsigned char) (c - '0');
185 185
186 return -1; 186 return -1;
187} 187}
@@ -198,11 +198,11 @@ _MHD_static_inline int
198toxdigitvalue (char c) 198toxdigitvalue (char c)
199{ 199{
200 if (isasciidigit (c)) 200 if (isasciidigit (c))
201 return (unsigned char)(c - '0'); 201 return (unsigned char) (c - '0');
202 if ( (c >= 'A') && (c <= 'F') ) 202 if ( (c >= 'A') && (c <= 'F') )
203 return (unsigned char)(c - 'A' + 10); 203 return (unsigned char) (c - 'A' + 10);
204 if ( (c >= 'a') && (c <= 'f') ) 204 if ( (c >= 'a') && (c <= 'f') )
205 return (unsigned char)(c - 'a' + 10); 205 return (unsigned char) (c - 'a' + 10);
206 206
207 return -1; 207 return -1;
208} 208}
@@ -216,7 +216,7 @@ toxdigitvalue (char c)
216 * @return boolean true if character is lower case letter, 216 * @return boolean true if character is lower case letter,
217 * boolean false otherwise 217 * boolean false otherwise
218 */ 218 */
219#define isasciilower(c) (((char)(c)) >= 'a' && ((char)(c)) <= 'z') 219#define isasciilower(c) (((char) (c)) >= 'a' && ((char) (c)) <= 'z')
220 220
221 221
222/** 222/**
@@ -226,7 +226,7 @@ toxdigitvalue (char c)
226 * @return boolean true if character is upper case letter, 226 * @return boolean true if character is upper case letter,
227 * boolean false otherwise 227 * boolean false otherwise
228 */ 228 */
229#define isasciiupper(c) (((char)(c)) >= 'A' && ((char)(c)) <= 'Z') 229#define isasciiupper(c) (((char) (c)) >= 'A' && ((char) (c)) <= 'Z')
230 230
231 231
232/** 232/**
@@ -236,7 +236,7 @@ toxdigitvalue (char c)
236 * @return boolean true if character is letter, boolean false 236 * @return boolean true if character is letter, boolean false
237 * otherwise 237 * otherwise
238 */ 238 */
239#define isasciialpha(c) (isasciilower(c) || isasciiupper(c)) 239#define isasciialpha(c) (isasciilower (c) || isasciiupper (c))
240 240
241 241
242/** 242/**
@@ -246,7 +246,7 @@ toxdigitvalue (char c)
246 * @return boolean true if character is decimal digit, boolean false 246 * @return boolean true if character is decimal digit, boolean false
247 * otherwise 247 * otherwise
248 */ 248 */
249#define isasciidigit(c) (((char)(c)) >= '0' && ((char)(c)) <= '9') 249#define isasciidigit(c) (((char) (c)) >= '0' && ((char) (c)) <= '9')
250 250
251 251
252/** 252/**
@@ -256,9 +256,9 @@ toxdigitvalue (char c)
256 * @return boolean true if character is hexadecimal digit, 256 * @return boolean true if character is hexadecimal digit,
257 * boolean false otherwise 257 * boolean false otherwise
258 */ 258 */
259#define isasciixdigit(c) (isasciidigit((c)) || \ 259#define isasciixdigit(c) (isasciidigit ((c)) || \
260 (((char)(c)) >= 'A' && ((char)(c)) <= 'F') || \ 260 (((char) (c)) >= 'A' && ((char) (c)) <= 'F') || \
261 (((char)(c)) >= 'a' && ((char)(c)) <= 'f') ) 261 (((char) (c)) >= 'a' && ((char) (c)) <= 'f') )
262 262
263 263
264/** 264/**
@@ -268,7 +268,7 @@ toxdigitvalue (char c)
268 * @return boolean true if character is decimal digit or letter, 268 * @return boolean true if character is decimal digit or letter,
269 * boolean false otherwise 269 * boolean false otherwise
270 */ 270 */
271#define isasciialnum(c) (isasciialpha(c) || isasciidigit(c)) 271#define isasciialnum(c) (isasciialpha (c) || isasciidigit (c))
272 272
273 273
274/** 274/**
@@ -280,7 +280,8 @@ toxdigitvalue (char c)
280 * @param c character to convert 280 * @param c character to convert
281 * @return converted to lower case character 281 * @return converted to lower case character
282 */ 282 */
283#define toasciilower(c) ((isasciiupper(c)) ? (((char)(c)) - 'A' + 'a') : ((char)(c))) 283#define toasciilower(c) ((isasciiupper (c)) ? (((char) (c)) - 'A' + 'a') : \
284 ((char) (c)))
284 285
285 286
286/** 287/**
@@ -292,7 +293,8 @@ toxdigitvalue (char c)
292 * @param c character to convert 293 * @param c character to convert
293 * @return converted to upper case character 294 * @return converted to upper case character
294 */ 295 */
295#define toasciiupper(c) ((isasciilower(c)) ? (((char)(c)) - 'a' + 'A') : ((char)(c))) 296#define toasciiupper(c) ((isasciilower (c)) ? (((char) (c)) - 'a' + 'A') : \
297 ((char) (c)))
296 298
297 299
298/** 300/**
@@ -301,7 +303,8 @@ toxdigitvalue (char c)
301 * @param c character to convert 303 * @param c character to convert
302 * @return value of hexadecimal digit or -1 if @ c is not hexadecimal digit 304 * @return value of hexadecimal digit or -1 if @ c is not hexadecimal digit
303 */ 305 */
304#define todigitvalue(c) (isasciidigit(c) ? (int)(((char)(c)) - '0') : (int)(-1)) 306#define todigitvalue(c) (isasciidigit (c) ? (int) (((char) (c)) - '0') : \
307 (int) (-1))
305 308
306 309
307/** 310/**
@@ -309,11 +312,12 @@ toxdigitvalue (char c)
309 * @param c character to convert 312 * @param c character to convert
310 * @return value of hexadecimal digit or -1 if @ c is not hexadecimal digit 313 * @return value of hexadecimal digit or -1 if @ c is not hexadecimal digit
311 */ 314 */
312#define toxdigitvalue(c) ( isasciidigit(c) ? (int)(((char)(c)) - '0') : \ 315#define toxdigitvalue(c) (isasciidigit (c) ? (int) (((char) (c)) - '0') : \
313 ( (((char)(c)) >= 'A' && ((char)(c)) <= 'F') ? \ 316 ( (((char) (c)) >= 'A' && ((char) (c)) <= 'F') ? \
314 (int)(((unsigned char)(c)) - 'A' + 10) : \ 317 (int) (((unsigned char) (c)) - 'A' + 10) : \
315 ( (((char)(c)) >= 'a' && ((char)(c)) <= 'f') ? \ 318 ( (((char) (c)) >= 'a' && ((char) (c)) <= 'f') ? \
316 (int)(((unsigned char)(c)) - 'a' + 10) : (int)(-1) ))) 319 (int) (((unsigned char) (c)) - 'a' + 10) : \
320 (int) (-1) )))
317#endif /* !INLINE_FUNC */ 321#endif /* !INLINE_FUNC */
318 322
319 323
@@ -326,19 +330,19 @@ toxdigitvalue (char c)
326 * @return non-zero if two strings are equal, zero otherwise. 330 * @return non-zero if two strings are equal, zero otherwise.
327 */ 331 */
328int 332int
329MHD_str_equal_caseless_ (const char * str1, 333MHD_str_equal_caseless_ (const char *str1,
330 const char * str2) 334 const char *str2)
331{ 335{
332 while (0 != (*str1)) 336 while (0 != (*str1))
333 { 337 {
334 const char c1 = *str1; 338 const char c1 = *str1;
335 const char c2 = *str2; 339 const char c2 = *str2;
336 if ( (c1 != c2) && 340 if ( (c1 != c2) &&
337 (toasciilower (c1) != toasciilower (c2)) ) 341 (toasciilower (c1) != toasciilower (c2)) )
338 return 0; 342 return 0;
339 str1++; 343 str1++;
340 str2++; 344 str2++;
341 } 345 }
342 return 0 == (*str2); 346 return 0 == (*str2);
343} 347}
344#endif /* ! MHD_FAVOR_SMALL_CODE */ 348#endif /* ! MHD_FAVOR_SMALL_CODE */
@@ -356,23 +360,23 @@ MHD_str_equal_caseless_ (const char * str1,
356 * @return non-zero if two strings are equal, zero otherwise. 360 * @return non-zero if two strings are equal, zero otherwise.
357 */ 361 */
358int 362int
359MHD_str_equal_caseless_n_ (const char * const str1, 363MHD_str_equal_caseless_n_ (const char *const str1,
360 const char * const str2, 364 const char *const str2,
361 size_t maxlen) 365 size_t maxlen)
362{ 366{
363 size_t i; 367 size_t i;
364 368
365 for (i = 0; i < maxlen; ++i) 369 for (i = 0; i < maxlen; ++i)
366 { 370 {
367 const char c1 = str1[i]; 371 const char c1 = str1[i];
368 const char c2 = str2[i]; 372 const char c2 = str2[i];
369 if (0 == c2) 373 if (0 == c2)
370 return 0 == c1; 374 return 0 == c1;
371 if ( (c1 != c2) && 375 if ( (c1 != c2) &&
372 (toasciilower (c1) != toasciilower (c2)) ) 376 (toasciilower (c1) != toasciilower (c2)) )
373 return 0; 377 return 0;
374 } 378 }
375 return !0; 379 return ! 0;
376} 380}
377 381
378 382
@@ -386,21 +390,21 @@ MHD_str_equal_caseless_n_ (const char * const str1,
386 * @return non-zero if two strings are equal, zero otherwise. 390 * @return non-zero if two strings are equal, zero otherwise.
387 */ 391 */
388bool 392bool
389MHD_str_equal_caseless_bin_n_ (const char * const str1, 393MHD_str_equal_caseless_bin_n_ (const char *const str1,
390 const char * const str2, 394 const char *const str2,
391 size_t len) 395 size_t len)
392{ 396{
393 size_t i; 397 size_t i;
394 398
395 for (i = 0; i < len; ++i) 399 for (i = 0; i < len; ++i)
396 { 400 {
397 const char c1 = str1[i]; 401 const char c1 = str1[i];
398 const char c2 = str2[i]; 402 const char c2 = str2[i];
399 if ( (c1 != c2) && 403 if ( (c1 != c2) &&
400 (toasciilower (c1) != toasciilower (c2)) ) 404 (toasciilower (c1) != toasciilower (c2)) )
401 return 0; 405 return 0;
402 } 406 }
403 return !0; 407 return ! 0;
404} 408}
405 409
406 410
@@ -419,46 +423,49 @@ MHD_str_equal_caseless_bin_n_ (const char * const str1,
419 * @return non-zero if two strings are equal, zero otherwise. 423 * @return non-zero if two strings are equal, zero otherwise.
420 */ 424 */
421bool 425bool
422MHD_str_has_token_caseless_ (const char * str, 426MHD_str_has_token_caseless_ (const char *str,
423 const char * const token, 427 const char *const token,
424 size_t token_len) 428 size_t token_len)
425{ 429{
426 if (0 == token_len) 430 if (0 == token_len)
427 return false; 431 return false;
428 432
429 while (0 != *str) 433 while (0 != *str)
434 {
435 size_t i;
436 /* Skip all whitespaces and empty tokens. */
437 while (' ' == *str || '\t' == *str || ',' == *str)
438 str++;
439
440 /* Check for token match. */
441 i = 0;
442 while (1)
430 { 443 {
431 size_t i; 444 const char sc = *(str++);
432 /* Skip all whitespaces and empty tokens. */ 445 const char tc = token[i++];
433 while (' ' == *str || '\t' == *str || ',' == *str) str++; 446
434 447 if (0 == sc)
435 /* Check for token match. */ 448 return false;
436 i = 0; 449 if ( (sc != tc) &&
437 while (1) 450 (toasciilower (sc) != toasciilower (tc)) )
438 { 451 break;
439 const char sc = *(str++); 452 if (i >= token_len)
440 const char tc = token[i++]; 453 {
441 454 /* Check whether substring match token fully or
442 if (0 == sc) 455 * has additional unmatched chars at tail. */
443 return false; 456 while (' ' == *str || '\t' == *str)
444 if ( (sc != tc) && 457 str++;
445 (toasciilower (sc) != toasciilower (tc)) ) 458 /* End of (sub)string? */
446 break; 459 if ((0 == *str) ||(',' == *str) )
447 if (i >= token_len) 460 return true;
448 { 461 /* Unmatched chars at end of substring. */
449 /* Check whether substring match token fully or 462 break;
450 * has additional unmatched chars at tail. */ 463 }
451 while (' ' == *str || '\t' == *str) str++;
452 /* End of (sub)string? */
453 if (0 == *str || ',' == *str)
454 return true;
455 /* Unmatched chars at end of substring. */
456 break;
457 }
458 }
459 /* Find next substring. */
460 while (0 != *str && ',' != *str) str++;
461 } 464 }
465 /* Find next substring. */
466 while (0 != *str && ',' != *str)
467 str++;
468 }
462 return false; 469 return false;
463} 470}
464 471
@@ -479,25 +486,25 @@ size_t
479MHD_str_to_uint64_ (const char *str, 486MHD_str_to_uint64_ (const char *str,
480 uint64_t *out_val) 487 uint64_t *out_val)
481{ 488{
482 const char * const start = str; 489 const char *const start = str;
483 uint64_t res; 490 uint64_t res;
484 491
485 if (!str || !out_val || !isasciidigit(str[0])) 492 if (! str || ! out_val || ! isasciidigit (str[0]))
486 return 0; 493 return 0;
487 494
488 res = 0; 495 res = 0;
489 do 496 do
490 { 497 {
491 const int digit = (unsigned char)(*str) - '0'; 498 const int digit = (unsigned char) (*str) - '0';
492 if ( (res > (UINT64_MAX / 10)) || 499 if ( (res > (UINT64_MAX / 10)) ||
493 ( (res == (UINT64_MAX / 10)) && 500 ( (res == (UINT64_MAX / 10)) &&
494 ((uint64_t)digit > (UINT64_MAX % 10)) ) ) 501 ((uint64_t) digit > (UINT64_MAX % 10)) ) )
495 return 0; 502 return 0;
496 503
497 res *= 10; 504 res *= 10;
498 res += digit; 505 res += digit;
499 str++; 506 str++;
500 } while (isasciidigit (*str)); 507 } while (isasciidigit (*str));
501 508
502 *out_val = res; 509 *out_val = res;
503 return str - start; 510 return str - start;
@@ -518,34 +525,34 @@ MHD_str_to_uint64_ (const char *str,
518 * then possible to store in uint64_t or @a out_val is NULL 525 * then possible to store in uint64_t or @a out_val is NULL
519 */ 526 */
520size_t 527size_t
521MHD_str_to_uint64_n_ (const char * str, 528MHD_str_to_uint64_n_ (const char *str,
522 size_t maxlen, 529 size_t maxlen,
523 uint64_t *out_val) 530 uint64_t *out_val)
524{ 531{
525 uint64_t res; 532 uint64_t res;
526 size_t i; 533 size_t i;
527 534
528 if (!str || !maxlen || !out_val || !isasciidigit (str[0])) 535 if (! str || ! maxlen || ! out_val || ! isasciidigit (str[0]))
529 return 0; 536 return 0;
530 537
531 res = 0; 538 res = 0;
532 i = 0; 539 i = 0;
533 do 540 do
534 { 541 {
535 const int digit = (unsigned char)str[i] - '0'; 542 const int digit = (unsigned char) str[i] - '0';
536 543
537 if ( (res > (UINT64_MAX / 10)) || 544 if ( (res > (UINT64_MAX / 10)) ||
538 ( (res == (UINT64_MAX / 10)) && 545 ( (res == (UINT64_MAX / 10)) &&
539 ((uint64_t)digit > (UINT64_MAX % 10)) ) ) 546 ((uint64_t) digit > (UINT64_MAX % 10)) ) )
540 return 0; 547 return 0;
541 548
542 res *= 10; 549 res *= 10;
543 res += digit; 550 res += digit;
544 i++; 551 i++;
545 } while ( (i < maxlen) && 552 } while ( (i < maxlen) &&
546 isasciidigit (str[i]) ); 553 isasciidigit (str[i]) );
547 554
548 *out_val= res; 555 *out_val = res;
549 return i; 556 return i;
550} 557}
551 558
@@ -561,31 +568,32 @@ MHD_str_to_uint64_n_ (const char * str,
561 * then possible to store in uint32_t or @a out_val is NULL 568 * then possible to store in uint32_t or @a out_val is NULL
562 */ 569 */
563size_t 570size_t
564MHD_strx_to_uint32_ (const char * str, 571MHD_strx_to_uint32_ (const char *str,
565 uint32_t *out_val) 572 uint32_t *out_val)
566{ 573{
567 const char * const start = str; 574 const char *const start = str;
568 uint32_t res; 575 uint32_t res;
569 int digit; 576 int digit;
570 577
571 if (!str || !out_val) 578 if (! str || ! out_val)
572 return 0; 579 return 0;
573 580
574 res = 0; 581 res = 0;
575 digit = toxdigitvalue (*str); 582 digit = toxdigitvalue (*str);
576 while (digit >= 0) 583 while (digit >= 0)
584 {
585 if ( (res < (UINT32_MAX / 16)) ||
586 ((res == (UINT32_MAX / 16)) &&( (uint32_t) digit <= (UINT32_MAX
587 % 16)) ) )
577 { 588 {
578 if ( (res < (UINT32_MAX / 16)) || 589 res *= 16;
579 (res == (UINT32_MAX / 16) && (uint32_t)digit <= (UINT32_MAX % 16)) ) 590 res += digit;
580 {
581 res *= 16;
582 res += digit;
583 }
584 else
585 return 0;
586 str++;
587 digit = toxdigitvalue (*str);
588 } 591 }
592 else
593 return 0;
594 str++;
595 digit = toxdigitvalue (*str);
596 }
589 597
590 if (str - start > 0) 598 if (str - start > 0)
591 *out_val = res; 599 *out_val = res;
@@ -614,21 +622,22 @@ MHD_strx_to_uint32_n_ (const char *str,
614 size_t i; 622 size_t i;
615 uint32_t res; 623 uint32_t res;
616 int digit; 624 int digit;
617 if (!str || !out_val) 625 if (! str || ! out_val)
618 return 0; 626 return 0;
619 627
620 res = 0; 628 res = 0;
621 i = 0; 629 i = 0;
622 while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0) 630 while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0)
623 { 631 {
624 if ( (res > (UINT32_MAX / 16)) || 632 if ( (res > (UINT32_MAX / 16)) ||
625 (res == (UINT32_MAX / 16) && (uint32_t)digit > (UINT32_MAX % 16)) ) 633 ((res == (UINT32_MAX / 16)) &&( (uint32_t) digit > (UINT32_MAX
626 return 0; 634 % 16)) ) )
635 return 0;
627 636
628 res *= 16; 637 res *= 16;
629 res += digit; 638 res += digit;
630 i++; 639 i++;
631 } 640 }
632 641
633 if (i) 642 if (i)
634 *out_val = res; 643 *out_val = res;
@@ -650,27 +659,28 @@ size_t
650MHD_strx_to_uint64_ (const char *str, 659MHD_strx_to_uint64_ (const char *str,
651 uint64_t *out_val) 660 uint64_t *out_val)
652{ 661{
653 const char * const start = str; 662 const char *const start = str;
654 uint64_t res; 663 uint64_t res;
655 int digit; 664 int digit;
656 if (!str || !out_val) 665 if (! str || ! out_val)
657 return 0; 666 return 0;
658 667
659 res = 0; 668 res = 0;
660 digit = toxdigitvalue (*str); 669 digit = toxdigitvalue (*str);
661 while (digit >= 0) 670 while (digit >= 0)
671 {
672 if ( (res < (UINT64_MAX / 16)) ||
673 ((res == (UINT64_MAX / 16)) &&( (uint64_t) digit <= (UINT64_MAX
674 % 16)) ) )
662 { 675 {
663 if ( (res < (UINT64_MAX / 16)) || 676 res *= 16;
664 (res == (UINT64_MAX / 16) && (uint64_t)digit <= (UINT64_MAX % 16)) ) 677 res += digit;
665 {
666 res *= 16;
667 res += digit;
668 }
669 else
670 return 0;
671 str++;
672 digit = toxdigitvalue (*str);
673 } 678 }
679 else
680 return 0;
681 str++;
682 digit = toxdigitvalue (*str);
683 }
674 684
675 if (str - start > 0) 685 if (str - start > 0)
676 *out_val = res; 686 *out_val = res;
@@ -692,28 +702,29 @@ MHD_strx_to_uint64_ (const char *str,
692 * then possible to store in uint64_t or @a out_val is NULL 702 * then possible to store in uint64_t or @a out_val is NULL
693 */ 703 */
694size_t 704size_t
695MHD_strx_to_uint64_n_ (const char * str, 705MHD_strx_to_uint64_n_ (const char *str,
696 size_t maxlen, 706 size_t maxlen,
697 uint64_t *out_val) 707 uint64_t *out_val)
698{ 708{
699 size_t i; 709 size_t i;
700 uint64_t res; 710 uint64_t res;
701 int digit; 711 int digit;
702 if (!str || !out_val) 712 if (! str || ! out_val)
703 return 0; 713 return 0;
704 714
705 res = 0; 715 res = 0;
706 i = 0; 716 i = 0;
707 while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0) 717 while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0)
708 { 718 {
709 if ( (res > (UINT64_MAX / 16)) || 719 if ( (res > (UINT64_MAX / 16)) ||
710 (res == (UINT64_MAX / 16) && (uint64_t)digit > (UINT64_MAX % 16)) ) 720 ((res == (UINT64_MAX / 16)) &&( (uint64_t) digit > (UINT64_MAX
711 return 0; 721 % 16)) ) )
722 return 0;
712 723
713 res *= 16; 724 res *= 16;
714 res += digit; 725 res += digit;
715 i++; 726 i++;
716 } 727 }
717 728
718 if (i) 729 if (i)
719 *out_val = res; 730 *out_val = res;
@@ -742,7 +753,7 @@ MHD_strx_to_uint64_n_ (const char * str,
742size_t 753size_t
743MHD_str_to_uvalue_n_ (const char *str, 754MHD_str_to_uvalue_n_ (const char *str,
744 size_t maxlen, 755 size_t maxlen,
745 void * out_val, 756 void *out_val,
746 size_t val_size, 757 size_t val_size,
747 uint64_t max_val, 758 uint64_t max_val,
748 int base) 759 int base)
@@ -754,34 +765,34 @@ MHD_str_to_uvalue_n_ (const char *str,
754 const uint64_t max_v_mod_b = max_val % base; 765 const uint64_t max_v_mod_b = max_val % base;
755 /* 'digit->value' must be function, not macro */ 766 /* 'digit->value' must be function, not macro */
756 int (*const dfunc)(char) = (base == 16) ? 767 int (*const dfunc)(char) = (base == 16) ?
757 toxdigitvalue : todigitvalue; 768 toxdigitvalue : todigitvalue;
758 769
759 if ( !str || !out_val || 770 if ( ! str || ! out_val ||
760 (base != 16 && base != 10) ) 771 ((base != 16)&&(base != 10)) )
761 return 0; 772 return 0;
762 773
763 res = 0; 774 res = 0;
764 i = 0; 775 i = 0;
765 while (maxlen > i && 0 <= (digit = dfunc (str[i]))) 776 while (maxlen > i && 0 <= (digit = dfunc (str[i])))
766 { 777 {
767 if ( ((max_v_div_b) < res) || 778 if ( ((max_v_div_b) < res) ||
768 ((max_v_div_b) == res && (max_v_mod_b) < (uint64_t)digit) ) 779 (( (max_v_div_b) == res) &&( (max_v_mod_b) < (uint64_t) digit) ) )
769 return 0; 780 return 0;
770 781
771 res *= base; 782 res *= base;
772 res += digit; 783 res += digit;
773 i++; 784 i++;
774 } 785 }
775 786
776 if (i) 787 if (i)
777 { 788 {
778 if (8 == val_size) 789 if (8 == val_size)
779 *(uint64_t*)out_val = res; 790 *(uint64_t*) out_val = res;
780 else if (4 == val_size) 791 else if (4 == val_size)
781 *(uint32_t*)out_val = (uint32_t)res; 792 *(uint32_t*) out_val = (uint32_t) res;
782 else 793 else
783 return 0; 794 return 0;
784 } 795 }
785 return i; 796 return i;
786} 797}
787#endif /* MHD_FAVOR_SMALL_CODE */ 798#endif /* MHD_FAVOR_SMALL_CODE */