aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/mhd_str.c
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-11-02 21:29:57 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-11-02 21:29:57 +0300
commitfa4a35d9d5921e7dbfdc251a3a231638bc23d549 (patch)
tree4a9fa67f5bb82cf94eee2d2c853601e796a8c7d6 /src/microhttpd/mhd_str.c
parent93a5a52a019e654b899ab3bc22a7bfdbac41990f (diff)
downloadlibmicrohttpd-fa4a35d9d5921e7dbfdc251a3a231638bc23d549.tar.gz
libmicrohttpd-fa4a35d9d5921e7dbfdc251a3a231638bc23d549.zip
MHD_str_remove_token_caseless_(): clarified comments
Diffstat (limited to 'src/microhttpd/mhd_str.c')
-rw-r--r--src/microhttpd/mhd_str.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/microhttpd/mhd_str.c b/src/microhttpd/mhd_str.c
index 31cc20b0..4222cbab 100644
--- a/src/microhttpd/mhd_str.c
+++ b/src/microhttpd/mhd_str.c
@@ -588,8 +588,9 @@ MHD_str_remove_token_caseless_ (const char *str,
588 if ((size_t) (s1 - str) >= str_len) 588 if ((size_t) (s1 - str) >= str_len)
589 break; /* Nothing to copy, end of the input string */ 589 break; /* Nothing to copy, end of the input string */
590 590
591 cur_token = s1; /* the first char of input token or 591 /* 's1' points to the first char of token in the input string */
592 the char after the input buffer */ 592
593 cur_token = s1; /* the first char of input token */
593 594
594 /* Check the token with case-insensetive match */ 595 /* Check the token with case-insensetive match */
595 t_pos = 0; 596 t_pos = 0;
@@ -599,6 +600,7 @@ MHD_str_remove_token_caseless_ (const char *str,
599 s1++; 600 s1++;
600 t_pos++; 601 t_pos++;
601 } 602 }
603 /* s1 may point just beyond the end of the input string */
602 if ( (token_len == t_pos) && (0 != token_len) ) 604 if ( (token_len == t_pos) && (0 != token_len) )
603 { 605 {
604 /* 'token' matched, check that current input token does not have 606 /* 'token' matched, check that current input token does not have
@@ -616,10 +618,11 @@ MHD_str_remove_token_caseless_ (const char *str,
616 } 618 }
617 } 619 }
618 620
619 /* 's1' points to some non-whitespace char in the token in the input 621 /* 's1' points to first non-whitespace char, to some char after
620 * string, to the ',', or just beyond the end of the input string */ 622 * first non-whitespace char in the token in the input string, to
621 /* The current token in the input string does not match excluded token, 623 * the ',', or just beyond the end of the input string */
622 * it must be copied to the output string */ 624 /* The current token in the input string does not match the token
625 * to exclude, it must be copied to the output string */
623 /* the current token size excluding leading whitespaces and current char */ 626 /* the current token size excluding leading whitespaces and current char */
624 copy_size = (size_t) (s1 - cur_token); 627 copy_size = (size_t) (s1 - cur_token);
625 if (buf == s2) 628 if (buf == s2)
@@ -649,7 +652,10 @@ MHD_str_remove_token_caseless_ (const char *str,
649 652
650 while ( ((size_t) (s1 - str) < str_len) && (',' != *s1)) 653 while ( ((size_t) (s1 - str) < str_len) && (',' != *s1))
651 { 654 {
652 /* 's1' points to some non-whitespace char in the token */ 655 /* 's1' points to first non-whitespace char, to some char after
656 * first non-whitespace char in the token in the input string */
657 /* Copy all non-whitespace chars from the current token in
658 * the input string */
653 while ( ((size_t) (s1 - str) < str_len) && 659 while ( ((size_t) (s1 - str) < str_len) &&
654 (',' != *s1) && (' ' != *s1) && ('\t' != *s1) ) 660 (',' != *s1) && (' ' != *s1) && ('\t' != *s1) )
655 { 661 {
@@ -668,7 +674,8 @@ MHD_str_remove_token_caseless_ (const char *str,
668 s1++; 674 s1++;
669 675
670 /* 's1' points to the first non-whitespace char in the input string 676 /* 's1' points to the first non-whitespace char in the input string
671 * after whitespace chars or just beyond the end of the input string */ 677 * after whitespace chars, to the ',', or just beyond the end of
678 * the input string */
672 if (((size_t) (s1 - str) < str_len) && (',' != *s1)) 679 if (((size_t) (s1 - str) < str_len) && (',' != *s1))
673 { /* Not the end of the current token */ 680 { /* Not the end of the current token */
674 if (buf + *buf_size <= s2) /* '<= s2' equals '< s2 + 1' */ 681 if (buf + *buf_size <= s2) /* '<= s2' equals '< s2 + 1' */