Add P1003.1-2001 -f and -p options.
PR: standards/36243 Submitted by: Tim J. Robbins <tim@robbins.dropbear.id.au> Reviewed by: mike MFC after: 2 weeks
This commit is contained in:
parent
9a0c70235d
commit
032b32ada6
@ -50,7 +50,7 @@
|
|||||||
.Bk -words
|
.Bk -words
|
||||||
.Op Fl Ar column
|
.Op Fl Ar column
|
||||||
.Ek
|
.Ek
|
||||||
.Op Fl adFmrt
|
.Op Fl adFfmprt
|
||||||
.Bk -words
|
.Bk -words
|
||||||
.Oo
|
.Oo
|
||||||
.Op Fl e
|
.Op Fl e
|
||||||
@ -197,6 +197,10 @@ instead of the default behavior that uses a
|
|||||||
sequence of
|
sequence of
|
||||||
.Em <newline>
|
.Em <newline>
|
||||||
characters.
|
characters.
|
||||||
|
.It Fl f
|
||||||
|
Same as
|
||||||
|
.Fl F
|
||||||
|
but pause before beginning the first page if standard output is a terminal.
|
||||||
.It Fl h Ar header
|
.It Fl h Ar header
|
||||||
Use the string
|
Use the string
|
||||||
.Ar header
|
.Ar header
|
||||||
@ -293,6 +297,11 @@ If the
|
|||||||
.Fl o
|
.Fl o
|
||||||
option is not specified, the default is zero.
|
option is not specified, the default is zero.
|
||||||
The space taken is in addition to the output line width.
|
The space taken is in addition to the output line width.
|
||||||
|
.It Fl p
|
||||||
|
Pause before each page if the standard output is a terminal.
|
||||||
|
.Nm
|
||||||
|
will write an alert character to standard error and wait for a carriage
|
||||||
|
return to be read on the terminal.
|
||||||
.It Fl r
|
.It Fl r
|
||||||
Write no diagnostic reports on failure to open a file.
|
Write no diagnostic reports on failure to open a file.
|
||||||
.It Fl s Ar char
|
.It Fl s Ar char
|
||||||
@ -373,7 +382,7 @@ file printing is complete (when printing to a terminal).
|
|||||||
The
|
The
|
||||||
.Nm
|
.Nm
|
||||||
utility is
|
utility is
|
||||||
.St -p1003.2
|
.St -p1003.1-2001
|
||||||
compatible.
|
compatible.
|
||||||
.Sh HISTORY
|
.Sh HISTORY
|
||||||
A
|
A
|
||||||
|
@ -84,6 +84,8 @@ int across; /* mult col flag; write across page */
|
|||||||
int dspace; /* double space flag */
|
int dspace; /* double space flag */
|
||||||
char inchar; /* expand input char */
|
char inchar; /* expand input char */
|
||||||
int ingap; /* expand input gap */
|
int ingap; /* expand input gap */
|
||||||
|
int pausefst; /* Pause before first page */
|
||||||
|
int pauseall; /* Pause before each page */
|
||||||
int formfeed; /* use formfeed as trailer */
|
int formfeed; /* use formfeed as trailer */
|
||||||
char *header; /* header name instead of file name */
|
char *header; /* header name instead of file name */
|
||||||
char ochar; /* contract output char */
|
char ochar; /* contract output char */
|
||||||
@ -138,6 +140,28 @@ main(argc, argv)
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if we should pause and write an alert character and wait for a
|
||||||
|
* carriage return on /dev/tty.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ttypause(pagecnt)
|
||||||
|
int pagecnt;
|
||||||
|
{
|
||||||
|
int pch;
|
||||||
|
FILE *ttyfp;
|
||||||
|
|
||||||
|
if ((pauseall || (pausefst && pagecnt == 1)) &&
|
||||||
|
isatty(STDOUT_FILENO)) {
|
||||||
|
if ((ttyfp = fopen("/dev/tty", "r")) != NULL) {
|
||||||
|
(void)putc('\a', stderr);
|
||||||
|
while ((pch = getc(ttyfp)) != '\n' && pch != EOF)
|
||||||
|
;
|
||||||
|
(void)fclose(ttyfp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* onecol: print files with only one column of output.
|
* onecol: print files with only one column of output.
|
||||||
* Line length is unlimited.
|
* Line length is unlimited.
|
||||||
@ -222,6 +246,8 @@ onecol(argc, argv)
|
|||||||
ips = 0;
|
ips = 0;
|
||||||
cps = 0;
|
cps = 0;
|
||||||
|
|
||||||
|
ttypause(pagecnt);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* loop by line
|
* loop by line
|
||||||
*/
|
*/
|
||||||
@ -410,6 +436,8 @@ vertcol(argc, argv)
|
|||||||
* loop by page
|
* loop by page
|
||||||
*/
|
*/
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
ttypause(pagecnt);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* loop by column
|
* loop by column
|
||||||
*/
|
*/
|
||||||
@ -666,6 +694,8 @@ horzcol(argc, argv)
|
|||||||
* loop by page
|
* loop by page
|
||||||
*/
|
*/
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
ttypause(pagecnt);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* loop by line
|
* loop by line
|
||||||
*/
|
*/
|
||||||
@ -856,6 +886,8 @@ mulfile(argc, argv)
|
|||||||
* continue to loop while any file still has data
|
* continue to loop while any file still has data
|
||||||
*/
|
*/
|
||||||
while (actf > 0) {
|
while (actf > 0) {
|
||||||
|
ttypause(pagecnt);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* loop by line
|
* loop by line
|
||||||
*/
|
*/
|
||||||
@ -1561,7 +1593,8 @@ void
|
|||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
(void)fputs(
|
(void)fputs(
|
||||||
"usage: pr [+page] [-col] [-adFmrt] [-e[ch][gap]] [-h header]\n",err);
|
"usage: pr [+page] [-col] [-adFfmprt] [-e[ch][gap]] [-h header]\n",
|
||||||
|
err);
|
||||||
(void)fputs(
|
(void)fputs(
|
||||||
" [-i[ch][gap]] [-l line] [-n[ch][width]] [-o offset]\n",err);
|
" [-i[ch][gap]] [-l line] [-n[ch][width]] [-o offset]\n",err);
|
||||||
(void)fputs(
|
(void)fputs(
|
||||||
@ -1596,7 +1629,7 @@ setup(argc, argv)
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
err = stderr;
|
err = stderr;
|
||||||
while ((c = egetopt(argc, argv, "#adFmrte?h:i?L:l:n?o:s?w:")) != -1) {
|
while ((c = egetopt(argc, argv, "#adFfmrte?h:i?L:l:n?o:ps?w:")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '+':
|
case '+':
|
||||||
if ((pgnm = atoi(eoptarg)) < 1) {
|
if ((pgnm = atoi(eoptarg)) < 1) {
|
||||||
@ -1640,6 +1673,9 @@ setup(argc, argv)
|
|||||||
} else
|
} else
|
||||||
ingap = INGAP;
|
ingap = INGAP;
|
||||||
break;
|
break;
|
||||||
|
case 'f':
|
||||||
|
++pausefst;
|
||||||
|
/*FALLTHROUGH*/
|
||||||
case 'F':
|
case 'F':
|
||||||
++formfeed;
|
++formfeed;
|
||||||
break;
|
break;
|
||||||
@ -1705,6 +1741,9 @@ setup(argc, argv)
|
|||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
++pauseall;
|
||||||
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
++nodiag;
|
++nodiag;
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user