By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,605 Members | 1,491 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,605 IT Pros & Developers. It's quick & easy.

gnu indent: how to avoid extra indent?

P: n/a
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

--
Posted via a free Usenet account from http://www.teranews.com

Nov 15 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
dt wrote:
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.

Nov 15 '06 #2

P: n/a
dt wrote:
>
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.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Nov 15 '06 #3

P: n/a
dt wrote:
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
Dec 31 '06 #4

P: n/a
james of tucson wrote:
dt wrote:
>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
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)
Dec 31 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.