gnu indent: how to avoid extra indent?

D

dt

Greetings,

I'm having some trouble understanding the plethora of options
available for GNU indent for my C code.

Except for the function's opening {, I want all code to line
up under the opening { of the block it resides in.

Let me explain with an example. I'm using this command,

gindent -npro -kr -bl -bli4 -nce < ncmp.c > ncmp2.c

and ncmp2.c is neatly formatted like this,

int32_t dcrp_oidncmp(dcroid_t * a, dcroid_t * b, size_t n)
{
size_t i;
size_t szA = OID_LEN(a);
size_t szB = OID_LEN(b);

if (n == 0)
{
return 0;
}
else if (szB == 0)
{
return 1;
}
else
{
for (i = 0; i < n && i < szA && i < szB; i++)
{
if (OID_AT(a, i) > OID_AT(b, i))
return 1;
else if (OID_AT(a, i) < OID_AT(b, i))
return -1;
}
return 0;
}
}

However, notice the extra indention of code for inner blocks;
I want output to omit that extra indention, like this output,

int32_t dcrp_oidncmp(dcroid_t * a, dcroid_t * b, size_t n)
{
size_t i;
size_t szA = OID_LEN(a);
size_t szB = OID_LEN(b);

if (n == 0)
{
return 0;
}
else if (szB == 0)
{
return 1;
}
else
{
for (i = 0; i < n && i < szA && i < szB; i++)
{
if (OID_AT(a, i) > OID_AT(b, i))
return 1;
else if (OID_AT(a, i) < OID_AT(b, i))
return -1;
}
return 0;
}
}

Except for the function's opening {, all code is lined up
under the opening { of the block it resides in.

I don't seem to see any options that turn off this extra
indent. How do I do this? Any ideas?

Regards,

David
 
S

santosh

dt said:
Greetings,

I'm having some trouble understanding the plethora of options
available for GNU indent for my C code.
[snip]

As your question deals with GNU indent, try posting to comp.os.linux or
similar groups. Maybe even comp.programming.
 
C

CBFalconer

dt said:
I'm having some trouble understanding the plethora of options
available for GNU indent for my C code.

Whether or not you use DJGPP, download ind229b.zip from the djgpp
site (www.delorie.com) and extract the man and info sections. The
info pages are best. If you are using a *IX system you will
probably need to convert the line endings, which unzip can do.
 
J

james of tucson

dt said:
I don't seem to see any options that turn off this extra
indent. How do I do this? Any ideas?

The syntax for indent is pretty arcane, I would say "baroque", and I
don't care for it. I can't answer your question directly, but here is
the "indent.pro" I use. Let me know if you like the results better than
the default or the switches you use:

-bad -bap -bbo -bc -br -brs -ncdb -ce -ci4 -cli4
-cp33 -di4 -fc1 -fca -hnl -i4 -ip4 -l75 -lp -npcs -nprs -npsl
-saf -sai -saw -sc -nsob -nss -ts4 -nut -c4
 
C

CBFalconer

james said:
The syntax for indent is pretty arcane, I would say "baroque", and I
don't care for it. I can't answer your question directly, but here is
the "indent.pro" I use. Let me know if you like the results better than
the default or the switches you use:

-bad -bap -bbo -bc -br -brs -ncdb -ce -ci4 -cli4
-cp33 -di4 -fc1 -fca -hnl -i4 -ip4 -l75 -lp -npcs -nprs -npsl
-saf -sai -saw -sc -nsob -nss -ts4 -nut -c4

And here is the one I use on indent 2.2.9

-kr -l66 -i3 -bad -di16 -lc66 -nce -ncs -cbi0 -bbo -pmt -psl -ts1
-cdw


--
Some informative links:
<http://members.fortunecity.com/nnqweb/> (newusers)
<http://www.catb.org/~esr/faqs/smart-questions.html>
<http://www.caliburn.nl/topposting.html>
<http://www.netmeister.org/news/learn2quote.html>
<http://cfaj.freeshell.org/google/> (taming google)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top