mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Continue develop of search engine: simple search now worked
This commit is contained in:
parent
dac42ca7f2
commit
9db1cf46a4
@ -1920,7 +1920,7 @@ void edit_search_cmd (WEdit * edit, int again)
|
|||||||
else
|
else
|
||||||
edit->search->search_type = MC_SEARCH_T_NORMAL;
|
edit->search->search_type = MC_SEARCH_T_NORMAL;
|
||||||
|
|
||||||
edit->search->is_case_sentitive = (!replace_case);
|
edit->search->is_case_sentitive = (replace_case);
|
||||||
edit->search->search_fn = edit_search_cmd_callback;
|
edit->search->search_fn = edit_search_cmd_callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
src/search.c
15
src/search.c
@ -153,18 +153,10 @@ mc_search__cond_struct_new (const char *str, guint str_len, const char *charset,
|
|||||||
mc_search_cond->str = g_string_new_len (str, str_len);
|
mc_search_cond->str = g_string_new_len (str, str_len);
|
||||||
mc_search_cond->len = str_len;
|
mc_search_cond->len = str_len;
|
||||||
mc_search_cond->charset = g_strdup (charset);
|
mc_search_cond->charset = g_strdup (charset);
|
||||||
if (case_sentitive) {
|
if (!case_sentitive) {
|
||||||
mc_search_cond->upper = mc_search__toupper_case_str (charset, str, str_len);
|
mc_search_cond->upper = mc_search__toupper_case_str (charset, str, str_len);
|
||||||
mc_search_cond->lower = mc_search__tolower_case_str (charset, str, str_len);
|
mc_search_cond->lower = mc_search__tolower_case_str (charset, str, str_len);
|
||||||
}
|
}
|
||||||
char *up, *lo;
|
|
||||||
up = (mc_search_cond->upper) ? mc_search_cond->upper->str: "(null)";
|
|
||||||
lo = (mc_search_cond->lower) ? mc_search_cond->lower->str: "(null)";
|
|
||||||
mc_log("\
|
|
||||||
mc_search_cond->str = %s\n\
|
|
||||||
mc_search_cond->upper = %s\n\
|
|
||||||
mc_search_cond->lower = %s\n\
|
|
||||||
\n",mc_search_cond->str->str, up, lo);
|
|
||||||
return mc_search_cond;
|
return mc_search_cond;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +255,7 @@ mc_search__normal_found_cond (mc_search_t * mc_search, int current_chr, gsize se
|
|||||||
for (loop1 = 0; loop1 < mc_search->conditions->len; loop1++) {
|
for (loop1 = 0; loop1 < mc_search->conditions->len; loop1++) {
|
||||||
mc_search_cond = (mc_search_cond_t *) g_ptr_array_index (mc_search->conditions, loop1);
|
mc_search_cond = (mc_search_cond_t *) g_ptr_array_index (mc_search->conditions, loop1);
|
||||||
|
|
||||||
if (search_pos > mc_search_cond->len)
|
if (search_pos > mc_search_cond->len-1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (mc_search->is_case_sentitive) {
|
if (mc_search->is_case_sentitive) {
|
||||||
@ -278,7 +270,7 @@ mc_search__normal_found_cond (mc_search_t * mc_search, int current_chr, gsize se
|
|||||||
if (((char) current_chr == upp->str[search_pos])
|
if (((char) current_chr == upp->str[search_pos])
|
||||||
|| ((char) current_chr == low->str[search_pos]))
|
|| ((char) current_chr == low->str[search_pos]))
|
||||||
return (search_pos ==
|
return (search_pos ==
|
||||||
mc_search_cond->len) ? COND__FOUND_CHAR_LAST : COND__FOUND_CHAR;
|
mc_search_cond->len-1) ? COND__FOUND_CHAR_LAST : COND__FOUND_CHAR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return COND__NOT_ALL_FOUND;
|
return COND__NOT_ALL_FOUND;
|
||||||
@ -311,7 +303,6 @@ mc_search__run_normal (mc_search_t * mc_search, const void *user_data,
|
|||||||
if (current_chr == -1)
|
if (current_chr == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
switch (mc_search__normal_found_cond (mc_search, current_chr, search_pos)) {
|
switch (mc_search__normal_found_cond (mc_search, current_chr, search_pos)) {
|
||||||
|
|
||||||
case COND__NOT_ALL_FOUND:
|
case COND__NOT_ALL_FOUND:
|
||||||
|
Loading…
Reference in New Issue
Block a user