diff options
Diffstat (limited to 'editors/vi.c')
-rw-r--r-- | editors/vi.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/editors/vi.c b/editors/vi.c index 02bdbb37b..4accfdbb1 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -291,6 +291,8 @@ struct globals { | |||
291 | #define INIT_G() do { \ | 291 | #define INIT_G() do { \ |
292 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ | 292 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
293 | last_file_modified = -1; \ | 293 | last_file_modified = -1; \ |
294 | /* "" but has space for 2 chars */ \ | ||
295 | USE_FEATURE_VI_SEARCH(last_search_pattern = xzalloc(2);) \ | ||
294 | } while (0) | 296 | } while (0) |
295 | 297 | ||
296 | 298 | ||
@@ -2974,7 +2976,7 @@ static void do_cmd(char c) | |||
2974 | const char *msg = msg; // for compiler | 2976 | const char *msg = msg; // for compiler |
2975 | char c1, *p, *q, *save_dot; | 2977 | char c1, *p, *q, *save_dot; |
2976 | char buf[12]; | 2978 | char buf[12]; |
2977 | int dir = dir; // for compiler | 2979 | int dir; |
2978 | int cnt, i, j; | 2980 | int cnt, i, j; |
2979 | 2981 | ||
2980 | // c1 = c; // quiet the compiler | 2982 | // c1 = c; // quiet the compiler |
@@ -3316,7 +3318,7 @@ static void do_cmd(char c) | |||
3316 | q = get_input_line(buf); // get input line- use "status line" | 3318 | q = get_input_line(buf); // get input line- use "status line" |
3317 | if (q[0] && !q[1]) { | 3319 | if (q[0] && !q[1]) { |
3318 | if (last_search_pattern[0]) | 3320 | if (last_search_pattern[0]) |
3319 | last_search_pattern[0] = c; | 3321 | last_search_pattern[0] = c; |
3320 | goto dc3; // if no pat re-use old pat | 3322 | goto dc3; // if no pat re-use old pat |
3321 | } | 3323 | } |
3322 | if (q[0]) { // strlen(q) > 1: new pat- save it and find | 3324 | if (q[0]) { // strlen(q) > 1: new pat- save it and find |
@@ -3346,14 +3348,8 @@ static void do_cmd(char c) | |||
3346 | do_cmd(c); | 3348 | do_cmd(c); |
3347 | } // repeat cnt | 3349 | } // repeat cnt |
3348 | dc3: | 3350 | dc3: |
3349 | if (last_search_pattern == 0) { | 3351 | dir = FORWARD; // assume FORWARD search |
3350 | msg = "No previous regular expression"; | 3352 | p = dot + 1; |
3351 | goto dc2; | ||
3352 | } | ||
3353 | if (last_search_pattern[0] == '/') { | ||
3354 | dir = FORWARD; // assume FORWARD search | ||
3355 | p = dot + 1; | ||
3356 | } | ||
3357 | if (last_search_pattern[0] == '?') { | 3353 | if (last_search_pattern[0] == '?') { |
3358 | dir = BACK; | 3354 | dir = BACK; |
3359 | p = dot - 1; | 3355 | p = dot - 1; |