%%s 0/0/0 %%d D 1.1 25-Mar-82 12:01:39 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- caxref 300 asc 25-mar-82 07:20:03 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- axref.r 8349 asc 25-mar-82 07:20:05 v1.1 (sw-tools v1.1) #-h- defns 814 asc 25-mar-82 07:19:40 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) define(EOR,RS) define(Push_back_size,10) # size of push back buffer #-h- main 1029 asc 25-mar-82 07:19:42 v1.1 (sw-tools v1.1) # axref - make cross reference list of named archive files DRIVER(xref) character name(MAXTOK), arg(MAXNAME) integer fd, fflag, nfiles, i, relnum integer open, getarg, index PB_DECL(Push_back_size) string usestr "usage: axref [-fr] [file] ..." string stdinp "-" data fflag/NO/, nfiles/0/, relnum/NO/ call query(usestr) call pbinit(Push_back_size) for (i = 1; getarg(i, arg, MAXNAME) != EOF; i = i + 1) if (arg(1) == '-' & arg(2) != EOS) { call fold(arg) if (index(arg, 'f') > 0) fflag = YES if (index(arg, 'r') > 0) relnum = YES } else { if (arg(1) == '-') fd = STDIN else fd = open(arg, READ) if (fd == ERR) call cant(arg) call doxref(arg, fd, fflag, relnum) if (fd != STDIN) call close(fd) nfiles = nfiles + 1 } if (nfiles == 0) call doxref(stdinp, STDIN, fflag, relnum) DRETURN end #-h- balloc 237 asc 25-mar-82 07:19:43 v1.1 (sw-tools v1.1) # balloc - allocate n words in storage array buf; return index integer function balloc(n) integer n include caxref nextbf = nextbf + n if (nextbf > MAXBUF) call error("out of storage.") return(nextbf - n) end #-h- doxref 1197 asc 25-mar-82 07:19:44 v1.1 (sw-tools v1.1) # doxref-generate cross reference list for file fd; fold if fflag = YES subroutine doxref(file, fd, fflag, relnum) integer fd, fflag, relnum integer t, root, lineno, i, lstlin character gettok character token(MAXTOK), file(FILENAMESIZE), name(FILENAMESIZE) include caxref lineno = 1 i = 1 call stcopy(file, 1, name, i) call chcopy('/', name, i) repeat { lstlin = lineno root = 0 nextbf = 1 repeat { t = gettok(token, MAXTOK, fd) if (t == EOF | t == EOR) break if (t == LETTER) { if (fflag == YES) call fold(token) call instl(token, lineno, root) } else if (t == '@n') lineno = lineno + 1 } if (lineno > lstlin) { call putlin(name, STDOUT) call putch(':', STDOUT) call putch('@n', STDOUT) call tprint(root) } if (t == EOR) { call scopy(token, 1, name, i) if (relnum == YES) lineno = 1 else lineno = lineno + 1 } } until (t == EOF) return end #-h- gettok 2022 asc 25-mar-82 07:19:45 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 ngetch, type integer i character c, lsttok, t data lsttok /'@n'/ for (c=ngetch(c, fd); c != EOF; c=ngetch(c, fd)) { if (lsttok == '@n' & c == '#') # check for "%#-h- " { i = 1 if (ngetch(c, fd) == '-') { call chcopy(c, token, i) if (ngetch(c, fd) == 'h') { call chcopy(c, token, i) if (ngetch(c, fd) == '-') { call chcopy(c, token, i) if (ngetch(c, fd) == ' ') # found an archive header { while (ngetch(c, fd) == ' ') ; token(1) = c for (i=2; ngetch(c, fd) != ' '; i=i+1) token(i) = c token(i) = EOS while (ngetch(c, fd) != '@n') ; lsttok = '@n' return(EOR) } } } } call chcopy(c, token, i) call pbstr(token) lsttok = '#' } else if (type(c) == LETTER) # start of name token { token(1) = c for (i = 2; ngetch(c, fd) != EOF; i = i + 1) { t = type(c) if (t == LETTER | t == DIGIT | t == '_') { if (i < size) token(i) = c } else break } call putbak(c) # went one too far if (i <= size) token(i) = EOS else token(size) = EOS lsttok = token(1) return(LETTER) } else if (c == '@n') { # newline must be returned lsttok = '@n' return('@n') } } lsttok = '@n' return(EOF) end #-h- instl 1171 asc 25-mar-82 07:19:46 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 caxref 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 553 asc 25-mar-82 07:19:47 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 caxref 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 742 asc 25-mar-82 07:19:48 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 caxref 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- axref.fmt 1431 asc 25-mar-82 07:20:08 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Axref (1) 11-Mar-82 cross reference symbols in archive files .sy axref [-fr] [file] ... .ds `axref' produces a cross-reference list of the symbols found 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 specified, of the file "-" is specified, `axref' reads the standard input. .sp `axref' differs from `xref' in that it generates a separate cross-reference list for each module found within an archive. Module boundaries are defined to be those lines which start with the string "#-h-", as generated by the file archiver. Each module is preceded with the label .sp file/module_name: .sp on the standard output. .sp A symbol is defined as a string of letters, digits and underlines 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 By default, `axref' differentiates between upper- and lower-case letters. The `-f' option causes all letters within symbols to be folded to a single case. .sp Normally, the line numbers specified in the symbol table are relative to the current file being processed. The `-r' option causes the line numbers specified to be relative to the start of the current archive module. .fl .sa xref - make a cross reference of symbols .di .au Joe Sventek .bu %%E 1