Argument declaration style (Was: ANSI C prototypes)

Barry Shein bzs at world.std.com
Wed Nov 7 12:58:43 AEST 1990


You're both wrong, use:

	void
	foo(x,y) int x,y;

Actually, I don't care that much if you put your args on the same line
or next and obviously with long declarations you eventually have to
break up the line (tho main(argc,argv) int argc; char **argv; seems
right, for example.)

But the point is that if you want to find a function's declaration you
should be able to use:

	grep '^foo' *.c

or even better:

	grep '^foo(' *.c

and find *only* the function definiton as that's the only place its
name will begin a line, any use within code will be indented at least
one stop.

I hardly ever want a list of every USAGE of a function, and that's
easy enough to get with this method (grep foo *.c) so it's not an
issue.

It's unfortunate that grep doesn't let you specify what is to be
listed when a hit occurs, the perfect thing would be something like:

	grep ^foo( -L .-1,. *.c

which would list the previous line and the hit (thus giving you
the type and the declaration) or even:

	grep ^foo( -L .-1,/^{/-1 *.c

Right now about the best you could do is use some sort of grep -n and
feed the result of that thru something else which can list particular
lines (sed or similar), but that requires going back thru the file
list for every match if there's more than one.

Seems like grep should have taken ed-like listing specifications as an
option (within reason of course, someone is going to point out how
painful this can be in the worst case, pipes etc, ok, fine, so ed
doesn't work either I suppose...)
-- 
        -Barry Shein

Software Tool & Die    | {xylogics,uunet}!world!bzs | bzs at world.std.com
Purveyors to the Trade | Voice: 617-739-0202        | Login: 617-739-WRLD



More information about the Comp.lang.c mailing list