mirror of
https://github.com/sheumann/hush.git
synced 2024-09-12 00:55:11 +00:00
vi: fix uninitialized last_search_pattern (bug 5794)
This commit is contained in:
parent
34e68c8b42
commit
c3a9dc8ac5
15
editors/vi.c
15
editors/vi.c
@ -270,6 +270,7 @@ struct globals {
|
|||||||
#define INIT_G() do { \
|
#define INIT_G() do { \
|
||||||
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
|
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
|
||||||
last_file_modified = -1; \
|
last_file_modified = -1; \
|
||||||
|
last_search_pattern = xzalloc(2); /* "" but has space for 2 chars */ \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
@ -2857,7 +2858,7 @@ static void do_cmd(int c)
|
|||||||
const char *msg = msg; // for compiler
|
const char *msg = msg; // for compiler
|
||||||
char *p, *q, *save_dot;
|
char *p, *q, *save_dot;
|
||||||
char buf[12];
|
char buf[12];
|
||||||
int dir = dir; // for compiler
|
int dir;
|
||||||
int cnt, i, j;
|
int cnt, i, j;
|
||||||
int c1;
|
int c1;
|
||||||
|
|
||||||
@ -3196,7 +3197,7 @@ static void do_cmd(int c)
|
|||||||
q = get_input_line(buf); // get input line- use "status line"
|
q = get_input_line(buf); // get input line- use "status line"
|
||||||
if (q[0] && !q[1]) {
|
if (q[0] && !q[1]) {
|
||||||
if (last_search_pattern[0])
|
if (last_search_pattern[0])
|
||||||
last_search_pattern[0] = c;
|
last_search_pattern[0] = c;
|
||||||
goto dc3; // if no pat re-use old pat
|
goto dc3; // if no pat re-use old pat
|
||||||
}
|
}
|
||||||
if (q[0]) { // strlen(q) > 1: new pat- save it and find
|
if (q[0]) { // strlen(q) > 1: new pat- save it and find
|
||||||
@ -3226,14 +3227,8 @@ static void do_cmd(int c)
|
|||||||
do_cmd(c);
|
do_cmd(c);
|
||||||
} // repeat cnt
|
} // repeat cnt
|
||||||
dc3:
|
dc3:
|
||||||
if (last_search_pattern == 0) {
|
dir = FORWARD; // assume FORWARD search
|
||||||
msg = "No previous regular expression";
|
p = dot + 1;
|
||||||
goto dc2;
|
|
||||||
}
|
|
||||||
if (last_search_pattern[0] == '/') {
|
|
||||||
dir = FORWARD; // assume FORWARD search
|
|
||||||
p = dot + 1;
|
|
||||||
}
|
|
||||||
if (last_search_pattern[0] == '?') {
|
if (last_search_pattern[0] == '?') {
|
||||||
dir = BACK;
|
dir = BACK;
|
||||||
p = dot - 1;
|
p = dot - 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user