Subject: Re: bug#47243: pr lacks -p

From: Paul Eggert <[email-masked]>
Date: Mon, 28 Jul 2025 08:14:22 -0700

On 2025-07-27 19:21, Collin Funk wrote:

> I think that v3 attached should cover everything.

In addition to Pádraig's comments, I would add:

> +  a newline character is read from /dev/tty, as required by POSIX Issue
> +  6.  The corresponding long option is --pause.

Don't say "Issue 6" as almost nobody knows what that means and it's 
obsolete anyway. Just say "POSIX".

> +              if (ch == EOF)
> +                {
> +                  /* Just exit if the user presses Ctrl-D.  */
> +                  if (feof (tty_fp))
> +                    goto finish;
> +                  error (EXIT_FAILURE, errno, _("error reading %s"),
> +                         quoteaf ("/dev/tty"));
> +                }

'goto finish;' should be 'return;'. That way, we don't need the 'finish' 
label.

It's possible for feof and ferror to both be true. In that case, pr 
should report the error. So, this code should call ferror instead of 
calling feof.

Come to think of it, why use stdio here? Plain 'open' and 'read' work 
just as well for this, and avoid possible stdio glitches. There's no 
real need for stdio's buffering.