%%s 0/0/0 %%d D 1.1 25-Mar-82 12:16: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- cxfind 118 asc 25-mar-82 09:09:09 v1.1 (sw-tools v1.1) common / cxfind / lstptr, ptr(MAX_PTR) integer lstptr # last used ptr index pointer ptr # dynamic storage pointers #-h- xfind.r 2683 asc 25-mar-82 09:09:11 v1.1 (sw-tools v1.1) #-h- defns 188 asc 25-mar-82 09:08:47 v1.1 (sw-tools v1.1) ifdef(LARGE_ADDRESS_SPACE) define(MAX_PTR,800) define(Mem_size,20000) elsedef define(MAX_PTR,200) # 200 patterns allowed define(Mem_size,5000) # size of dynamic storage enddef #-h- main 484 asc 25-mar-82 09:08:48 v1.1 (sw-tools v1.1) DRIVER(xfind) character buf(MAXLINE) integer pat(MAXPAT), i, k integer getlin, match pointer j include cxfind DS_DECL(Mem,Mem_size) call query("usage: xfind patfile ...") call inipat(buf, pat) while (getlin(buf, STDIN) != EOF) { for (i=1; i <= lstptr; i=i+1) { for ([j=ptr(i); k=1]; Mem(j) != EOS; [j=j+1; k=k+1]) pat(k) = Mem(j) pat(k) = EOS if (match(buf, pat) == YES) { call putlin(buf, STDOUT) break } } } DRETURN end #-h- enter 361 asc 25-mar-82 09:08:49 v1.1 (sw-tools v1.1) pointer function enter(pat) integer pat(MAXPAT), i, size pointer node, j pointer dsget DS_DECL(Mem,Mem_size) for (size = 1; pat(size) != EOS; size = size + 1) ; node = dsget(size) if (node == LAMBDA) call error("Too many patterns for internal storage.") for ([i=1; j=node]; pat(i) != EOS; [i=i+1; j=j+1]) Mem(j) = pat(i) Mem(j) = EOS return(node) end #-h- ferror 362 asc 25-mar-82 09:08:50 v1.1 (sw-tools v1.1) subroutine ferror(file, buf, reason) character file(ARB), buf(ARB), reason(ARB) string err1 "Error processing file: " string err2 ", reason: " string err3 "Offending line: " call putlin(err1, ERROUT) call putlin(file, ERROUT) call putlin(err2, ERROUT) call putlnl(reason, ERROUT) call putlin(err3, ERROUT) call putlnl(buf, ERROUT) call endst(ERR) return end #-h- inipat 923 asc 25-mar-82 09:08:51 v1.1 (sw-tools v1.1) subroutine inipat(buf, pat) character buf(ARB), patfil(FILENAMESIZE) integer pat(MAXPAT), i, j integer getarg, getlin, length, makpat filedes fd filedes open pointer enter include cxfind DS_DECL(Mem,Mem_size) string illpat "Illegal pattern." string ptrovf "Too many patterns for internal storage." ltrptr = 0 call dsinit(Mem_size) # initialize dynamic storage for (i=1; getarg(i, patfil, FILENAMESIZE) != EOF; i=i+1) { fd = open(patfil, READ) if (fd == ERR) call cant(patfil) while (getlin(buf, fd) != EOF) { j = length(buf) # find newline buf(j) = EOS # eliminate it if (makpat(buf, 1, EOS, pat) == ERR) # generate pattern call ferror(patfil, buf, illpat) # fatal error lstptr = lstptr + 1 if (lstptr > MAX_PTR) call ferror(patfil, buf, ptrovf) # Too many patterns ptr(lstptr) = enter(pat) # enter into dynamic storage } call close(fd) } return end #-h- xfind.fmt 687 asc 25-mar-82 09:09:13 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Xfind (1) 11-Mar-82 entended find utility .sy xfind patfile ... .ds `xfind' permits one to search for more than 10 expressions in one pass of the standard input file. During initialization, `xfind' compiles the patterns found in the one (or more) pattern files specified in the argument list. Then, standard input is read, and each input line which matches any one of the patterns is output on standard output. .sp The format of the pattern fils is quite simple: each line is taken to represent a single pattern. The complete regular expression syntax is supported. .fl .sa find - find regular expressions .br xch - extended change utility .di .au Joe Sventek .bu %%E 1