mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-23 05:11:35 +03:00
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.)
This commit is contained in:
parent
e38e2c634b
commit
85844ee6ef
@ -594,8 +594,7 @@ char *mbstrcasestr(const char *haystack, const char *needle)
|
|||||||
|
|
||||||
for (; *haystack != '\0' && haystack_len >= needle_len;
|
for (; *haystack != '\0' && haystack_len >= needle_len;
|
||||||
haystack += move_mbright(haystack, 0), haystack_len--) {
|
haystack += move_mbright(haystack, 0), haystack_len--) {
|
||||||
if (mbstrncasecmp(haystack, needle, needle_len) == 0 &&
|
if (mbstrncasecmp(haystack, needle, needle_len) == 0)
|
||||||
mblen(haystack, MB_CUR_MAX) > 0)
|
|
||||||
return (char *)haystack;
|
return (char *)haystack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -687,8 +686,7 @@ char *mbrevstrcasestr(const char *haystack, const char *needle, const
|
|||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
if (rev_start_len >= needle_len &&
|
if (rev_start_len >= needle_len &&
|
||||||
mbstrncasecmp(rev_start, needle, needle_len) == 0 &&
|
mbstrncasecmp(rev_start, needle, needle_len) == 0)
|
||||||
mblen(rev_start, MB_CUR_MAX) > 0)
|
|
||||||
return (char *)rev_start;
|
return (char *)rev_start;
|
||||||
|
|
||||||
/* If we've reached the head of the haystack, we found nothing. */
|
/* If we've reached the head of the haystack, we found nothing. */
|
||||||
|
Loading…
Reference in New Issue
Block a user