--- src/search.c +++ src/search.c @@ -140,7 +140,7 @@ kwsmusts (void) are not single byte character nor the first byte of a multibyte character. Caller must free the array. */ static char* -check_multibyte_string(char const *buf, size_t size) +check_multibyte_string(char const *buf, size_t size, int case_convert) { char *mb_properties = xmalloc(size); mbstate_t cur_state; @@ -161,7 +161,7 @@ check_multibyte_string(char const *buf, We treat it as a single byte character. */ mbclen = 1; } - else if (match_icase) + else if (case_convert) { if (iswupper((wint_t)wc)) { @@ -327,9 +327,9 @@ EXECUTE_FCT(EGexecute) if (start_ptr) start_ptr = case_buf + (start_ptr - buf); buf = case_buf; + if (kwset) + mb_properties = check_multibyte_string(buf, size, 1); } - if (kwset) - mb_properties = check_multibyte_string(buf, size); } #endif /* MBS_SUPPORT */ @@ -352,8 +352,13 @@ EXECUTE_FCT(EGexecute) end = memchr(beg, eol, buflim - beg); end++; #ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1 && mb_properties[beg - buf] == 0) - continue; + if (MB_CUR_MAX > 1) + { + if (!mb_properties) + mb_properties = check_multibyte_string (buf, size, 0); + if (mb_properties[beg - buf] == 0) + continue; + } #endif while (beg > buf && beg[-1] != eol) --beg; @@ -543,8 +548,8 @@ EXECUTE_FCT(Fexecute) if (start_ptr) start_ptr = case_buf + (start_ptr - buf); buf = case_buf; + mb_properties = check_multibyte_string(buf, size, 1); } - mb_properties = check_multibyte_string(buf, size); } #endif /* MBS_SUPPORT */ @@ -554,8 +559,13 @@ EXECUTE_FCT(Fexecute) if (offset == (size_t) -1) goto failure; #ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1 && mb_properties[offset+beg-buf] == 0) - continue; /* It is a part of multibyte character. */ + if (MB_CUR_MAX > 1) + { + if (!mb_properties) + mb_properties = check_multibyte_string(buf, size, 0); + if (mb_properties[offset+beg-buf] == 0) + continue; /* It is a part of multibyte character. */ + } #endif /* MBS_SUPPORT */ beg += offset; len = kwsmatch.size[0];