bossert@ssc-vax.UUCP (John Bossert) (05/23/84)
Does anyone in Netland have a piece of code that would scan a set of C programs and generate a software tree of the include files? The program would need to handle several layers of includes. Thanks in advance, -- John Bossert Boeing Computer Services Seattle, WA uw-beaver!ssc-vax!bossert
dyer@vaxuum.DEC (Example #22) (05/28/84)
Re: #include file tree generator_______________________________________________ I would also like one of these. Anyone have one? <_Jym_>
rpw3@fortune.UUCP (05/31/84)
#R:ssc-vax:-16200:fortune:26900061:000:1361 fortune!rpw3 May 31 03:22:00 1984 On the principle that the best way to do jobs like this is to use existing tools plus a little something extra (K & P "Unix Prog. Env."), may I suggest starting by using the C pre-processor, which gives you a nice little trace of what file it's handling. Given these files: ==== a ==== ==== b ==== ==== c ==== ==== d ==== This is a This is b This is c This is d #include "b" #include "c" Back to a Back to b #include "d" The end. The command "cc -E a | grep '^# ' " gives: # 1 "a" # 1 "./b" # 1 "./c" # 3 "./b" # 3 "a" # 1 "./d" # 5 "a" Given that much, I strongly suggest that you can write a SIMPLE little C program which reads that output, puts it on a stack, outputs each line indented one more level, and if you see a line that matches anything in your stack (searching backwards from the end) pop the stack and the indentation level back to there (and don't print that line). That would give you the output below: # 1 "a" # 1 "./b" # 1 "./c" # 1 "./d" Further formatting is left as an exercise for the reader... Note that this correctly handles any includes which are buried in or generated from macros, since the C pre-processor knows about macros. Rob Warnock UUCP: {ihnp4,ucbvax!amd70,hpda,harpo,sri-unix,allegra}!fortune!rpw3 DDD: (415)595-8444 USPS: Fortune Systems Corp, 101 Twin Dolphin Drive, Redwood City, CA 94065