[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] vi: stored search pattern applies to ':s'
From: Denys Vlasenko <vda.linux () googlemail ! com>
Date: 2021-06-27 11:38:46
Message-ID: CAK1hOcN9TG0tWHwWOvxLHGDXfTTi2euc1OK0nQyhk7RJ=CUeAQ () mail ! gmail ! com
[Download RAW message or body]
Applied, thank you.
On Fri, Jun 25, 2021 at 8:33 PM Ron Yorston <rmy@pobox.com> wrote:
>
> The same stored search pattern applies to both search ('/') and
> search/replace (':s') operations.
>
> A search/replace operation with an empty "find" string (':s//abc/')
> should use the last stored search pattern, if available, and issue an
> error message if there is none.
>
> If the "find" string is not empty it should replace the stored search
> pattern.
>
> function old new delta
> colon 3952 4024 +72
> ------------------------------------------------------------------------------
> (add/remove: 0/0 grow/shrink: 1/0 up/down: 72/0) Total: 72 bytes
>
> Signed-off-by: Ron Yorston <rmy@pobox.com>
> ---
> editors/vi.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/editors/vi.c b/editors/vi.c
> index 38ce1fdf0..f0bbc9518 100644
> --- a/editors/vi.c
> +++ b/editors/vi.c
> @@ -3100,6 +3100,18 @@ static void colon(char *buf)
> }
> len_R = strlen(R);
>
> + if (len_F) { // save "find" as last search pattern
> + free(last_search_pattern);
> + last_search_pattern = xstrdup(F - 1);
> + last_search_pattern[0] = '/';
> + } else if (last_search_pattern[1] == '\0') {
> + status_line_bold("No previous search");
> + goto ret;
> + } else {
> + F = last_search_pattern + 1;
> + len_F = strlen(F);
> + }
> +
> if (e < 0) { // no addr given
> q = begin_line(dot); // start with cur line
> r = end_line(dot);
> --
> 2.31.1
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic