[comp.lang.c] Indent question

roy%cybrspc@cs.umn.edu (Roy M. Silvernail) (11/14/90)

I have just picked up GNU Indent for MS-DOS. Unfortunately, no
documentation came with it. I'd like to know if the following is
possible...

Indent (both GNU and the previous version I found on SIMTEL) formats all
function declarations like this:

int this_function(int param)
{
        do_something();
}

but I prefer this:

int this_function(int param) {
        do_something();
}

Can I get indent to use my preferred brace style, or must I hack the
source?  (if I have to hack source, can someone point me to GNU source
for indent?)

Thanks in advance. E-mail replies would save bandwidth, and I'll
summarize if there's any interest in this.
--
Roy M. Silvernail |+|  roy%cybrspc@cs.umn.edu  |+| #define opinions ALL_MINE;
main(){float x=1;x=x/50;printf("It's only $%.2f, but it's my $%.2f!\n",x,x);}
"This is cyberspace." -- Peter da Silva  :--:  "...and I like it here!" -- me

yedinak@motcid.UUCP (Mark A. Yedinak) (11/17/90)

roy%cybrspc@cs.umn.edu (Roy M. Silvernail) writes:

:I have just picked up GNU Indent for MS-DOS. Unfortunately, no
:documentation came with it. I'd like to know if the following is
:possible...

:Indent (both GNU and the previous version I found on SIMTEL) formats all
:function declarations like this:

:int this_function(int param)
:{
:        do_something();
:}

:but I prefer this:

:int this_function(int param) {
:        do_something();
:}

:Can I get indent to use my preferred brace style, or must I hack the
:source?  (if I have to hack source, can someone point me to GNU source
:for indent?)

Consulting the man page for indent on the Suns's shows there is no way to tell
indent to do this. I am not sure if GNU indent follows the BSD version as far as
its options, so I am not sure if this helps.

The only other thing I question, is why declare your functions that way. I
realize there is the stylistic difference when it comes to if, while, for
statements, but this is the first time I have ever seen anyone wanting to format
functions in this manner. My only reservation to using this style, is that it is
radically differnet (at least from all the code, books, etc. I have ever seen)
from the norm.


-- 
Mark A. Yedinak - uunet!motcid!yedinak 		*  "Don't take life too
Motorola - General Systems Sector		*   seriously, you will
3205 Wilke Road, Arlington Heights, IL 60004	*   never get out of it
708-632-2874  (I said it, not the big M)	*         ALIVE!"

karl@ima.isc.com (Karl Heuer) (11/18/90)

In article <5334@catfish11.UUCP> yedinak@motcid.UUCP (Mark A. Yedinak) writes:
>roy%cybrspc@cs.umn.edu (Roy M. Silvernail) writes:
>[I want to tell indent to use this style:]
>>	int this_function(int param) {
>>	}
>
>The only other thing I question, is why declare your functions that way. I
>realize there is the stylistic difference when it comes to if, while, for
>statements, but this is the first time I have ever seen anyone wanting to
>format functions in this manner.

Why?  Because it's consistent with the common style for internal blocks:
	if (...) {
	}

>My only reservation to using this style, is that it is radically differnet
>(at least from all the code, books, etc. I have ever seen) from the norm.

I expect this will be changing now that prototypes have obviated the need for
the extra vertical space.

Karl W. Z. Heuer (karl@ima.isc.com or uunet!ima!karl), The Walking Lint