mirror of https://github.com/MidnightCommander/mc
Ticket #2231: fixup of replacement algorithm in mcedit.
Type accuracy. Removed unused variables. Removed double assignment. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
b341645369
commit
d2aad0716b
|
@ -1685,8 +1685,7 @@ edit_replace_cmd (WEdit * edit, int again)
|
|||
char *input2 = NULL;
|
||||
char *disp1 = NULL;
|
||||
char *disp2 = NULL;
|
||||
int replace_yes;
|
||||
long times_replaced = 0, last_search;
|
||||
long times_replaced = 0;
|
||||
gboolean once_found = FALSE;
|
||||
|
||||
if (!edit)
|
||||
|
@ -1696,8 +1695,6 @@ edit_replace_cmd (WEdit * edit, int again)
|
|||
return;
|
||||
}
|
||||
|
||||
last_search = edit->last_byte;
|
||||
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
|
||||
if (again && !saved1 && !saved2)
|
||||
|
@ -1770,7 +1767,6 @@ edit_replace_cmd (WEdit * edit, int again)
|
|||
do
|
||||
{
|
||||
gsize len = 0;
|
||||
long new_start;
|
||||
|
||||
if (!editcmd_find (edit, &len))
|
||||
{
|
||||
|
@ -1782,13 +1778,14 @@ edit_replace_cmd (WEdit * edit, int again)
|
|||
break;
|
||||
}
|
||||
once_found = TRUE;
|
||||
new_start = edit->search->normal_offset;
|
||||
|
||||
edit->search_start = new_start = edit->search->normal_offset;
|
||||
edit->search_start = edit->search->normal_offset;
|
||||
/*returns negative on not found or error in pattern */
|
||||
|
||||
if (edit->search_start >= 0)
|
||||
{
|
||||
gboolean replace_yes;
|
||||
|
||||
guint i;
|
||||
|
||||
edit->found_start = edit->search_start;
|
||||
|
@ -1797,7 +1794,7 @@ edit_replace_cmd (WEdit * edit, int again)
|
|||
edit_cursor_move (edit, edit->search_start - edit->curs1);
|
||||
edit_scroll_screen_over_cursor (edit);
|
||||
|
||||
replace_yes = 1;
|
||||
replace_yes = TRUE;
|
||||
|
||||
if (edit->replace_mode == 0)
|
||||
{
|
||||
|
@ -1820,22 +1817,23 @@ edit_replace_cmd (WEdit * edit, int again)
|
|||
switch (editcmd_dialog_replace_prompt_show (edit, disp1, disp2, -1, -1))
|
||||
{
|
||||
case B_ENTER:
|
||||
replace_yes = 1;
|
||||
replace_yes = TRUE;
|
||||
break;
|
||||
case B_SKIP_REPLACE:
|
||||
replace_yes = 0;
|
||||
replace_yes = FALSE;
|
||||
break;
|
||||
case B_REPLACE_ALL:
|
||||
edit->replace_mode = 1;
|
||||
break;
|
||||
case B_CANCEL:
|
||||
replace_yes = 0;
|
||||
replace_yes = FALSE;
|
||||
edit->replace_mode = -1;
|
||||
break;
|
||||
}
|
||||
g_free (disp1);
|
||||
g_free (disp2);
|
||||
}
|
||||
|
||||
if (replace_yes)
|
||||
{ /* delete then insert new */
|
||||
GString *repl_str, *tmp_str;
|
||||
|
@ -1860,15 +1858,9 @@ edit_replace_cmd (WEdit * edit, int again)
|
|||
}
|
||||
/* so that we don't find the same string again */
|
||||
if (edit_search_options.backwards)
|
||||
{
|
||||
last_search = edit->search_start;
|
||||
edit->search_start--;
|
||||
}
|
||||
else
|
||||
{
|
||||
edit->search_start += i;
|
||||
last_search = edit->last_byte;
|
||||
}
|
||||
edit_scroll_screen_over_cursor (edit);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue