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

List:       busybox
Subject:    Re: [PATCH] ed: align output of write command with POSIX-1.2008
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2021-10-12 15:33:35
Message-ID: CAK1hOcOzgE_Qdx2ZShwABwB4NBh-URGR_V5OdM_qoP4p+2TUqw () mail ! gmail ! com
[Download RAW message or body]

Applied, thank you!

On Sat, Jul 17, 2021 at 9:46 PM <soeren@soeren-tempel.net> wrote:
>
> From: Sören Tempel <soeren+git@soeren-tempel.net>
>
> POSIX.1-2008 mandates the following regarding the write command:
>
>         If the command is successful, the number of bytes written shall
>         be written to standard output, unless the -s option was
>         specified, in the following format:
>
>                 "%d\n", <number of bytes written>
>
> Presently, busybox does not use this specified format, the patch
> proposed here aligns the output format with POSIX.1-2008. I was unable
> to infer from git-blame(1) why this deviation from the standard was
> added in the first please, though I am aware that busybox ed is not
> POSIX compatible anyhow in its present form. For instance, it does also
> not support the aforementioned -s option. The difference in output
> behavior of the write command is just one deviation from the POSIX
> standard I just happend to came across. If you are not striving toward
> making busybox ed compatible with POSIX anyhow, please let me know.
> ---
>  editors/ed.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/editors/ed.c b/editors/ed.c
> index c50faeefa..3b54f274b 100644
> --- a/editors/ed.c
> +++ b/editors/ed.c
> @@ -468,12 +468,11 @@ static int readLines(const char *file, int num)
>  static int writeLines(const char *file, int num1, int num2)
>  {
>         LINE *lp;
> -       int fd, lineCount, charCount;
> +       int fd, charCount;
>
>         if (bad_nums(num1, num2, "write"))
>                 return FALSE;
>
> -       lineCount = 0;
>         charCount = 0;
>
>         fd = creat(file, 0666);
> @@ -482,9 +481,6 @@ static int writeLines(const char *file, int num1, int num2)
>                 return FALSE;
>         }
>
> -       printf("\"%s\", ", file);
> -       fflush_all();
> -
>         lp = findLine(num1);
>         if (lp == NULL) {
>                 close(fd);
> @@ -498,7 +494,6 @@ static int writeLines(const char *file, int num1, int num2)
>                         return FALSE;
>                 }
>                 charCount += lp->len;
> -               lineCount++;
>                 lp = lp->next;
>         }
>
> @@ -507,7 +502,7 @@ static int writeLines(const char *file, int num1, int num2)
>                 return FALSE;
>         }
>
> -       printf("%d lines, %d chars\n", lineCount, charCount);
> +       printf("%d\n", charCount);
>         return TRUE;
>  }
>
> _______________________________________________
> 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