[net.unix-wizards] C Language Cross Referencing

arnold@gatech.UUCP (Arnold D. Robbins) (01/26/84)

	I have written a program (actually 2 C programs and a shell file) which
will cross reference identifiers in C source files.  The program does not
include ``#include'' files, but they can be handled simply by adding them
to the command line.
	My question is this:  I want to add the facility to handle constants
to the cross referencer.  I  would like to ask ``the net'' its opinion on
what kind of constants should be listed, should they be turn-offable;
if yes, separately, or together?  Suggestions for command syntax are welcome,
as well as suggestions for default behavior.
	As soon as I have finished and tested the cross referencer, and
commented/cleaned it up some, I will post it to net.sources.  It should work on
essentially any UN*X system, from Z80 up to VAX, as long as the unix sort
program is available.  The only changes necessary would be from rindex() to
strrchr() for UNIX 3-5 and later systems (vs. berkeley, V7, etc.), and that
would be in only one place.
	The cross referencer is pretty quick, using LEX to find identifiers,
sort to sort them, and then a small formatting program to fix up the output.
-- 
Arnold Robbins
CSNET: arnold@gatech		ARPA: arnold.gatech@CSNet-relay
UUCP:	...!{akgua,allegra,rlgvax,sb1,unmvax,ulysses,ut-sally}!gatech!arnold

sjh@Purdue.ARPA (01/30/84)

From:  Steve Holmes <sjh@Purdue.ARPA>

Bravo!  I am currently maintaining/developing a ~35000 line C program and
would love (read need) a good cross referencer.  As to the handling of 
constants, I would always want them turned on.  (I'm not sure what you 
mean by what 'kind' of constants).

On a different subject one thing which would be useful to me would be a
differentiation in the xref between the statements in the source which
define, reference and set a variable.  A function definition versus a function
reference would be easier but also useful.

for example 

	static int x;			line 10
		.
		.
		.
	a = 2 * x;			line 40
		.
		.
		.
	x++;				line 50


would produce:

	x	<file>.c 10	set	50 <any other such lines>
				refs	40 <any other references>

I realize this could present problems for the xreffer to find and collect all
of the references for each individual 'x' and keep them seperate.  Multiple
declarations also exist for many variables.  My program has most variables
declared in one .h file,  declared as external in another .h file and then
some are allocated space in a .c file.

Looking forward to your product.

Steve Holmes
sjh@purdue
...!decvax!pur-ee!mordred!sjh