%%s 0/0/0 %%d D 1.1 25-Mar-82 12:17:02 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- cxref 300 asc 25-mar-82 09:10:15 v1.1 (sw-tools v1.1) ## common block for xref tool # put on a file called "cxref" # (Used only by 'xref') integer buf(MAXBUF) # holds trees and linked lists character cbuf(arith(MAXBUF,*,CHAR_PER_INT)) equivalence (buf(1), cbuf(1)) integer nextbf # next free element of buf, init = 1 common / cxref / nextbf, buf #-h- xref.r 6673 asc 25-mar-82 09:10:18 v1.1 (sw-tools v1.1) #-h- defns 746 asc 25-mar-82 09:09:52 v1.1 (sw-tools v1.1) # layout of tree nodes define(LLINK,0) # pointer to left subtree define(RLINK,1) # pointer to right subtree define(LNLIST,2) # pointer to list of references define(LAST,3) # pointer to last reference entered define(ENTRY,4) # pointer to name (string) define(TNODESIZE,5)# size of node = TNODESIZE + length(name) + 1 # layout of linked list nodes define(LINENUM,0) # line number define(LINK,1) # pointer to next line number define(LNODESIZE,2) ifdef(LARGE_ADDRESS_SPACE) define(MAXBUF,60000) elsedef define(MAXBUF,15000) enddef define(LINESIZE,80) # length of output lines (see pentry) define(MAXTOK,15) # maximum token size (see pentry) define(MAXNUM,5) # size of line number entry (see pentry) define(MAXNAME,FILENAMESIZE) #-h- main 1047 asc 25-mar-82 09:09:54 v1.1 (sw-tools v1.1) # xref - make cross reference list of named files DRIVER(xref) character name(MAXTOK), arg(MAXNAME) integer fd, fflag, nfiles, bias, i, j integer open, getarg, ctoi string usestr "usage: xref [-b] [-f] [file] ..." data fflag/NO/, nfiles/0/, bias/0/ call query(usestr) for (i = 1; getarg(i, arg, MAXNAME) != EOF; i = i + 1) if (arg(1) == '-' & (arg(2) == 'f' | arg(2) == 'F')) fflag = YES else if (arg(1) == '-' & (arg(2) == 'b' | arg(2) == 'B')) { j = 3 bias = ctoi(arg, j) if (bias < 0) bias = 0 } else if ((arg(1) == '-' & arg(2) != EOS) ) call error (usestr) else { if (arg(1) == '-') fd = STDIN else fd = open(arg, READ) if (fd == ERR) call cant(arg) call putlin(arg, STDOUT) call putc(':') call putc('@n') call doxref(fd, fflag, bias) nfiles = nfiles + 1 } if (nfiles == 0) call doxref(STDIN, fflag, bias) DRETURN end #-h- balloc 236 asc 25-mar-82 09:09:54 v1.1 (sw-tools v1.1) # balloc - allocate n words in storage array buf; return index integer function balloc(n) integer n include cxref nextbf = nextbf + n if (nextbf > MAXBUF) call error("out of storage.") return(nextbf - n) end #-h- doxref 585 asc 25-mar-82 09:09:55 v1.1 (sw-tools v1.1) # doxref-generate cross reference list for file fd; fold if fflag = YES subroutine doxref(fd, fflag, bias) integer fd, fflag, bias integer t, root character gettok character token(MAXTOK) include cxref root = 0 nextbf = 1 lineno = bias + 1 repeat { t = gettok(token, MAXTOK, fd) if (t == EOF) break if (t == LETTER) { if (fflag == YES) call fold(token) call instl(token, lineno, root) } else if (t == '@n') lineno = lineno + 1 } call tprint(root) return end #-h- gettok 1012 asc 25-mar-82 09:09:56 v1.1 (sw-tools v1.1) # gettok - get text token from file fd character function gettok(token, size, fd) character token(ARB) integer size, fd character getch, type integer i character c, peek data peek /0/ if (peek == 0) # check for lookahead c = getch(c, fd) else { c = peek peek = 0 } for (; c != EOF; c = getch(c, fd)) { gettok = type(c) if (gettok == LETTER) { # start of name token(1) = c for (i = 2; getch(c, fd) != EOF; i = i + 1) if (type(c) == LETTER | type(c) == DIGIT | c == '_') { if (i < size) token(i) = c } else break peek = c # went one too far if (i <= size) token(i) = EOS else token(size) = EOS return(LETTER) } else if (gettok == '@n') { # newline must be returned peek = 0 return('@n') } } peek = 0 return(EOF) end #-h- instl 1170 asc 25-mar-82 09:09:57 v1.1 (sw-tools v1.1) # instl - install name in tree with reference on lineno; update tree subroutine instl(name, lineno, tree) character name(ARB), temp(MAXNAME) integer lineno, tree integer cond, p, q integer balloc, strcmp, length include cxref p = tree for (q = 0; p != 0; p = buf(q)) { call scopy(cbuf, cvt_to_cptr(buf(p+ENTRY)), temp, 1) # fetch name string cond = strcmp(name, temp) if (cond == 0) { q = balloc(LNODESIZE) # add a new element onto list buf(q+LINENUM) = lineno buf(q+LINK) = 0 buf(buf(p+LAST)+LINK) = q buf(p+LAST) = q return } else if (cond < 0) q = p + LLINK else q = p + RLINK } p = balloc(TNODESIZE) # allocate and fill in new node buf(p+LLINK) = 0 buf(p+RLINK) = 0 if (q == 0) tree = p else buf(q) = p q = balloc(length(name) / CHAR_PER_INT + 1) # space for name string call scopy(name, 1, cbuf, cvt_to_cptr(q)) buf(p+ENTRY) = q q = balloc(LNODESIZE) # insert first reference buf(q+LINENUM) = lineno buf(q+LINK) = 0 buf(p+LNLIST) = q buf(p+LAST) = q return end #-h- pentry 552 asc 25-mar-82 09:09:58 v1.1 (sw-tools v1.1) # pentry - print name and list of references subroutine pentry(name, list) character name(ARB) integer list integer i, len include cxref call putstr(name, -MAXTOK - 1, STDOUT) len = MAXTOK + 1 for (i = list; i != 0; i = buf(i+LINK)) { if (len > LINESIZE - MAXNUM) { call putc('@n') call putstr(EOS, -MAXTOK - 1, STDOUT) len = MAXTOK + 1 } call putint(buf(i+LINENUM), MAXNUM, STDOUT) len = len + MAXNUM } if (len <= LINESIZE) call putc('@n') return end #-h- tprint 741 asc 25-mar-82 09:09:59 v1.1 (sw-tools v1.1) # tprint - destructively print tree, left subtree first subroutine tprint(tree) integer tree integer p, q, sp character temp(MAXNAME) include cxref sp = 0 p = tree repeat { while (p != 0) if (buf(p+LLINK) != 0) { q = buf(p+LLINK) buf(p+LLINK) = sp sp = p p = q } else { call scopy(cbuf, cvt_to_cptr(buf(p+ENTRY)), temp, 1) call pentry(temp, buf(p+LNLIST)) p = buf(p+RLINK) } if (sp == 0) return call scopy(cbuf, cvt_to_cptr(buf(sp+ENTRY)), temp, 1) call pentry(temp, buf(sp+LNLIST)) p = buf(sp+RLINK) sp = buf(sp+LLINK) } return end #-h- xref.fmt 1370 asc 25-mar-82 09:10:22 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Xref (1) 1-Jan-79 make a cross reference of symbols .sy xref [-b] [-f] [file] ... .ds xref produces a cross-reference list of the symbols in each of the named files on the standard output. Each symbol is listed followed by the numbers of the lines in which it appears. If no files are given, or the file "-" is specified, xref reads the standard input. .sp A symbol is defined as a string of letters, digits, underlines, or periods that begins with a letter. Symbols exceeding an internal limit are truncated. This limit is determined by the MAXTOK definition in the source code, and is currently set to 15. .sp Normally, xref treats upper- and lower-case letters as different characters. The -f option causes all letters to be folded to lower-case. .sp Normally, the line numbers specified in the symbol table are relative to the current file being processed. Specification of the `-b' flag causes `' to be added to each line number. .fi .di out of storage .br .in +3 The file contains too many symbols or references to fit within the current limitations of xref. The size of the buffer is determined by the MAXBUF definition in the source code. .in -3 .fi .sa axref - cross reference generator for archives .au David Hanson and friends (U. of Arizona) .bu There should be a means of suppressing "junk" symbols such as "the", "a", etc. %%E 1