%%s 0/0/0 %%d D 1.1 25-Mar-82 12:07:55 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- lam.r 2398 asc 25-mar-82 08:03:55 v1.1 (sw-tools v1.1) #-h- defns 166 asc 25-mar-82 08:03:44 v1.1 (sw-tools v1.1) # include ratdef define(MAXARGS,12) # max nbr args (files and strings) allowed define(MAXBUF,200) # buffer to hold strings define(MAXOBUF,500) # output buffer #-h- main 2086 asc 25-mar-82 08:03:45 v1.1 (sw-tools v1.1) # lam - laminate named files DRIVER(lam) character lin(MAXLINE), buf(MAXBUF), obuf(MAXOBUF) integer bp, obp, i, j, junk, nfiles, len, fd(MAXARGS) integer open, getarg, getlin, esc, addset call query("usage: lam {-string | file} ...") bp = 1 nfiles = 0 for (i = 1; getarg(i, lin, MAXLINE) != EOF; i = i + 1) { if (i > MAXARGS) call error("too many arguments.") if (lin(1) == '-' & lin(2) != EOS) { # -string fd(i) = -bp for (j = 2; lin(j) != EOS; j = j + 1) junk = addset(esc(lin, j), buf, bp, MAXBUF) if (addset(EOS, buf, bp, MAXBUF) == NO) call error("too many strings.") } else { nfiles = nfiles + 1 if (lin(1) == '-') fd(i) = STDIN else fd(i) = open(lin, READ) if (fd(i) == ERR) call cant(lin) } } if (nfiles == 0) { nfiles = 1 fd(i) = STDIN } else i = i - 1 n = i for (obp = 1; nfiles > 0; obp = 1) { for (i = 1; i <= n; i = i + 1) { if (fd(i) < 0 ) # do string { for (j = -fd(i); buf(j) != EOS; j = j + 1) { if ( addset(buf(j), obuf, obp, MAXOBUF) == NO) call error ("output buffer exceeded.") } } else if (fd(i) != EOF) { len = getlin(lin, fd(i)) if (len == EOF) { nfiles = nfiles - 1 if (fd(i) != STDIN) call close(fd(i)) fd(i) = EOF } else { for (j = 1; j < len; j = j + 1) { if ( addset(lin(j), obuf, obp, MAXOBUF) == NO) call error ("output buffer exceeded.") } } } } # end of second 'for' loop if (nfiles > 0) { for (j = 1; j < obp; j = j + 1) call putch(obuf(j), STDOUT) call putch('@n', STDOUT) } } # end of main 'for' loop. DRETURN end #-h- lam.fmt 1638 asc 25-mar-82 08:03:56 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Lam (1) 30-Jul-79 laminate files .sy lam { -string | file } ... .ds Lam laminates the named files to the standard output. That is, the first output line is the result of concatenating the first lines of each file, and so on. If the files are different lengths, null lines are used for the missing lines in the shorter files. .sp The "-string" arguments are used to place strings in each output line. Each "string" is placed in the output lines at the point it appears in the argument list. For example, .sp .in +3 .nf lam -file1: foo1 "-, file2:" foo2 .in -3 .sp .fi results in output lines that look like .sp .in +3 .nf file1: a line from foo1, file2: a line from foo2 .in -3 .sp .fi The escape sequences described in find (and change) are valid in "string" arguments. Thus .sp .in +3 .nf lam foo1 -@n foo2 .in -3 .sp .fi results in the lines from foo1 and foo2 being interleaved. .sp Files and string specifications may appear in any order in the argument list. .sp If no file arguments are given, or if the file "-" is specified, lam reads the standard input. .fi .fl none .sa comm, tail .di too many arguments .br .in +3 The maximum number of command line arguments allowed has been exceeded. It is set by the MAXARGS definition in the source code. .in -3 .sp too many strings .br .in +3 The max number of characters in a string has been exceeded. It is set by the MAXBUF definition in the source code. .in -3 .sp output buffer exceeded .in +3 The size of the output line buffer has been exceeded. It is set by the MAXOBUF definition in the source code. .in -3 .au David Hanson and friends (U. of Arizona) .bu %%E 1