%%s 11/11/346 %%d D 1.5 15-Jun-83 13:57:45 sventek 5 4 %%c Removed trailing periods from quoted strings, as they are no longer needed. %%s 5/5/352 %%d D 1.4 13-May-83 13:54:16 sventek 4 3 %%c Modified xch.r`dosubs and xch.r`enter to reflect the new compound %%c statement syntax for `for' statements. %%s 13/9/344 %%d D 1.3 01-Feb-83 14:17:16 stamerjohn 3 2 %%c Fix error in xch 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 xch.w`xch.r`dosubs and xch.w`xch.r`enter. %%s 2/2/351 %%d D 1.2 01-Nov-82 19:11:00 sventek 2 1 %%c Made appropriate modifications to convert all occurrences of the string %%c ''' to the string '@''. The previous form is now a syntax error, due to %%c the extension to ratfor to permit "'" to be used as a quoted string %%c delimiter %%s 0/0/0 %%d D 1.1 25-Mar-82 12:16:46 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- ctable 271 asc 25-mar-82 09:07:59 v1.1 (sw-tools v1.1) common / ctable / verbos, lstptr, gblpat(MAXPAT), ptr(MAX_PTR) integer verbos # YES/NO to display modified lines on ERROUT integer lstptr # last used ptr index integer gblpat # global pattern for substitutions; gblpat(1) = EOS pointer ptr # dynamic storage pointers %%D 3 #-h- xch.r 4562 asc 25-mar-82 09:08:01 v1.1 (sw-tools v1.1) %%E 3 %%I 3 %%D 4 #-h- xch.r 4697 asc 01-feb-83 14:15:08 stamerjohn (ralph stamerjohn) %%E 4 %%E 3 %%I 4 %%D 5 #-h- xch.r 4679 asc 13-may-83 13:53:16 sventek (joseph sventek) %%E 5 %%E 4 %%I 5 #-h- xch.r 4680 asc 15-jun-83 13:57:21 sventek (joseph sventek) %%E 5 #-h- defns 191 asc 25-mar-82 09:07:33 v1.1 (sw-tools v1.1) ifdef(LARGE_ADDRESS_SPACE) define(MAX_PTR,400) define(Mem_size,20000) elsedef define(MAX_PTR,100) # 100 /pat/sub/'s allowed define(Mem_size,5000) # size of dynamic storage enddef #-h- main 674 asc 25-mar-82 09:07:34 v1.1 (sw-tools v1.1) DRIVER(xch) character buf(MAXLINE), sub(MAXPAT), old(MAXLINE) integer n, pat(MAXPAT) integer getlin, equal, match include ctable call query("usage: xch [-gpat] [-v] patfile ...") call inipat(buf, pat, sub) # initialize patterns n = 0 while (getlin(buf, STDIN) != EOF) { n = n + 1 call strcpy(buf, old) if (gblpat(1) == EOS) call dosubs(buf, pat, sub) else if (match(buf, gblpat) == YES) call dosubs(buf, pat, sub) if (verbos == YES) if (equal(buf, old) == NO) { call putint(n, 1, ERROUT) call putch('@n', ERROUT) call putlin(old, ERROUT) call putlin(buf, ERROUT) } call putlin(buf, STDOUT) } DRETURN end %%D 3 #-h- dosubs 371 asc 25-mar-82 09:07:35 v1.1 (sw-tools v1.1) %%E 3 %%I 3 %%D 4 #-h- dosubs 469 asc 01-feb-83 13:47:10 stamerjohn (ralph stamerjohn) %%E 4 %%E 3 %%I 4 #-h- dosubs 465 asc 13-may-83 13:53:07 sventek (joseph sventek) %%E 4 subroutine dosubs(buf, pat, sub) character buf(MAXLINE), sub(MAXPAT) %%D 3 integer i, j, k, pat(MAXPAT) %%E 3 %%I 3 integer i, j, k, l, size, pat(MAXPAT), patsiz %%E 3 include ctable DS_DECL(Mem,Mem_size) for (i=1; i <= lstptr; i=i+1) { %%D 3 for ([j=ptr(i)+1; k=1]; Mem(j) != EOS; [j=j+1; k=k+1]) pat(k) = Mem(j) %%E 3 %%I 3 %%D 4 for ([j=ptr(i)+1; k=1]; Mem(j) != EOS; [j=j+size; k=k+size]) %%E 4 %%I 4 for (j=ptr(i)+1, k=1; Mem(j) != EOS; j=j+size, k=k+size) %%E 4 { size = patsiz(Mem,j) for (l=0; l != size; l=l+1) pat(k+l) = Mem(j+l) } %%E 3 pat(k) = EOS j = ptr(i) call scopy(Cmem, cvt_to_cptr(Mem(j)), sub, 1) call replac(buf, pat, sub) } return end %%D 3 #-h- enter 505 asc 25-mar-82 09:07:36 v1.1 (sw-tools v1.1) %%E 3 %%I 3 %%D 4 #-h- enter 524 asc 01-feb-83 13:47:10 stamerjohn (ralph stamerjohn) %%E 4 %%E 3 %%I 4 %%D 5 #-h- enter 520 asc 13-may-83 13:53:07 sventek (joseph sventek) %%E 5 %%E 4 %%I 5 #-h- enter 518 asc 15-jun-83 13:57:00 sventek (joseph sventek) %%E 5 pointer function enter(lhs, rhs) %%D 3 integer lhs(MAXPAT), size, i, j %%E 3 %%I 3 integer lhs(MAXPAT), size, i, j, patsiz %%E 3 character rhs(MAXPAT) pointer node, dsget, temp, sdupl DS_DECL(Mem,Mem_size) %%D 3 for (size=1; lhs(size) != EOS; size=size+1) %%E 3 %%I 3 for (size=1; lhs(size) != EOS; size=size+patsiz(lhs,size)) %%E 3 ; node = dsget(size + 1) if (node == LAMBDA) %%D 5 call error("Too many patterns for internal storage.") %%E 5 %%D 3 for ([i=1; j=node+1]; lhs(i) != EOS; [i=i+1; j=j+1]) %%E 3 %%I 3 %%D 4 for ([i=1; j=node+1]; i != size; [i=i+1; j=j+1]) %%E 4 %%E 3 %%I 4 %%I 5 call error("Too many patterns for internal storage") %%E 5 for (i=1, j=node+1; i != size; i=i+1, j=j+1) %%E 4 Mem(j) = lhs(i) Mem(j) = EOS temp = sdupl(rhs) if (temp == LAMBDA) %%D 5 call error("Too many patterns for internal storage.") %%E 5 %%I 5 call error("Too many patterns for internal storage") %%E 5 Mem(node) = temp return(node) end #-h- ferror 362 asc 25-mar-82 09:07:37 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 5 #-h- inipat 1374 asc 25-mar-82 09:07:38 v1.1 (sw-tools v1.1) %%E 5 %%I 5 #-h- inipat 1370 asc 15-jun-83 13:57:00 sventek (joseph sventek) %%E 5 subroutine inipat(buf, lhs, rhs) character buf(MAXLINE), rhs(MAXPAT), patfil(FILENAMESIZE), delim integer i, j, lhs(MAXPAT) integer getarg, getlin, makpat, maksub pointer enter filedes int filedes open include ctable DS_DECL(Mem,Mem_size) %%D 5 string illpat "Illegal pattern in left hand side." string illsub "Illegal substitution string in right hand side." string ptrovf "Too many patterns for internal storage." %%E 5 %%I 5 string illpat "Illegal pattern in left hand side" string illsub "Illegal substitution string in right hand side" string ptrovf "Too many patterns for internal storage" %%E 5 lstptr = 0 verbos = NO gblpat(1) = EOS call dsinit(Mem_size) # initialize dynamic storage for (i=1; getarg(i, patfil, FILENAMESIZE) != EOF; i=i+1) if (patfil(1) == '-') if (patfil(2) == 'v' | patfil(2) == 'V') verbos = YES else if (patfil(2) == 'g' | patfil(2) == 'G') { if (makpat(patfil, 3, EOS, gblpat) == ERR) %%D 5 call error("Error in global pattern.") %%E 5 %%I 5 call error("Error in global pattern") %%E 5 } else call badarg(patfil) else { int = open(patfil, READ) if (int == ERR) call cant(patfil) while (getlin(buf, int) != EOF) { delim = buf(1) j = makpat(buf, 2, delim, lhs) if (j == ERR) call ferror(patfil, buf, illpat) j = maksub(buf, j+1, delim, rhs) if (j == ERR) call ferror(patfil, buf, illsub) lstptr = lstptr + 1 if (lstptr > MAX_PTR) call ferror(patfil, buf, ptrovf) ptr(lstptr) = enter(lhs, rhs) } call close(int) } return end %%D 5 #-h- replac 574 asc 25-mar-82 09:07:40 v1.1 (sw-tools v1.1) %%E 5 %%I 5 #-h- replac 573 asc 15-jun-83 13:57:01 sventek (joseph sventek) %%E 5 subroutine replac(old, pat, sub) character old(MAXLINE), sub(MAXPAT), new(MAXLINE) integer j, lastm, k, m, junk, pat(MAXPAT) integer amatch, addset j = 1 lastm = 0 for (k=1; old(k) != EOS; ) { m = amatch(old, k, pat) if (m > 0 & lastm != m) { call catsub(old, k, m, sub, new, j, MAXLINE) lastm = m } if (m == 0 | m == k) { junk = addset(old(k), new, j, MAXLINE) k = k + 1 } else k = m } if (j > MAXLINE) { j = MAXLINE %%D 5 call remark("The next line has been truncated.") %%E 5 %%I 5 call remark("The next line has been truncated") %%E 5 } new(j) = EOS call strcpy(new, old) return end #-h- xch.fmt 1381 asc 25-mar-82 09:08:04 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Xch (1) 11-Mar-82 extended change utility .sy xch [-gpat] [-v] patfile ... .ds `xch' permits several global changes to be performed during one pass over the input data. During initialization, `xch' compiles the "/pat/sub/" lines found in the one (or more) pattern files specified in the arguments list. Then, standard input is read, and the equivalent of .sp % ch "pat" "sub" .sp is performed on each line. .sp Normally, the substitutions are attempted on each input line. If the `-gpat' option is selected, then the substitutions are attempted on only those lines which match `pat'. When the number of substitutions are large, this can substantially speed up the process. .sp If the `-v' flag is specified, for each line in which a substitution has occurred, the line number, followed by the old and new lines are displayed on error output. .sp The format of the pattern files is quite simple: each "/pat/sub/" pair occupies a single line, with the first character of the line assumed to be the delimeter character. The complete regular expression syntax is supported, such that the lines in the pattern files are exactly equivalent to the `ed' command with "s" prepended and "g" appended to the line. .fl .sa ch - change regular expressions .br find - find regular expressions .br xfind - extended find utility .br ed - text editor .di .au Joe Sventek .bu %%D 2 #-h- xchpf 1140 asc 25-mar-82 09:08:06 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- xchpf 1142 asc 01-nov-82 18:22:18 sventek (joseph sventek) %%E 2 /'@@n'/NEWLINE/ /'@@t'/TAB/ /'`'/ACCENT/ /'&'/AMPER/ /'@@@@'/ATSIGN/ /'\'/BACKSLASH/ /'!'/BANG/ /'|'/BAR/ /'A'/BIGA/ /'B'/BIGB/ /'C'/BIGC/ /'D'/BIGD/ /'E'/BIGE/ /'F'/BIGF/ /'G'/BIGG/ /'H'/BIGH/ /'I'/BIGI/ /'J'/BIGJ/ /'K'/BIGK/ /'L'/BIGL/ /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