[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH] ed: fix current line number for file passed via the command-line
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2021-12-19 22:16:37
Message-ID: CAK1hOcM9R5Qnvx3x3A=ZHSBBW=n_t6WwoS=ovAaBgCfNSP9q_w () mail ! gmail ! com
[Download RAW message or body]

Applied, thanks

On Wed, Nov 17, 2021 at 3:16 PM <soeren@soeren-tempel.net> wrote:
>
> From: Sören Tempel <soeren+git@soeren-tempel.net>
>
> POSIX.1-2008 mandates the following regarding the file command-line
> argument:
>
>         If the file argument is given, ed shall simulate an e command
>         on the file named by the pathname […]
>
> The specification for the e command mandates the following behaviour
> regarding the current line number in POSIX.1-2008:
>
>         The current line number shall be set to the address of the last
>         line of the buffer.
>
> However, without this commit, busybox ed will set the current line
> number to 1 if a file is given on the command-line and this file is not
> empty (lastNum != 0). This is incorrect and fixed in this commit by not
> modifying the current line number in ed_main(). As such, the current
> line number will be zero for empty files and otherwise be set to the
> address of the last line of the buffer.
>
> Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
> ---
>  editors/ed.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/editors/ed.c b/editors/ed.c
> index 14540e566..cb903bca7 100644
> --- a/editors/ed.c
> +++ b/editors/ed.c
> @@ -1010,8 +1010,6 @@ int ed_main(int argc UNUSED_PARAM, char **argv)
>                 if (!readLines(fileName, 1)) {
>                         return EXIT_SUCCESS;
>                 }
> -               if (lastNum)
> -                       setCurNum(1);
>                 dirty = FALSE;
>         }
>
> _______________________________________________
> 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