clang-analyzer: Reduce scope in search.c.

This commit is contained in:
Florian Walch
2014-07-23 11:55:15 +02:00
parent 1d524ea98d
commit d80d46883e

View File

@@ -3762,16 +3762,8 @@ current_search (
int forward /* move forward or backwards */ int forward /* move forward or backwards */
) )
{ {
pos_T start_pos; /* position before the pattern */
pos_T orig_pos; /* position of the cursor at beginning */
pos_T pos; /* position after the pattern */
int i;
int dir;
int result; /* result of various function calls */
bool old_p_ws = p_ws; bool old_p_ws = p_ws;
int flags = 0;
pos_T save_VIsual = VIsual; pos_T save_VIsual = VIsual;
int one_char;
/* wrapping should not occur */ /* wrapping should not occur */
p_ws = false; p_ws = false;
@@ -3780,11 +3772,11 @@ current_search (
if (VIsual_active && *p_sel == 'e' && lt(VIsual, curwin->w_cursor)) if (VIsual_active && *p_sel == 'e' && lt(VIsual, curwin->w_cursor))
dec_cursor(); dec_cursor();
if (VIsual_active) { pos_T orig_pos; /* position of the cursor at beginning */
orig_pos = curwin->w_cursor; pos_T pos; /* position after the pattern */
pos = curwin->w_cursor; if (VIsual_active) {
start_pos = VIsual; orig_pos = pos = curwin->w_cursor;
/* make sure, searching further will extend the match */ /* make sure, searching further will extend the match */
if (VIsual_active) { if (VIsual_active) {
@@ -3794,10 +3786,10 @@ current_search (
decl(&pos); decl(&pos);
} }
} else } else
orig_pos = pos = start_pos = curwin->w_cursor; orig_pos = pos = curwin->w_cursor;
/* Is the pattern is zero-width? */ /* Is the pattern is zero-width? */
one_char = is_one_char(spats[last_idx].pat); int one_char = is_one_char(spats[last_idx].pat);
if (one_char == -1) { if (one_char == -1) {
p_ws = old_p_ws; p_ws = old_p_ws;
return FAIL; /* pattern not found */ return FAIL; /* pattern not found */
@@ -3808,17 +3800,14 @@ current_search (
* so that a match at the current cursor position will be correctly * so that a match at the current cursor position will be correctly
* captured. * captured.
*/ */
for (i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if (forward) int dir = forward ? i : !i;
dir = i; int flags = 0;
else
dir = !i;
flags = 0;
if (!dir && !one_char) if (!dir && !one_char)
flags = SEARCH_END; flags = SEARCH_END;
result = searchit(curwin, curbuf, &pos, (dir ? FORWARD : BACKWARD), int result = searchit(curwin, curbuf, &pos, (dir ? FORWARD : BACKWARD),
spats[last_idx].pat, (long) (i ? count : 1), spats[last_idx].pat, (long) (i ? count : 1),
SEARCH_KEEP | flags, RE_SEARCH, 0, NULL); SEARCH_KEEP | flags, RE_SEARCH, 0, NULL);
@@ -3845,13 +3834,13 @@ current_search (
p_ws = old_p_ws; p_ws = old_p_ws;
} }
start_pos = pos; int flags = forward ? SEARCH_END : 0;
flags = forward ? SEARCH_END : 0; pos_T start_pos = pos;
/* move to match, except for zero-width matches, in which case, we are /* move to match, except for zero-width matches, in which case, we are
* already on the next match */ * already on the next match */
if (!one_char) if (!one_char)
result = searchit(curwin, curbuf, &pos, (forward ? FORWARD : BACKWARD), searchit(curwin, curbuf, &pos, (forward ? FORWARD : BACKWARD),
spats[last_idx].pat, 0L, flags | SEARCH_KEEP, RE_SEARCH, 0, NULL); spats[last_idx].pat, 0L, flags | SEARCH_KEEP, RE_SEARCH, 0, NULL);
if (!VIsual_active) if (!VIsual_active)