On 2019-05-19, Richard Ipsum <[email protected]> wrote:
> From POSIX:
>
> In the POSIX locale, results of the comparison shall be written to
> standard output. When no options are used, the format shall be:
>
>     "%s %s differ: char %d, line %d\n", file1, file2,
>         <byte number>, <line number>
>
> ....
> in the POSIX locale the following
> diagnostic message shall be written:
>
> "cmp: EOF on %s%s\n", <name of shorter file>, <additional info>
> ---
>  cmp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/cmp.c b/cmp.c
> index ea8902f..6949191 100644
> --- a/cmp.c
> +++ b/cmp.c
> @@ -57,12 +57,12 @@ main(int argc, char *argv[])
>                       continue;
>               } else if (b[0] == EOF || b[1] == EOF) {
>                       if (!sflag)
> -                             weprintf("cmp: EOF on %s\n", argv[(b[0] != 
> EOF)]);
> +                             printf("cmp: EOF on %s\n", argv[(b[0] != EOF)]);

I think stderr is correct for this message:

        The standard error shall be used only for diagnostic messages. ... in
the POSIX locale the following diagnostic message shall be written

However, we probably want to avoid the double-prefix on the message with just

        weprintf("EOF on %s\n", argv[(b[0] != EOF)]);

>                       same = 0;
>                       break;
>               } else if (!lflag) {
>                       if (!sflag)
> -                             printf("%s %s differ: byte %zu, line %zu\n",
> +                             printf("%s %s differ: char %zu, line %zu\n",
>                                      argv[0], argv[1], n, line);
>                       same = 0;
>                       break;
> --
> 2.21.0

Reply via email to