aboutsummaryrefslogtreecommitdiff
path: root/src/lib/mhd_str.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/mhd_str.c')
-rw-r--r--src/lib/mhd_str.c43
1 files changed, 31 insertions, 12 deletions
diff --git a/src/lib/mhd_str.c b/src/lib/mhd_str.c
index 6f2d7b98..d750a393 100644
--- a/src/lib/mhd_str.c
+++ b/src/lib/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
@@ -427,7 +442,7 @@ MHD_str_has_token_caseless_ (const char *str,
427 while (' ' == *str || '\t' == *str) 442 while (' ' == *str || '\t' == *str)
428 str++; 443 str++;
429 /* End of (sub)string? */ 444 /* End of (sub)string? */
430 if ((0 == *str) ||(',' == *str) ) 445 if ((0 == *str) || (',' == *str) )
431 return true; 446 return true;
432 /* Unmatched chars at end of substring. */ 447 /* Unmatched chars at end of substring. */
433 break; 448 break;
@@ -440,6 +455,7 @@ MHD_str_has_token_caseless_ (const char *str,
440 return false; 455 return false;
441} 456}
442 457
458
443#ifndef MHD_FAVOR_SMALL_CODE 459#ifndef MHD_FAVOR_SMALL_CODE
444/* Use individual function for each case */ 460/* Use individual function for each case */
445 461
@@ -554,8 +570,8 @@ MHD_strx_to_uint32_ (const char *str,
554 while (digit >= 0) 570 while (digit >= 0)
555 { 571 {
556 if ( (res < (UINT32_MAX / 16)) || 572 if ( (res < (UINT32_MAX / 16)) ||
557 ((res == (UINT32_MAX / 16)) &&( (uint32_t) digit <= (UINT32_MAX 573 ((res == (UINT32_MAX / 16)) && ( (uint32_t) digit <= (UINT32_MAX
558 % 16)) ) ) 574 % 16)) ) )
559 { 575 {
560 res *= 16; 576 res *= 16;
561 res += digit; 577 res += digit;
@@ -601,8 +617,8 @@ MHD_strx_to_uint32_n_ (const char *str,
601 while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0) 617 while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0)
602 { 618 {
603 if ( (res > (UINT32_MAX / 16)) || 619 if ( (res > (UINT32_MAX / 16)) ||
604 ((res == (UINT32_MAX / 16)) &&( (uint32_t) digit > (UINT32_MAX 620 ((res == (UINT32_MAX / 16)) && ( (uint32_t) digit > (UINT32_MAX
605 % 16)) ) ) 621 % 16)) ) )
606 return 0; 622 return 0;
607 623
608 res *= 16; 624 res *= 16;
@@ -641,8 +657,8 @@ MHD_strx_to_uint64_ (const char *str,
641 while (digit >= 0) 657 while (digit >= 0)
642 { 658 {
643 if ( (res < (UINT64_MAX / 16)) || 659 if ( (res < (UINT64_MAX / 16)) ||
644 ((res == (UINT64_MAX / 16)) &&( (uint64_t) digit <= (UINT64_MAX 660 ((res == (UINT64_MAX / 16)) && ( (uint64_t) digit <= (UINT64_MAX
645 % 16)) ) ) 661 % 16)) ) )
646 { 662 {
647 res *= 16; 663 res *= 16;
648 res += digit; 664 res += digit;
@@ -688,8 +704,8 @@ MHD_strx_to_uint64_n_ (const char *str,
688 while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0) 704 while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0)
689 { 705 {
690 if ( (res > (UINT64_MAX / 16)) || 706 if ( (res > (UINT64_MAX / 16)) ||
691 ((res == (UINT64_MAX / 16)) &&( (uint64_t) digit > (UINT64_MAX 707 ((res == (UINT64_MAX / 16)) && ( (uint64_t) digit > (UINT64_MAX
692 % 16)) ) ) 708 % 16)) ) )
693 return 0; 709 return 0;
694 710
695 res *= 16; 711 res *= 16;
@@ -702,6 +718,7 @@ MHD_strx_to_uint64_n_ (const char *str,
702 return i; 718 return i;
703} 719}
704 720
721
705#else /* MHD_FAVOR_SMALL_CODE */ 722#else /* MHD_FAVOR_SMALL_CODE */
706 723
707/** 724/**
@@ -738,8 +755,8 @@ MHD_str_to_uvalue_n_ (const char *str,
738 int (*const dfunc)(char) = (base == 16) ? 755 int (*const dfunc)(char) = (base == 16) ?
739 toxdigitvalue : todigitvalue; 756 toxdigitvalue : todigitvalue;
740 757
741 if ( ! str || ! out_val || 758 if (! str || ! out_val ||
742 ((base != 16)&&(base != 10)) ) 759 ((base != 16) && (base != 10)) )
743 return 0; 760 return 0;
744 761
745 res = 0; 762 res = 0;
@@ -747,7 +764,7 @@ MHD_str_to_uvalue_n_ (const char *str,
747 while (maxlen > i && 0 <= (digit = dfunc (str[i]))) 764 while (maxlen > i && 0 <= (digit = dfunc (str[i])))
748 { 765 {
749 if ( ((max_v_div_b) < res) || 766 if ( ((max_v_div_b) < res) ||
750 (( (max_v_div_b) == res) &&( (max_v_mod_b) < (uint64_t) digit) ) ) 767 (( (max_v_div_b) == res) && ( (max_v_mod_b) < (uint64_t) digit) ) )
751 return 0; 768 return 0;
752 769
753 res *= base; 770 res *= base;
@@ -766,4 +783,6 @@ MHD_str_to_uvalue_n_ (const char *str,
766 } 783 }
767 return i; 784 return i;
768} 785}
786
787
769#endif /* MHD_FAVOR_SMALL_CODE */ 788#endif /* MHD_FAVOR_SMALL_CODE */