%%s 4/4/180 %%d D 1.3 15-Jun-83 11:50:46 sventek 3 2 %%c Removed trailing periods from quoted strings, as they are no longer needed. %%s 9/7/175 %%d D 1.2 28-Jan-83 14:22:22 stamerjohn 2 1 %%c Change default line length to 60 to match line printer controls. %%c Also update documentation to reflect change. Modifications made %%c to pr.w`pr.r`defns and pr.w`pr.fmt. %%s 0/0/0 %%d D 1.1 25-Mar-82 12:10:52 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 #-h- cprint 748 asc 25-mar-82 08:17:36 v1.1 (sw-tools v1.1) ## common block to hold info for pr tool # put on a file called 'cprint' # used only by the pr tool common /cprint/ mar1, mar2, bmar, dohead, dotail, plen integer mar1 #distance between top of page and header #(default = 3) integer mar2 #distance between header and text #(default = 2) integer bmar #distance between text and bottom of page #(default = 6) integer dohead #flag to cause/suppress printing of header # (default = YES) integer dotail #flag to cause/suppress printing of bottom #margin (default = YES) integer plen #page length (default = 66) %%D 2 #-h- pr.r 3317 asc 25-mar-82 08:17:38 v1.1 (sw-tools v1.1) #-h- defns 96 asc 25-mar-82 08:17:24 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 3 #-h- pr.r 3326 asc 28-jan-83 14:20:55 stamerjohn (ralph stamerjohn) %%E 3 %%I 3 #-h- pr.r 3328 asc 15-jun-83 11:50:18 sventek (joseph sventek) %%E 3 #-h- defns 96 asc 28-jan-83 14:11:27 stamerjohn (ralph stamerjohn) %%E 2 # include ratdef define(MARGIN1,0) define(MARGIN2,2) define(BMARGIN,0) %%D 2 define(PAGELEN,62) %%E 2 %%I 2 define(PAGELEN,60) %%E 2 %%D 3 #-h- main 1338 asc 25-mar-82 08:17:24 v1.1 (sw-tools v1.1) %%E 3 %%I 3 #-h- main 1336 asc 15-jun-83 11:49:55 sventek (joseph sventek) %%E 3 ## print - print files with headings DRIVER(pr) character name(FILENAMESIZE) integer getarg, open, ctoi integer fd, i, j include cprint string stdinp "Standard input" string usestr "usage: pr [-l] [file] ..." call query(usestr) mar1 = MARGIN1 #set defaults mar2 = MARGIN2 bmar = BMARGIN dohead = YES plen = PAGELEN fd = ERR for (i = 1; getarg(i, name, FILENAMESIZE) != EOF; i = i + 1) { if (name(1) == '-' & name(2) != EOS) { #it is anticipated that more #options may be added in the future if (name(2) == 'l' | name(2) == 'L') #set page length { j = 3 plen = ctoi(name, j) if ((plen-mar1-mar2-bmar-2) <= 0) %%D 3 call error ("page too small.") %%E 3 %%I 3 call error ("page too small") %%E 3 } else %%D 3 call remark ("ignoring invalid argument.") %%E 3 %%I 3 call remark ("ignoring invalid argument") %%E 3 } else if (name(1) == '-' & name(2) == EOS) { fd = STDIN call fprint (stdinp, STDIN) } else { fd = open(name, READ) if (fd == ERR) call cant(name) call fprint(name, fd) call close(fd) } } if (fd ==ERR) # no input file specified call fprint(stdinp, STDIN) DRETURN end #-h- fprint 892 asc 25-mar-82 08:17:25 v1.1 (sw-tools v1.1) # fprint - print file "name" from fd subroutine fprint(name, fd) character line(MAXLINE), name(ARB), date(10), time(10) integer getlin integer fd, lineno, pageno, now(7) include cprint call getnow(now) call fmtdat(date, time, now, LETTER) pageno = 0 lineno = 0 while (getlin(line, fd) != EOF) { if (lineno == 0) { pageno = pageno + 1 if (dohead == YES) { call skip(mar1) call head(name, date, time, pageno) call skip(mar2) lineno = mar1 + mar2 + 1 } } call putlin(line, STDOUT) lineno = lineno + 1 if (lineno + bmar >= plen) { call skip(bmar) lineno = 0 } } if (lineno > 0) { call skip(plen-lineno) call skip(bmar) } return end #-h- head 473 asc 25-mar-82 08:17:26 v1.1 (sw-tools v1.1) # head - print top of page header subroutine head(name, date, time, pageno) character name(ARB), date(ARB), time(ARB) integer pageno string page " Page " string twoblk " " call putch(FF, STDOUT) call putlin(name, STDOUT) call putlin(twoblk, STDOUT) call putlin(date, STDOUT) call putch(' ', STDOUT) call putlin(time, STDOUT) call putlin(page, STDOUT) call putdec(pageno, 1) call putc('@n') return end #-h- skip 153 asc 25-mar-82 08:17:26 v1.1 (sw-tools v1.1) # skip - output n blank lines subroutine skip(n) integer i, n for (i = 1; i <= n; i = i + 1) call putc('@n') return end %%D 2 #-h- pr.fmt 1022 asc 25-mar-82 08:17:39 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- pr.fmt 1122 asc 28-jan-83 14:20:44 stamerjohn (ralph stamerjohn) %%E 2 .so ~bin/manhdr .hd Pr (1) 15-Jan-77 paginate files to standard output .sy pr [-l] [file] ... .ds pr paginates the named files to standard output. Each file is printed as a sequence of pages. Each page %%D 2 is 66 lines long, including a 6-line header and 3-line footer. %%E 2 %%I 2 is 60 lines long, including a 3-line header and no footer. This gives 57 lines of text. The default format matches the printer control used on most line printers. %%E 2 The header includes the file name, possibly the date, and the page number. If the file '-' is specified, or no file names are given, the standard input is read. Option flags include: .in +11 .ti -5 -l Sets the page length to ''. %%D 2 Default page length is 66. %%E 2 %%I 2 Default page length is 60. %%E 2 .in -11 .sa os, detab, mcol, format, cat .di ignoring invalid argument .in +3 An option flag was specified which pr did not understand .in -3 A message is printed if an input file could not be opened .au Original from the Kernighan-Plauger 'Software Tools' book, with modifications by David Hanson and friends (U. of Arizona) and Debbie Scherrer (LBL) .bu The header and trailer spacing can be modified by adjusting the MARGIN1, MARGIN2, and BMARGIN definitions in the source code. %%E 1