bug#47243: pr lacks -p

Paul Eggert <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Organization UCLA Computer Science Department
Message-ID <[email protected]>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.