[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] vi: fix empty line range regression
From: Denys Vlasenko <vda.linux () googlemail ! com>
Date: 2021-04-29 23:41:07
Message-ID: CAK1hOcPPosYw4b=5ms5NjCrb5d2QFJnGMOYvbPoShzkAFOAk_A () mail ! gmail ! com
[Download RAW message or body]
Applied, thank you
On Thu, Apr 29, 2021 at 9:36 AM Ron Yorston <rmy@pobox.com> wrote:
>
> Commit 7a8ceb4eb (vi: changes to line addresses for colon commands)
> was supposed to address the issue:
>
> When the last address is empty it should refer to the current line.
>
> This was intended to allow ranges of the form '1,' with an empty
> last address. It should have been expressed as:
>
> When the last address is empty *and the second last isn't* it
> should refer to the current line.
>
> Otherwise a command like ':w' only writes the current line resulting
> in serious loss of data.
>
> function old new delta
> colon 3906 3911 +5
> ------------------------------------------------------------------------------
> (add/remove: 0/0 grow/shrink: 1/0 up/down: 5/0) Total: 5 bytes
>
> Signed-off-by: Ron Yorston <rmy@pobox.com>
> ---
> editors/vi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/editors/vi.c b/editors/vi.c
> index 6a879fa8a..edcf84240 100644
> --- a/editors/vi.c
> +++ b/editors/vi.c
> @@ -2553,7 +2553,7 @@ static char *get_address(char *p, int *b, int *e)
> break;
> state = GET_SEPARATOR;
> } else {
> - if (state == GET_SEPARATOR && *e < 0)
> + if (state == GET_SEPARATOR && *b >= 0 && *e < 0)
> *e = count_lines(text, dot);
> break;
> }
> --
> 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