Re: Question about style when converting from K&R to ANSI C.

Erik Hensema
2003-06-02T15:42:48Z

Linus Torvalds (torvalds@transmeta.com) wrote:
> In article <20030601132626.GA3012@work.bitmover.com>,
> Larry McVoy <lm@bitmover.com> wrote:
>>On Sat, May 31, 2003 at 11:56:16PM -0600, Steven Cole wrote:
>>> Proposed conversion:
>>>
>>> int foo(void)
>>> {
>>> /* body here */
>>> }
>>
>>Sometimes it is nice to be able to see function names with a
>>
>> grep '^[a-zA-Z].*(' *.c
>>
>>which is why I've always preferred
>>
>>int
>>foo(void)
>>{
>> /* body here */
>>}
>
> That makes no sense.

But it does. Type /^foo <enter> and you're at the function definition. At
least when using vi, which is the editor everybody's using, right? ;-)

Also, when in working in a (too) long function body, type ?^{ and you're
at the start of the function body.

> Do you write your normal variable definitions like
>
> int
> a,b,c;
>
> too? No you don't, because that would be totally idiotic.

Indeed, searching for ^a will fail. There's no reason whatsoever why you'd
declare your variables that way.

--
Erik Hensema <erik@hensema.net>