%%s 6/6/151 %%d D 1.4 15-Jun-83 14:00:06 sventek 4 3 %%c Removed trailing periods from quoted strings, as they are no longer needed. %%s 5/5/152 %%d D 1.3 13-May-83 13:58:03 sventek 3 2 %%c Modified routines xfind.r`main and xfind.r`enter to reflect the new %%c compound statement syntax for the `for' statement. %%s 14/10/143 %%d D 1.2 01-Feb-83 13:35:23 stamerjohn 2 1 %%c Fix error in xfind when copying pattern strings. Assumed that EOS (0) %%c marked end of string. While true, a zero is also used elsewhere in %%c patterns. Need to call patsiz to get true size of pattern element. %%c Changed xfind.w`xfind.r`main and xfind.w`xfind.r`enter. %%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 %%D 2 #-h- xfind.r 2683 asc 25-mar-82 09:09:11 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 3 #-h- xfind.r 2821 asc 01-feb-83 13:32:52 stamerjohn (ralph stamerjohn) %%E 3 %%E 2 %%I 3 %%D 4 #-h- xfind.r 2803 asc 13-may-83 13:56:58 sventek (joseph sventek) %%E 4 %%E 3 %%I 4 #-h- xfind.r 2804 asc 15-jun-83 13:59:48 sventek (joseph sventek) %%E 4 #-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 %%D 2 #-h- main 484 asc 25-mar-82 09:08:48 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 3 #-h- main 587 asc 01-feb-83 13:30:00 stamerjohn (ralph stamerjohn) %%E 3 %%E 2 %%I 3 #-h- main 583 asc 13-may-83 13:56:49 sventek (joseph sventek) %%E 3 DRIVER(xfind) character buf(MAXLINE) %%D 2 integer pat(MAXPAT), i, k integer getlin, match %%E 2 %%I 2 integer pat(MAXPAT), i, k, l, size integer getlin, match, patsiz %%E 2 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) { %%D 2 for ([j=ptr(i); k=1]; Mem(j) != EOS; [j=j+1; k=k+1]) pat(k) = Mem(j) %%E 2 %%I 2 %%D 3 for ([j=ptr(i); k=1]; Mem(j) != EOS; [j=j+size; k=k+size]) %%E 3 %%I 3 for (j=ptr(i), k=1; Mem(j) != EOS; j=j+size, k=k+size) %%E 3 { size = patsiz(Mem, j) for (l=0; l != size; l=l+1) pat(k+l) = Mem(j+l) } %%E 2 pat(k) = EOS if (match(buf, pat) == YES) { call putlin(buf, STDOUT) break } } } DRETURN end %%D 2 #-h- enter 361 asc 25-mar-82 09:08:49 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 3 #-h- enter 378 asc 01-feb-83 13:30:02 stamerjohn (ralph stamerjohn) %%E 3 %%E 2 %%I 3 %%D 4 #-h- enter 374 asc 13-may-83 13:56:51 sventek (joseph sventek) %%E 4 %%E 3 %%I 4 #-h- enter 373 asc 15-jun-83 13:59:27 sventek (joseph sventek) %%E 4 pointer function enter(pat) %%D 2 integer pat(MAXPAT), i, size %%E 2 %%I 2 integer pat(MAXPAT), i, size, patsiz %%E 2 pointer node, j pointer dsget DS_DECL(Mem,Mem_size) %%D 2 for (size = 1; pat(size) != EOS; size = size + 1) %%E 2 %%I 2 for (size = 1; pat(size) != EOS; size = size+patsiz(pat,size)) %%E 2 ; node = dsget(size) if (node == LAMBDA) %%D 4 call error("Too many patterns for internal storage.") %%E 4 %%D 2 for ([i=1; j=node]; pat(i) != EOS; [i=i+1; j=j+1]) %%E 2 %%I 2 %%D 3 for ([i=1; j=node]; i != size; [i=i+1; j=j+1]) %%E 3 %%E 2 %%I 3 %%I 4 call error("Too many patterns for internal storage") %%E 4 for (i=1, j=node; i != size; i=i+1, j=j+1) %%E 3 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 %%D 4 #-h- inipat 923 asc 25-mar-82 09:08:51 v1.1 (sw-tools v1.1) %%E 4 %%I 4 #-h- inipat 921 asc 15-jun-83 13:59:28 sventek (joseph sventek) %%E 4 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) %%D 4 string illpat "Illegal pattern." string ptrovf "Too many patterns for internal storage." %%E 4 %%I 4 string illpat "Illegal pattern" string ptrovf "Too many patterns for internal storage" %%E 4 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