|
22 | 22 |
|
23 | 23 | #include <assert.h>
|
24 | 24 | #include <math.h>
|
| 25 | +#include <wctype.h> |
25 | 26 |
|
26 | 27 | #define ARRLEN(x) (sizeof(x)/sizeof(x[0]))
|
27 | 28 | #define MAX(x, y) ((x) > (y) ? (x) : (y))
|
@@ -1009,11 +1010,33 @@ static bool handle_code_panel_key_press(void) {
|
1009 | 1010 | return false;
|
1010 | 1011 | }
|
1011 | 1012 |
|
| 1013 | +static bool search_string(char* str, char* substr) { |
| 1014 | + if (*substr == 0) return true; |
| 1015 | + |
| 1016 | + int next_ch, next_subch, cur_ch, cur_subch; |
| 1017 | + char* cur_substr = substr; |
| 1018 | + char* cur_str = str; |
| 1019 | + |
| 1020 | + while (*cur_str != 0 && *cur_substr != 0) { |
| 1021 | + cur_ch = GetCodepointNext(cur_str, &next_ch); |
| 1022 | + cur_subch = GetCodepointNext(cur_substr, &next_subch); |
| 1023 | + |
| 1024 | + if (towlower(cur_ch) == towlower(cur_subch)) { |
| 1025 | + cur_substr += next_subch; |
| 1026 | + cur_str += next_ch; |
| 1027 | + } else { |
| 1028 | + if (cur_substr == substr) cur_str += next_ch; |
| 1029 | + cur_substr = substr; |
| 1030 | + } |
| 1031 | + } |
| 1032 | + return *cur_substr == 0; |
| 1033 | +} |
| 1034 | + |
1012 | 1035 | static bool search_blockdef(ScrBlockdef* blockdef) {
|
1013 |
| - if (strcasestr(blockdef->id, search_list_search)) return true; |
| 1036 | + if (search_string(blockdef->id, search_list_search)) return true; |
1014 | 1037 | for (size_t i = 0; i < vector_size(blockdef->inputs); i++) {
|
1015 | 1038 | if (blockdef->inputs[i].type != INPUT_TEXT_DISPLAY) continue;
|
1016 |
| - if (strcasestr(blockdef->inputs[i].data.text, search_list_search)) return true; |
| 1039 | + if (search_string(blockdef->inputs[i].data.text, search_list_search)) return true; |
1017 | 1040 | }
|
1018 | 1041 | return false;
|
1019 | 1042 | }
|
|
0 commit comments