diff -urp mc-4.7.5.4/lib/search/internal.h mc-4.7.5.4.new/lib/search/internal.h
old
|
new
|
GString *mc_search__toupper_case_str (co |
57 | 57 | |
58 | 58 | void mc_search__cond_struct_new_init_regex (const char *, mc_search_t *, mc_search_cond_t *); |
59 | 59 | |
60 | | gboolean mc_search__run_regex (mc_search_t *, const void *, gsize, gsize, gsize *); |
| 60 | long mc_search__run_regex (mc_search_t *, const void *, gsize, gsize, gsize *); |
61 | 61 | |
62 | 62 | GString *mc_search_regex_prepare_replace_str (mc_search_t *, GString *); |
63 | 63 | |
… |
… |
GString *mc_search_regex_prepare_replace |
65 | 65 | |
66 | 66 | void mc_search__cond_struct_new_init_normal (const char *, mc_search_t *, mc_search_cond_t *); |
67 | 67 | |
68 | | gboolean mc_search__run_normal (mc_search_t *, const void *, gsize, gsize, gsize *); |
| 68 | long mc_search__run_normal (mc_search_t *, const void *, gsize, gsize, gsize *); |
69 | 69 | |
70 | 70 | GString *mc_search_normal_prepare_replace_str (mc_search_t *, GString *); |
71 | 71 | |
diff -urp mc-4.7.5.4/lib/search/normal.c mc-4.7.5.4.new/lib/search/normal.c
old
|
new
|
mc_search__cond_struct_new_init_normal ( |
108 | 108 | |
109 | 109 | /* --------------------------------------------------------------------------------------------- */ |
110 | 110 | |
111 | | gboolean |
| 111 | long |
112 | 112 | mc_search__run_normal (mc_search_t * lc_mc_search, const void *user_data, |
113 | 113 | gsize start_search, gsize end_search, gsize * found_len) |
114 | 114 | { |
diff -urp mc-4.7.5.4/lib/search/regex.c mc-4.7.5.4.new/lib/search/regex.c
old
|
new
|
mc_search__cond_struct_new_init_regex (c |
576 | 576 | |
577 | 577 | /* --------------------------------------------------------------------------------------------- */ |
578 | 578 | |
579 | | gboolean |
| 579 | long |
580 | 580 | mc_search__run_regex (mc_search_t * lc_mc_search, const void *user_data, |
581 | 581 | gsize start_search, gsize end_search, gsize * found_len) |
582 | 582 | { |
… |
… |
mc_search__run_regex (mc_search_t * lc_m |
584 | 584 | int current_chr = 0; |
585 | 585 | gint start_pos; |
586 | 586 | gint end_pos; |
| 587 | ulong lines = 0; |
587 | 588 | |
588 | 589 | if (lc_mc_search->regex_buffer != NULL) |
589 | 590 | g_string_free (lc_mc_search->regex_buffer, TRUE); |
… |
… |
mc_search__run_regex (mc_search_t * lc_m |
615 | 616 | g_string_append_c (lc_mc_search->regex_buffer, (char) current_chr); |
616 | 617 | |
617 | 618 | |
618 | | if (current_chr == 0 || (char) current_chr == '\n') |
| 619 | if (current_chr == 0 || (char) current_chr == '\n') { |
| 620 | lines++; |
619 | 621 | break; |
| 622 | } |
620 | 623 | |
621 | 624 | if (virtual_pos > end_search) |
622 | 625 | break; |
… |
… |
mc_search__run_regex (mc_search_t * lc_m |
649 | 652 | if (found_len) |
650 | 653 | *found_len = end_pos - start_pos; |
651 | 654 | lc_mc_search->normal_offset = lc_mc_search->start_buffer + start_pos; |
652 | | return TRUE; |
| 655 | return 1+lines; |
653 | 656 | case COND__NOT_ALL_FOUND: |
654 | 657 | break; |
655 | 658 | default: |
656 | 659 | g_string_free (lc_mc_search->regex_buffer, TRUE); |
657 | 660 | lc_mc_search->regex_buffer = NULL; |
658 | | return FALSE; |
| 661 | return 0; |
659 | 662 | } |
660 | 663 | if ((lc_mc_search->update_fn != NULL) && |
661 | 664 | ((lc_mc_search->update_fn) (user_data, current_pos) == MC_SEARCH_CB_ABORT)) |
… |
… |
mc_search__run_regex (mc_search_t * lc_m |
673 | 676 | else |
674 | 677 | lc_mc_search->error_str = NULL; |
675 | 678 | |
676 | | return FALSE; |
| 679 | return 1-lines; |
677 | 680 | } |
678 | 681 | |
679 | 682 | /* --------------------------------------------------------------------------------------------- */ |
diff -urp mc-4.7.5.4/lib/search/search.c mc-4.7.5.4.new/lib/search/search.c
old
|
new
|
mc_search_prepare (mc_search_t * lc_mc_s |
232 | 232 | |
233 | 233 | /* --------------------------------------------------------------------------------------------- */ |
234 | 234 | |
235 | | gboolean |
| 235 | long |
236 | 236 | mc_search_run (mc_search_t * lc_mc_search, const void *user_data, |
237 | 237 | gsize start_search, gsize end_search, gsize * found_len) |
238 | 238 | { |
239 | | gboolean ret = FALSE; |
240 | | |
| 239 | long ret = 0; |
241 | 240 | if (!lc_mc_search) |
242 | | return FALSE; |
| 241 | return 0; |
243 | 242 | if (!mc_search_is_type_avail (lc_mc_search->search_type)) |
244 | 243 | { |
245 | 244 | lc_mc_search->error = MC_SEARCH_E_INPUT; |
246 | 245 | lc_mc_search->error_str = g_strdup (_(STR_E_UNKNOWN_TYPE)); |
247 | | return FALSE; |
| 246 | return 0; |
248 | 247 | } |
249 | 248 | #ifdef SEARCH_TYPE_GLIB |
250 | 249 | if (lc_mc_search->regex_match_info) |
… |
… |
mc_search_run (mc_search_t * lc_mc_searc |
259 | 258 | lc_mc_search->error_str = NULL; |
260 | 259 | |
261 | 260 | if ((lc_mc_search->conditions == NULL) && !mc_search_prepare (lc_mc_search)) |
262 | | return FALSE; |
| 261 | return 0; |
263 | 262 | |
264 | 263 | switch (lc_mc_search->search_type) |
265 | 264 | { |
diff -urp mc-4.7.5.4/lib/search.h mc-4.7.5.4.new/lib/search.h
old
|
new
|
void mc_search_free (mc_search_t * lc_mc |
127 | 127 | |
128 | 128 | gboolean mc_search_prepare (mc_search_t * mc_search); |
129 | 129 | |
130 | | gboolean mc_search_run (mc_search_t * mc_search, const void *user_data, gsize start_search, |
| 130 | long mc_search_run (mc_search_t * mc_search, const void *user_data, gsize start_search, |
131 | 131 | gsize end_search, gsize * found_len); |
132 | 132 | |
133 | 133 | gboolean mc_search_is_type_avail (mc_search_type_t); |
diff -urp mc-4.7.5.4/src/viewer/search.c mc-4.7.5.4.new/src/viewer/search.c
old
|
new
|
mcview_search_update_steps (mcview_t * v |
76 | 76 | /* --------------------------------------------------------------------------------------------- */ |
77 | 77 | |
78 | 78 | static gboolean |
79 | | mcview_find (mcview_t * view, gsize search_start, gsize * len) |
| 79 | mcview_find (mcview_t * view, gsize search_start, gsize * len, gboolean secondPass) |
80 | 80 | { |
81 | 81 | gsize search_end; |
| 82 | long skip_lines; |
82 | 83 | |
83 | 84 | view->search_numNeedSkipChar = 0; |
84 | 85 | search_cb_char_curr_index = -1; |
… |
… |
mcview_find (mcview_t * view, gsize sear |
95 | 96 | && mc_search_is_fixed_search_str (view->search)) |
96 | 97 | search_end = search_start + view->search->original_len; |
97 | 98 | |
98 | | if (mc_search_run (view->search, (void *) view, search_start, search_end, len) |
| 99 | skip_lines = mc_search_run (view->search, (void *) view, search_start, search_end, len); |
| 100 | if (skip_lines |
99 | 101 | && view->search->normal_offset == (off_t) search_start) |
100 | 102 | { |
101 | 103 | if (view->text_nroff_mode) |
102 | 104 | view->search->normal_offset++; |
| 105 | view->dpy_start_line-=skip_lines; |
103 | 106 | return TRUE; |
104 | 107 | } |
105 | 108 | |
… |
… |
mcview_find (mcview_t * view, gsize sear |
111 | 114 | view->search_nroff_seq->index = search_start; |
112 | 115 | mcview_nroff_seq_info (view->search_nroff_seq); |
113 | 116 | |
114 | | return mc_search_run (view->search, (void *) view, search_start, mcview_get_filesize (view), |
| 117 | skip_lines = mc_search_run (view->search, (void *) view, search_start, mcview_get_filesize (view), |
115 | 118 | len); |
| 119 | if (skip_lines>1) { |
| 120 | view->dpy_start_line+=skip_lines-2; |
| 121 | if(secondPass && view->dpy_lines_status != -1) view->dpy_start_line-=view->dpy_lines_total-view->dpy_visible_lines; |
| 122 | if(secondPass && view->dpy_lines_status == -1) { view->dpy_start_line+=view->dpy_visible_lines; view->dpy_lines_status = 0; } |
| 123 | return TRUE; |
| 124 | } |
| 125 | if (view->dpy_lines_status==0) { |
| 126 | view->dpy_lines_total=view->dpy_start_line-skip_lines; |
| 127 | view->dpy_lines_status=1; |
| 128 | } else if (view->dpy_lines_status==-1 && view->dpy_lines_total<-skip_lines) { |
| 129 | view->dpy_lines_total=-skip_lines; |
| 130 | } |
| 131 | return FALSE; |
116 | 132 | } |
117 | 133 | |
118 | 134 | /* --------------------------------------------------------------------------------------------- */ |
… |
… |
mcview_do_search (mcview_t * view) |
247 | 263 | off_t search_start = 0; |
248 | 264 | gboolean isFound = FALSE; |
249 | 265 | gboolean need_search_again = TRUE; |
| 266 | long saved_lines_total = view->dpy_lines_total; |
250 | 267 | |
251 | 268 | Dlg_head *d = NULL; |
252 | 269 | |
… |
… |
mcview_do_search (mcview_t * view) |
293 | 310 | /* Compute the percent steps */ |
294 | 311 | mcview_search_update_steps (view); |
295 | 312 | view->update_activate = 0; |
| 313 | // view->dpy_visible_lines = 0; // mcview_search_show_result -> destroy_dlg sets lines_total as start_line (already calculated) + visible_lines (currently shown) |
296 | 314 | |
297 | 315 | tty_enable_interrupt_key (); |
298 | 316 | |
… |
… |
mcview_do_search (mcview_t * view) |
305 | 323 | else |
306 | 324 | growbufsize = view->search->original_len; |
307 | 325 | |
308 | | if (mcview_find (view, search_start, &match_len)) |
| 326 | if (mcview_find (view, search_start, &match_len, FALSE)) |
309 | 327 | { |
310 | 328 | mcview_search_show_result (view, &d, match_len); |
311 | 329 | need_search_again = FALSE; |
… |
… |
mcview_do_search (mcview_t * view) |
336 | 354 | query_dialog (_("Search done"), _("Continue from beginning?"), D_NORMAL, 2, _("&Yes"), |
337 | 355 | _("&No")); |
338 | 356 | |
339 | | if (result != 0) |
| 357 | if (result != 0) { |
| 358 | saved_lines_total=view->dpy_lines_total; |
340 | 359 | isFound = TRUE; |
341 | | else |
| 360 | } |
| 361 | else { |
342 | 362 | search_start = 0; |
| 363 | if (view->dpy_lines_status == -1) { |
| 364 | // view->dpy_lines_status = 0; |
| 365 | // view->dpy_lines_total = saved_lines_total; // for mcview_find below |
| 366 | } |
| 367 | } |
343 | 368 | } |
344 | 369 | |
345 | | if (!isFound && view->search->error_str != NULL && mcview_find (view, search_start, &match_len)) |
| 370 | if (!isFound && view->search->error_str != NULL) { if(mcview_find (view, search_start, &match_len, TRUE)) |
346 | 371 | { |
347 | 372 | mcview_search_show_result (view, &d, match_len); |
348 | 373 | isFound = TRUE; |
349 | | } |
| 374 | } else { |
| 375 | saved_lines_total=view->dpy_lines_total; |
| 376 | if(view->dpy_lines_status==-1) { |
| 377 | view->dpy_lines_status=1; |
| 378 | view->dpy_start_line+=view->dpy_lines_total; |
| 379 | } |
| 380 | }} |
350 | 381 | |
351 | 382 | if (!isFound && view->search->error_str != NULL) |
352 | 383 | message (D_NORMAL, _("Search"), "%s", view->search->error_str); |
353 | 384 | |
354 | 385 | view->dirty++; |
| 386 | view->dpy_lines_total = saved_lines_total; |
355 | 387 | mcview_update (view); |
356 | 388 | |
357 | 389 | tty_disable_interrupt_key (); |