diff options
Diffstat (limited to 'src/microhttpd/mhd_str.c')
-rw-r--r-- | src/microhttpd/mhd_str.c | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/src/microhttpd/mhd_str.c b/src/microhttpd/mhd_str.c index 80f0b82e..08162fb2 100644 --- a/src/microhttpd/mhd_str.c +++ b/src/microhttpd/mhd_str.c | |||
@@ -63,6 +63,8 @@ isasciilower (char c) | |||
63 | { | 63 | { |
64 | return (c >= 'a') && (c <= 'z'); | 64 | return (c >= 'a') && (c <= 'z'); |
65 | } | 65 | } |
66 | |||
67 | |||
66 | #endif /* Disable unused functions. */ | 68 | #endif /* Disable unused functions. */ |
67 | 69 | ||
68 | 70 | ||
@@ -91,6 +93,8 @@ isasciialpha (char c) | |||
91 | { | 93 | { |
92 | return isasciilower (c) || isasciiupper (c); | 94 | return isasciilower (c) || isasciiupper (c); |
93 | } | 95 | } |
96 | |||
97 | |||
94 | #endif /* Disable unused functions. */ | 98 | #endif /* Disable unused functions. */ |
95 | 99 | ||
96 | 100 | ||
@@ -106,6 +110,7 @@ isasciidigit (char c) | |||
106 | return (c >= '0') && (c <= '9'); | 110 | return (c >= '0') && (c <= '9'); |
107 | } | 111 | } |
108 | 112 | ||
113 | |||
109 | #if 0 /* Disable unused functions. */ | 114 | #if 0 /* Disable unused functions. */ |
110 | /** | 115 | /** |
111 | * Check whether character is hexadecimal digit in US-ASCII | 116 | * Check whether character is hexadecimal digit in US-ASCII |
@@ -133,6 +138,8 @@ isasciialnum (char c) | |||
133 | { | 138 | { |
134 | return isasciialpha (c) || isasciidigit (c); | 139 | return isasciialpha (c) || isasciidigit (c); |
135 | } | 140 | } |
141 | |||
142 | |||
136 | #endif /* Disable unused functions. */ | 143 | #endif /* Disable unused functions. */ |
137 | 144 | ||
138 | 145 | ||
@@ -167,6 +174,8 @@ toasciiupper (char c) | |||
167 | { | 174 | { |
168 | return isasciilower (c) ? (c - 'a' + 'A') : c; | 175 | return isasciilower (c) ? (c - 'a' + 'A') : c; |
169 | } | 176 | } |
177 | |||
178 | |||
170 | #endif /* Disable unused functions. */ | 179 | #endif /* Disable unused functions. */ |
171 | 180 | ||
172 | 181 | ||
@@ -185,6 +194,8 @@ todigitvalue (char c) | |||
185 | 194 | ||
186 | return -1; | 195 | return -1; |
187 | } | 196 | } |
197 | |||
198 | |||
188 | #endif /* MHD_FAVOR_SMALL_CODE */ | 199 | #endif /* MHD_FAVOR_SMALL_CODE */ |
189 | 200 | ||
190 | 201 | ||
@@ -206,6 +217,8 @@ toxdigitvalue (char c) | |||
206 | 217 | ||
207 | return -1; | 218 | return -1; |
208 | } | 219 | } |
220 | |||
221 | |||
209 | #else /* !INLINE_FUNC */ | 222 | #else /* !INLINE_FUNC */ |
210 | 223 | ||
211 | 224 | ||
@@ -345,6 +358,8 @@ MHD_str_equal_caseless_ (const char *str1, | |||
345 | } | 358 | } |
346 | return 0 == (*str2); | 359 | return 0 == (*str2); |
347 | } | 360 | } |
361 | |||
362 | |||
348 | #endif /* ! MHD_FAVOR_SMALL_CODE */ | 363 | #endif /* ! MHD_FAVOR_SMALL_CODE */ |
349 | 364 | ||
350 | 365 | ||
@@ -408,7 +423,6 @@ MHD_str_equal_caseless_bin_n_ (const char *const str1, | |||
408 | } | 423 | } |
409 | 424 | ||
410 | 425 | ||
411 | |||
412 | /** | 426 | /** |
413 | * Check whether @a str has case-insensitive @a token. | 427 | * Check whether @a str has case-insensitive @a token. |
414 | * Token could be surrounded by spaces and tabs and delimited by comma. | 428 | * Token could be surrounded by spaces and tabs and delimited by comma. |
@@ -456,7 +470,7 @@ MHD_str_has_token_caseless_ (const char *str, | |||
456 | while (' ' == *str || '\t' == *str) | 470 | while (' ' == *str || '\t' == *str) |
457 | str++; | 471 | str++; |
458 | /* End of (sub)string? */ | 472 | /* End of (sub)string? */ |
459 | if ((0 == *str) ||(',' == *str) ) | 473 | if ((0 == *str) || (',' == *str) ) |
460 | return true; | 474 | return true; |
461 | /* Unmatched chars at end of substring. */ | 475 | /* Unmatched chars at end of substring. */ |
462 | break; | 476 | break; |
@@ -469,6 +483,7 @@ MHD_str_has_token_caseless_ (const char *str, | |||
469 | return false; | 483 | return false; |
470 | } | 484 | } |
471 | 485 | ||
486 | |||
472 | #ifndef MHD_FAVOR_SMALL_CODE | 487 | #ifndef MHD_FAVOR_SMALL_CODE |
473 | /* Use individual function for each case */ | 488 | /* Use individual function for each case */ |
474 | 489 | ||
@@ -583,8 +598,8 @@ MHD_strx_to_uint32_ (const char *str, | |||
583 | while (digit >= 0) | 598 | while (digit >= 0) |
584 | { | 599 | { |
585 | if ( (res < (UINT32_MAX / 16)) || | 600 | if ( (res < (UINT32_MAX / 16)) || |
586 | ((res == (UINT32_MAX / 16)) &&( (uint32_t) digit <= (UINT32_MAX | 601 | ((res == (UINT32_MAX / 16)) && ( (uint32_t) digit <= (UINT32_MAX |
587 | % 16)) ) ) | 602 | % 16)) ) ) |
588 | { | 603 | { |
589 | res *= 16; | 604 | res *= 16; |
590 | res += digit; | 605 | res += digit; |
@@ -630,8 +645,8 @@ MHD_strx_to_uint32_n_ (const char *str, | |||
630 | while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0) | 645 | while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0) |
631 | { | 646 | { |
632 | if ( (res > (UINT32_MAX / 16)) || | 647 | if ( (res > (UINT32_MAX / 16)) || |
633 | ((res == (UINT32_MAX / 16)) &&( (uint32_t) digit > (UINT32_MAX | 648 | ((res == (UINT32_MAX / 16)) && ( (uint32_t) digit > (UINT32_MAX |
634 | % 16)) ) ) | 649 | % 16)) ) ) |
635 | return 0; | 650 | return 0; |
636 | 651 | ||
637 | res *= 16; | 652 | res *= 16; |
@@ -670,8 +685,8 @@ MHD_strx_to_uint64_ (const char *str, | |||
670 | while (digit >= 0) | 685 | while (digit >= 0) |
671 | { | 686 | { |
672 | if ( (res < (UINT64_MAX / 16)) || | 687 | if ( (res < (UINT64_MAX / 16)) || |
673 | ((res == (UINT64_MAX / 16)) &&( (uint64_t) digit <= (UINT64_MAX | 688 | ((res == (UINT64_MAX / 16)) && ( (uint64_t) digit <= (UINT64_MAX |
674 | % 16)) ) ) | 689 | % 16)) ) ) |
675 | { | 690 | { |
676 | res *= 16; | 691 | res *= 16; |
677 | res += digit; | 692 | res += digit; |
@@ -717,8 +732,8 @@ MHD_strx_to_uint64_n_ (const char *str, | |||
717 | while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0) | 732 | while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0) |
718 | { | 733 | { |
719 | if ( (res > (UINT64_MAX / 16)) || | 734 | if ( (res > (UINT64_MAX / 16)) || |
720 | ((res == (UINT64_MAX / 16)) &&( (uint64_t) digit > (UINT64_MAX | 735 | ((res == (UINT64_MAX / 16)) && ( (uint64_t) digit > (UINT64_MAX |
721 | % 16)) ) ) | 736 | % 16)) ) ) |
722 | return 0; | 737 | return 0; |
723 | 738 | ||
724 | res *= 16; | 739 | res *= 16; |
@@ -731,6 +746,7 @@ MHD_strx_to_uint64_n_ (const char *str, | |||
731 | return i; | 746 | return i; |
732 | } | 747 | } |
733 | 748 | ||
749 | |||
734 | #else /* MHD_FAVOR_SMALL_CODE */ | 750 | #else /* MHD_FAVOR_SMALL_CODE */ |
735 | 751 | ||
736 | /** | 752 | /** |
@@ -767,8 +783,8 @@ MHD_str_to_uvalue_n_ (const char *str, | |||
767 | int (*const dfunc)(char) = (base == 16) ? | 783 | int (*const dfunc)(char) = (base == 16) ? |
768 | toxdigitvalue : todigitvalue; | 784 | toxdigitvalue : todigitvalue; |
769 | 785 | ||
770 | if ( ! str || ! out_val || | 786 | if (! str || ! out_val || |
771 | ((base != 16)&&(base != 10)) ) | 787 | ((base != 16) && (base != 10)) ) |
772 | return 0; | 788 | return 0; |
773 | 789 | ||
774 | res = 0; | 790 | res = 0; |
@@ -776,7 +792,7 @@ MHD_str_to_uvalue_n_ (const char *str, | |||
776 | while (maxlen > i && 0 <= (digit = dfunc (str[i]))) | 792 | while (maxlen > i && 0 <= (digit = dfunc (str[i]))) |
777 | { | 793 | { |
778 | if ( ((max_v_div_b) < res) || | 794 | if ( ((max_v_div_b) < res) || |
779 | (( (max_v_div_b) == res) &&( (max_v_mod_b) < (uint64_t) digit) ) ) | 795 | (( (max_v_div_b) == res) && ( (max_v_mod_b) < (uint64_t) digit) ) ) |
780 | return 0; | 796 | return 0; |
781 | 797 | ||
782 | res *= base; | 798 | res *= base; |
@@ -795,4 +811,6 @@ MHD_str_to_uvalue_n_ (const char *str, | |||
795 | } | 811 | } |
796 | return i; | 812 | return i; |
797 | } | 813 | } |
814 | |||
815 | |||
798 | #endif /* MHD_FAVOR_SMALL_CODE */ | 816 | #endif /* MHD_FAVOR_SMALL_CODE */ |