PING.

I think this is a fairly obvious POSIX compliance issue with an easy fix.

Sören Tempel <[email protected]> wrote:
> Hello,
> 
> Currently, the OpenBSD ed implementation incorrectly writes information
> to standard error that should be written to standard out (as per POSIX).
> 
> For the read and write command the POSIX standard states the following:
> 
>       If the command is successful, the number of bytes written shall
>       be written to standard output [...]
> 
> However, OpenBSD ed presently writes the number of bytes (for both the
> read and the write command) to standard error. Furthermore, the POSIX
> standard mandates that the infamous "?\n" error string should also be
> written to standard output while OpenBSD ed presently writes the string
> to standard error.
> 
> Both cases are fixed by the patch below.
> 
> OK?
> 
> diff --git bin/ed/io.c bin/ed/io.c
> index 97306be16..e75bedd8b 100644
> --- bin/ed/io.c
> +++ bin/ed/io.c
> @@ -64,7 +64,7 @@ read_file(char *fn, int n)
>               return ERR;
>       }
>       if (!scripted)
> -             fprintf(stderr, "%d\n", size);
> +             printf("%d\n", size);
>       return current_addr - n;
>  }
>  
> @@ -166,7 +166,7 @@ write_file(char *fn, char *mode, int n, int m)
>               return ERR;
>       }
>       if (!scripted)
> -             fprintf(stderr, "%d\n", size);
> +             printf("%d\n", size);
>       return n ? m - n + 1 : 0;
>  }
>  
> diff --git bin/ed/main.c bin/ed/main.c
> index 231d021ef..674741c7c 100644
> --- bin/ed/main.c
> +++ bin/ed/main.c
> @@ -184,7 +184,7 @@ top:
>       signal(SIGINT, signal_int);
>       if (sigsetjmp(env, 1)) {
>               status = -1;
> -             fputs("\n?\n", stderr);
> +             fputs("\n?\n", stdout);
>               seterrmsg("interrupt");
>       } else {
>               init_buffers();
> @@ -196,7 +196,7 @@ top:
>                               strlcpy(old_filename, *argv,
>                                   sizeof old_filename);
>               } else if (argc) {
> -                     fputs("?\n", stderr);
> +                     fputs("?\n", stdout);
>                       if (**argv == '\0')
>                               seterrmsg("invalid filename");
>                       if (!interactive)
> @@ -215,7 +215,7 @@ top:
>                       continue;
>               } else if (n == 0) {
>                       if (modified && !scripted) {
> -                             fputs("?\n", stderr);
> +                             fputs("?\n", stdout);
>                               seterrmsg("warning: file modified");
>                               if (!interactive) {
>                                       if (garrulous)
> @@ -250,7 +250,7 @@ top:
>                       break;
>               case EMOD:
>                       modified = 0;
> -                     fputs("?\n", stderr);           /* give warning */
> +                     fputs("?\n", stdout);           /* give warning */
>                       seterrmsg("warning: file modified");
>                       if (!interactive) {
>                               if (garrulous)
> @@ -271,7 +271,7 @@ top:
>                       quit(3);
>                       break;
>               default:
> -                     fputs("?\n", stderr);
> +                     fputs("?\n", stdout);
>                       if (!interactive) {
>                               if (garrulous)
>                                       fprintf(stderr,

Reply via email to