diff options
author | jmallett <jmallett@FreeBSD.org> | 2002-03-31 18:44:36 +0000 |
---|---|---|
committer | jmallett <jmallett@FreeBSD.org> | 2002-03-31 18:44:36 +0000 |
commit | cace3f9d081619c267182e7e1c926cafabc283e2 (patch) | |
tree | 02a08d1645bdc41e4c0c2ad249f5707e83a9e02d /usr.bin/pr/pr.c | |
parent | 77d700702cc9a30522135da39f2c704d0e8bfa0b (diff) | |
download | FreeBSD-src-cace3f9d081619c267182e7e1c926cafabc283e2.zip FreeBSD-src-cace3f9d081619c267182e7e1c926cafabc283e2.tar.gz |
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
Diffstat (limited to 'usr.bin/pr/pr.c')
-rw-r--r-- | usr.bin/pr/pr.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/usr.bin/pr/pr.c b/usr.bin/pr/pr.c index 941b8fe..754c7db 100644 --- a/usr.bin/pr/pr.c +++ b/usr.bin/pr/pr.c @@ -84,6 +84,8 @@ int across; /* mult col flag; write across page */ int dspace; /* double space flag */ char inchar; /* expand input char */ int ingap; /* expand input gap */ +int pausefst; /* Pause before first page */ +int pauseall; /* Pause before each page */ int formfeed; /* use formfeed as trailer */ char *header; /* header name instead of file name */ char ochar; /* contract output char */ @@ -139,6 +141,28 @@ main(argc, argv) } /* + * 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. * Line length is unlimited. */ @@ -222,6 +246,8 @@ onecol(argc, argv) ips = 0; cps = 0; + ttypause(pagecnt); + /* * loop by line */ @@ -410,6 +436,8 @@ vertcol(argc, argv) * loop by page */ for(;;) { + ttypause(pagecnt); + /* * loop by column */ @@ -666,6 +694,8 @@ horzcol(argc, argv) * loop by page */ for(;;) { + ttypause(pagecnt); + /* * loop by line */ @@ -856,6 +886,8 @@ mulfile(argc, argv) * continue to loop while any file still has data */ while (actf > 0) { + ttypause(pagecnt); + /* * loop by line */ @@ -1561,7 +1593,8 @@ void usage() { (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( " [-i[ch][gap]] [-l line] [-n[ch][width]] [-o offset]\n",err); (void)fputs( @@ -1596,7 +1629,7 @@ setup(argc, argv) } } else 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) { case '+': if ((pgnm = atoi(eoptarg)) < 1) { @@ -1640,6 +1673,9 @@ setup(argc, argv) } else ingap = INGAP; break; + case 'f': + ++pausefst; + /*FALLTHROUGH*/ case 'F': ++formfeed; break; @@ -1705,6 +1741,9 @@ setup(argc, argv) return(1); } break; + case 'p': + ++pauseall; + break; case 'r': ++nodiag; break; |