diff options
-rw-r--r-- | editors/vi.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/editors/vi.c b/editors/vi.c index 51dfc1209..1dd0b6fb6 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -2251,7 +2251,6 @@ static char *get_one_address(char *p, int *addr) // get colon addr, if present | |||
2251 | int st; | 2251 | int st; |
2252 | char *q; | 2252 | char *q; |
2253 | IF_FEATURE_VI_YANKMARK(char c;) | 2253 | IF_FEATURE_VI_YANKMARK(char c;) |
2254 | IF_FEATURE_VI_SEARCH(char *pat;) | ||
2255 | 2254 | ||
2256 | *addr = -1; // assume no addr | 2255 | *addr = -1; // assume no addr |
2257 | if (*p == '.') { // the current line | 2256 | if (*p == '.') { // the current line |
@@ -2276,16 +2275,20 @@ static char *get_one_address(char *p, int *addr) // get colon addr, if present | |||
2276 | #endif | 2275 | #endif |
2277 | #if ENABLE_FEATURE_VI_SEARCH | 2276 | #if ENABLE_FEATURE_VI_SEARCH |
2278 | else if (*p == '/') { // a search pattern | 2277 | else if (*p == '/') { // a search pattern |
2279 | q = strchrnul(++p, '/'); | 2278 | q = strchrnul(p + 1, '/'); |
2280 | pat = xstrndup(p, q - p); // save copy of pattern | 2279 | if (p + 1 != q) { |
2280 | // save copy of new pattern | ||
2281 | free(last_search_pattern); | ||
2282 | last_search_pattern = xstrndup(p, q - p); | ||
2283 | } | ||
2281 | p = q; | 2284 | p = q; |
2282 | if (*p == '/') | 2285 | if (*p == '/') |
2283 | p++; | 2286 | p++; |
2284 | q = char_search(dot, pat, (FORWARD << 1) | FULL); | 2287 | q = char_search(next_line(dot), last_search_pattern + 1, |
2288 | (FORWARD << 1) | FULL); | ||
2285 | if (q != NULL) { | 2289 | if (q != NULL) { |
2286 | *addr = count_lines(text, q); | 2290 | *addr = count_lines(text, q); |
2287 | } | 2291 | } |
2288 | free(pat); | ||
2289 | } | 2292 | } |
2290 | #endif | 2293 | #endif |
2291 | else if (*p == '$') { // the last line in file | 2294 | else if (*p == '$') { // the last line in file |