marks@grkermit.UUCP (Mark A. Swanson) (02/05/84)
We developed a format which allows a concise C cross reference format. While unavailable, others may be interested in it. It is aimed at supporting cases with LARGE programs composed of many modules. (I had a 60,000 line, 200 module program to maintain. Plus library utilities.) The output listing consists of: 1) A Table of Contents, listing the .h and .c files in alphabetical order, all .h first. Each entry provides: <file number> <full file name> <page of listing it starts on> 2) Each file then appears, in the above order. Each file starts on a new page. Each line of source is proceeded with an id of the form: <file number>.<line number> <c source> If your people like to do long lines or have very long files, you will have to be careful about wraparound, etc. 3) Then comes the cross reference. It has entries of the general form <token> <file num>.<line num><usage> { ... } e.g. FILE 1.124# 1.295 6.56 8.76 8.134 9.12... {for #define FILE } Gatetime 5.44 5.101 16.37= 16.142 { for global variable initialized in file 16 at line 37, used in files 5 and 16 } paldts 4.22<> 5.35<> 6.18<> 7.18<> { for #include <paldts.h> } pdout 14.127() 16.45 16.180 { for ftn pdout(): defined in file 14, called in file 16. } This provides quite readable cross references which stay significantly smaller than the listings. The usage markers help a lot in finding definitions and unused variables, functions, etc. The tool works about as following: 1) Collect all files names into a list and check that they exist (driven from a makefile equivalent). Handle .h defaults, archives, etc. 2) for (all files) set file number and write out TOC entry >tocfile for (each line) get line from file (gets(lbuf)) write out numbered listing of line: fprintf(lfile, "%d.%d %s",...) for (each token in line) fprintf(xfile, "%-8s %4d.%4d%s\n", ptok, filenum, linenum, getsymusage(lbuf, bufptr, ptok) ); 3) Do sort and unique proceedures on cross reference (xfile) 4) put together <tocfile> <lfile> <compressed form of xfile> Mark Swanson decvax!genrad!grkermit!marks