Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site grkermit.UUCP Path: utzoo!watmath!clyde!floyd!whuxle!mit-eddie!genrad!grkermit!marks From: marks@grkermit.UUCP (Mark A. Swanson) Newsgroups: net.unix-wizards Subject: C Cross Reference: Description of tool with concise format Message-ID: <696@grkermit.UUCP> Date: Sun, 5-Feb-84 12:58:25 EST Article-I.D.: grkermit.696 Posted: Sun Feb 5 12:58:25 1984 Date-Received: Wed, 8-Feb-84 10:00:22 EST Organization: GenRad Inc., Concord, MA Lines: 59 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: 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: . 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 . { ... } 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 } 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 Mark Swanson decvax!genrad!grkermit!marks