Xref: utzoo comp.lang.c:33480 alt.religion.computers:2011 Path: utzoo!utgpu!cs.utexas.edu!uunet!world!bzs From: bzs@world.std.com (Barry Shein) Newsgroups: comp.lang.c,alt.religion.computers Subject: Re: Argument declaration style (Was: ANSI C prototypes) Message-ID: Date: 7 Nov 90 01:58:43 GMT References: <1990Nov2.030556.27759@ccu.umanitoba.ca> <3933.27353319@cc.helsinki.fi> <_1X6_32@xds13.ferranti.com> <3944.27367fb2@cc.helsinki.fi> <1990Nov06.233654.29974@dirtydog.ima.isc.com> Sender: bzs@world.std.com (Barry Shein) Organization: The World Lines: 52 In-Reply-To: karl@ima.isc.com's message of 6 Nov 90 23:36:54 GMT 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@world.std.com Purveyors to the Trade | Voice: 617-739-0202 | Login: 617-739-WRLD