%%s 13/13/309 %%d D 1.3 15-Jun-83 11:07:06 sventek 3 2 %%c Removed trailing periods from quoted strings, as they are no longer needed. %%s 3/3/319 %%d D 1.2 18-Jan-83 13:00:20 stamerjohn 2 1 %%c Modify mcol.w`mcol.r`defns to make MAXBUF 8712. This is large enough for %%c 66 line by 132 column pages. %%s 0/0/0 %%d D 1.1 25-Mar-82 12:09:13 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- cmcol 379 asc 25-mar-82 08:09:49 v1.1 (sw-tools v1.1) ## common block to hold line buffers for mcol tool # put on a file called 'cmcol' # used only by the mcol tool common /ccol/ col, nextbf, linbuf(MAXBUF), linptr(MAXPTR) integer col # current column number on formatted page integer nextbf # next available slot in linbuf character linbuf # holds a formatted page integer linptr # points to lines %%D 2 #-h- mcol.r 5846 asc 25-mar-82 08:09:51 v1.1 (sw-tools v1.1) #-h- defns 254 asc 25-mar-82 08:09:32 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 3 #-h- mcol.r 5852 asc 18-jan-83 12:58:47 stamerjohn (rw stamerjohn) %%E 3 %%I 3 #-h- mcol.r 5860 asc 15-jun-83 11:06:42 sventek (joseph sventek) %%E 3 #-h- defns 254 asc 18-jan-83 12:56:48 stamerjohn (rw stamerjohn) %%E 2 # include ratdef define(COLUMNS,2) # defaults define(PAGESIZE,55) define(GUTTER,8) define(LINESIZE,60) ifdef(LARGE_ADDRESS_SPACE) define(MAXBUF,20000) define(MAXPTR,4000) elsedef %%D 2 define(MAXBUF,5000) # size limits %%E 2 %%I 2 define(MAXBUF,8712) # size limits %%E 2 define(MAXPTR,1000) enddef #-h- main 1142 asc 25-mar-82 08:09:32 v1.1 (sw-tools v1.1) # mcol - format standard input into multiple columns DRIVER(mcol) integer pagsiz, linsiz, ncols, gutsiz, lineno, nlines, i, j, fd integer readln, ctoi, getarg, mod, max, open character arg(MAXLINE) include cmcol string usestr "usage: mcol [-cn] [-ln] [-wn] [-gn] [-dn] [file] ..." call query(usestr) for (i = 1; i <= MAXPTR; i = i + 1) # clear pointer array linptr(i) = 0 col = 0 nextbf = 1 pagsiz = PAGESIZE # set defaults linsiz = LINESIZE ncols = COLUMNS gutsiz = GUTTER fd = ERR for (i = 1; getarg(i, arg, MAXLINE) != EOF; i = i + 1) { if (arg(1) == '-' & arg(2) != EOS) call colarg (arg, pagsiz, ncols, gutsiz, linsiz) else if (arg(1) == '-' & arg(2) == EOS) call docol (pagsiz, ncols, gutsiz, linsiz, STDIN) else { fd = open(arg, READ) if (fd == ERR) call cant(arg) call docol(pagsiz, ncols, gutsiz, linsiz, fd) call close (fd) } } if (fd == ERR) #read STDIN call docol (pagsiz, ncols, gutsiz, linsiz, STDIN) DRETURN end %%D 3 #-h- colarg 1145 asc 25-mar-82 08:09:33 v1.1 (sw-tools v1.1) %%E 3 %%I 3 #-h- colarg 1140 asc 15-jun-83 11:06:10 sventek (joseph sventek) %%E 3 ## colarg - process flags for mcol tool subroutine colarg (arg, pagsiz, ncols, gutsiz, linsiz) integer pagsiz, ncols, gutsiz, linsiz, j integer ctoi character arg(ARB) j = 3 j = ctoi(arg, j) if (arg(2) == 'c' | arg(2) == 'C') { ncols = j if (ncols <= 0) %%D 3 call error ("invalid column count.") %%E 3 %%I 3 call error ("invalid column count") %%E 3 } else if (arg(2) == 'l' | arg(2) == 'L') { pagsiz = j if (pagsiz <= 0) %%D 3 call error ("invalid page size.") %%E 3 %%I 3 call error ("invalid page size") %%E 3 } else if ( (arg(2) == 'w' | arg(2) == 'W') | (arg(2) == 's' | arg(2) == 's') ) #UofA convention { linsiz = j if (linsiz <= 0) %%D 3 call error ("invalid column width.") %%E 3 %%I 3 call error ("invalid column width") %%E 3 } else if (arg(2) == 'g' | arg(2) == 'G') { gutsiz = j if (gutsiz < 0) %%D 3 call error ("invalid gutter width.") %%E 3 %%I 3 call error ("invalid gutter width") %%E 3 } else if (arg(2) == 'd' | arg(2) == 'D') { pagsiz = 23 # display defaults linsiz = 10 ncols = 7 gutsiz = 1 if (j > 0) # set column width and number of columns { linsiz = j ncols = max(1, 81/(linsiz+1)) if (ncols > 1) { gutsiz = (79 - (linsiz+1)*ncols)/(ncols - 1)+1 if (gutsiz <= 0) ncols = ncols - 1 } } } else %%D 3 call remark ("ignoring invalid flag.") %%E 3 %%I 3 call remark ("ignoring invalid flag") %%E 3 return end %%D 3 #-h- docol 692 asc 25-mar-82 08:09:34 v1.1 (sw-tools v1.1) %%E 3 %%I 3 #-h- docol 691 asc 15-jun-83 11:06:11 sventek (joseph sventek) %%E 3 ## docol - process file for mcol subroutine docol (pagsiz, ncols, gutsiz, linsiz, fd) integer pagsiz, ncols, gutsiz, linsiz, fd, nlines, lineno, i integer readln include cmcol nlines = pagsiz*ncols # total number of lines/page if (nlines > MAXPTR) %%D 3 call error ("too many lines.") %%E 3 %%I 3 call error ("too many lines") %%E 3 for (lineno = 1; readln(i, linsiz, fd) != EOF; lineno = lineno + 1) { call inject(i, lineno) if (lineno >= nlines) { call outbuf(pagsiz, linsiz, gutsiz) lineno = 0 } } if (lineno > 1) { pagsiz = lineno/ncols if (mod(lineno, ncols) != 0) pagsiz = pagsiz + 1 call outbuf(pagsiz, linsiz, gutsiz) } return end %%D 3 #-h- inject 235 asc 25-mar-82 08:09:35 v1.1 (sw-tools v1.1) %%E 3 %%I 3 #-h- inject 234 asc 15-jun-83 11:06:12 sventek (joseph sventek) %%E 3 # inject - insert pointer ptr into linptr array subroutine inject(ptr, lineno) integer ptr, lineno include cmcol if (lineno > MAXPTR) %%D 3 call error("insufficient buffer space.") %%E 3 %%I 3 call error("insufficient buffer space") %%E 3 linptr(lineno) = ptr return end #-h- outbuf 517 asc 25-mar-82 08:09:35 v1.1 (sw-tools v1.1) # outbuf - dump current buffer to formatted page subroutine outbuf(pagsiz, linsiz, gutsiz) integer pagsiz, linsiz, gutsiz integer i, j include cmcol for (i = 1; linptr(i) != 0; i = i + 1) { call outlin(linbuf(linptr(i))) linptr(i) = 0 for (j = i + pagsiz; linptr(j) != 0; j = j + pagsiz) { call outtab((linsiz + gutsiz)*((j - 1)/pagsiz)) call outlin(linbuf(linptr(j))) linptr(j) = 0 } call outch('@n') } nextbf = 1 return end #-h- outch 186 asc 25-mar-82 08:09:36 v1.1 (sw-tools v1.1) # outch - output c to formatted page subroutine outch(c) character c include cmcol call putc(c) if (c == '@n') col = 0 else col = col + 1 return end #-h- outlin 185 asc 25-mar-82 08:09:36 v1.1 (sw-tools v1.1) # outlin - output str to formatted page subroutine outlin(str) character str(ARB) integer i for (i = 1; str(i) != EOS; i = i + 1) call outch(str(i)) return end #-h- outtab 158 asc 25-mar-82 08:09:37 v1.1 (sw-tools v1.1) # outtab - tab to column n on formatted page subroutine outtab(n) integer n include cmcol while (col < n) call outch(' ') return end %%D 3 #-h- readln 602 asc 25-mar-82 08:09:37 v1.1 (sw-tools v1.1) %%E 3 %%I 3 #-h- readln 601 asc 15-jun-83 11:06:13 sventek (joseph sventek) %%E 3 # readln - read next line (<= linsiz) into linbuf; return location p integer function readln(p, linsiz, fd) integer p, linsiz, fd integer i character getch character c include cmcol p = nextbf for (i = 1; getch(c, fd) != EOF; i = i + 1) { if (c == '@n') break if (i <= linsiz) { if (nextbf >= MAXBUF) %%D 3 call error("insufficient buffer space.") %%E 3 %%I 3 call error("insufficient buffer space") %%E 3 linbuf(nextbf) = c nextbf = nextbf + 1 } } if (c == EOF & i == 1) return (EOF) linbuf(nextbf) = EOS nextbf = nextbf + 1 return (i - 1) end #-h- mcol.fmt 2135 asc 25-mar-82 08:09:53 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Mcol (1) 1-Oct-78 multicolumn formatting .sy mcol [-cn] [-ln] [-wn] [-gn] [-dn] [file] ... .ds mcol reads the named files and formats them into multicolumn output on the standard output. If the filename "-" is given, or no files are specified, the standard input is read. The options are as follows. .sp .in +5 .ti -5 -cn Format the output into "n" columns. Default is 2. .sp .ti -5 -ln Set the output page size to "n". Mcol produces its output in pages, but does not place separators between the pages on the assumption that some subsequent processor will do that. (The default page length is 55.) .sp .ti -5 -wn Set the column width to "n" characters. Lines longer than "n" characters are truncated. (The default column width is 60.) .sp .ti -5 -gn Set the "gutter" width to "n". The gutter is the white space between columns. (The default gutter width is 8.) .sp .ti -5 -dn Assume output is to be printed on a display terminal. The column size is set to "n" characters and the page size is set to 24 lines. The number of columns and gutter width are computed to maximize the amount of information on a single screen. If "n" is omitted, 10 is used, which is useful for displaying lists of file names. .sp .in -5 .fi .fl none .sa .di .nf invalid column count invalid page size invalid column width invalid gutter width .br .fi .in +3 The value of one of the option flags is invalid or exceeds the limitations of mcol. .sp .ti -3 ignoring invalid flag .br A command argument option flag was given which mcol didn't recognize. .in -3 .sp insufficient buffer space .br .in +3 Mcol could not buffer an entire page. This is usually the result of options that specify a large page size or many columns. The buffer size is set by the MAXBUF definition in the source code. .in -3 .sp too many lines .in +3 .br The number of lines per page times the number of columns exceeded mcol's line buffer space. The maximum number of lines allowed is set by the MAXPTR definition in the source code. .in -3 .fi .bu .au Original by David Hanson and friends (U. of Arizona), with modifications by Debbie Scherrer (LBL). %%E 1