From: Sören Tempel <[email protected]>

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
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to