473,473 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

gnu indent: how to avoid extra indent?

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
4 1705
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: hongping | last post by:
I am having problems transforming a xml doc into html with proper indenting. Here is the xslt <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0"...
4
by: Werner Partner | last post by:
I'm looking for something like that: http://www.sonoptikon.de/praxis-mt/test.php The text should have a certain indent, and from the left border should come a "marker" which goes over the text...
8
by: tintagel | last post by:
Hi everyone, I've just joined your group! I'm pretty new to HTML etc. Here's my problem: I'm attached to the idea of keeping content separate from formatting information, so I like putting...
2
by: Chris Seidel | last post by:
Hi, I have a submit-element with a background-image of 16x16 px and the following style: background-image: url("ok.gif"); background-repeat: no-repeat; text-indent: 20 px; The problem is,...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.