commit 85844ee6ef5f30bccc9cfee4a4aa332c051832ed
parent e38e2c634b0e309e86cf6aff37698bae3927013e
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 6 Aug 2016 10:47:22 +0200
chars: remove superfluous afterchecks
Now that mbstrncasecmp() does the right thing, there is no need any
more to verify that only a valid multibyte sequence was matched.
(See https://savannah.gnu.org/bugs/?45579 for a test case.)
Also, this will make it possible to search for invalid sequences.
(Currently it isn't possible to enter a search string with invalid
characters, but... a user might edit the search history file. And
if pasting at the prompt is implemented, it will be trivial to enter
invalid sequences if you have a file that contains them.)
Diffstat:
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/chars.c b/src/chars.c
@@ -594,8 +594,7 @@ char *mbstrcasestr(const char *haystack, const char *needle)
for (; *haystack != '\0' && haystack_len >= needle_len;
haystack += move_mbright(haystack, 0), haystack_len--) {
- if (mbstrncasecmp(haystack, needle, needle_len) == 0 &&
- mblen(haystack, MB_CUR_MAX) > 0)
+ if (mbstrncasecmp(haystack, needle, needle_len) == 0)
return (char *)haystack;
}
@@ -687,8 +686,7 @@ char *mbrevstrcasestr(const char *haystack, const char *needle, const
while (TRUE) {
if (rev_start_len >= needle_len &&
- mbstrncasecmp(rev_start, needle, needle_len) == 0 &&
- mblen(rev_start, MB_CUR_MAX) > 0)
+ mbstrncasecmp(rev_start, needle, needle_len) == 0)
return (char *)rev_start;
/* If we've reached the head of the haystack, we found nothing. */