how to suppress "indent" from performing functions not specified in the options?

D

Divya

I want to use indent to selectively format some code anomalies. For
example, braces after if, etc. But, when I use the indent progam with -
bl option, it does other things as well and changes the whole source
code to some coding style. It's probably the GNU coding style. But, I
want only the "braces after if" to be fixed and rest of the source
code to be untouched. How can this be done?
 
R

Richard Heathfield

Divya said:
I want to use indent to selectively format some code anomalies.

Why are you asking in comp.lang.c? Perhaps comp.unix.programmer or
comp.os.linux.development.apps would be a better starting point.
 
T

Tim Prince

Richard said:
Divya said:


Why are you asking in comp.lang.c? Perhaps comp.unix.programmer or
comp.os.linux.development.apps would be a better starting point.
What about using indent on Windows, as I usually do, even though I work
more often on linux? Here, at least, a response was elicited.
 
R

Richard Heathfield

Tim Prince said:
What about using indent on Windows, as I usually do, even though I
work
more often on linux?

Whoops! You're quite right. I should have been more general in my reply.
My apologies to the OP. (Indeed, a glance at the article's headers
suggests that the OP is indeed using Windows, although it's hard to be
certain nowadays.) So I should add comp.os.ms-windows.programmer.win32
to the mix, I guess.
 
T

Thomas Dickey

Divya said:
I want to use indent to selectively format some code anomalies. For
example, braces after if, etc. But, when I use the indent progam with -
bl option, it does other things as well and changes the whole source
code to some coding style. It's probably the GNU coding style. But, I
want only the "braces after if" to be fixed and rest of the source
code to be untouched. How can this be done?

short - you can't, because indent writes a completely new version of the
file, token-by-token. The best you can achieve with it is to setup
options with indent to closely match what you want, and use the *INDENT-ON*
and *INDENT-OFF* comments to block out changes to lines that you do not
want altered.
 
C

CBFalconer

Richard said:
Tim Prince said:

Whoops! You're quite right. I should have been more general in my
reply. My apologies to the OP. (Indeed, a glance at the article's
headers suggests that the OP is indeed using Windows, although it's
hard to be certain nowadays.) So I should add
comp.os.ms-windows.programmer.win32 to the mix, I guess.

Try comp.os.msdos.djgpp for a DOS version that will run happily
under Windoze.
 
C

Chris Torek

Divya said:
Why are you asking in comp.lang.c? Perhaps comp.unix.programmer or
comp.os.linux.development.apps would be a better starting point.

As someone else noted, those are quite possibly the wrong groups for
the redirection.

To the original poster, though, be careful about where you ask and
the replies you get: there are multiple, differing versions of
"indent", which behave differently. Answers you get here in
comp.lang.c may not be correct for whichever version of indent you
have. Several of the GNU versions (you probably have one of those)
have quite a few options for controlling the results -- you could
spend weeks fiddling with them all. :)
 
C

CBFalconer

Chris said:
As someone else noted, those are quite possibly the wrong groups for
the redirection.

To the original poster, though, be careful about where you ask and
the replies you get: there are multiple, differing versions of
"indent", which behave differently. Answers you get here in
comp.lang.c may not be correct for whichever version of indent you
have. Several of the GNU versions (you probably have one of those)
have quite a few options for controlling the results -- you could
spend weeks fiddling with them all. :)

Actually, IMO, if you read the manual it is quite straight
forward. I setup and use the following (one line) several years
ago:

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

That line lives in indent.pro. My only real objection is the
handling of the procedure names.
 
J

Jack Klein

I want to use indent to selectively format some code anomalies. For
example, braces after if, etc. But, when I use the indent progam with -
bl option, it does other things as well and changes the whole source
code to some coding style. It's probably the GNU coding style. But, I
want only the "braces after if" to be fixed and rest of the source
code to be untouched. How can this be done?

Sorry, but the use of third party programs like pretty printers and
formatters is not defined by the C standard, not part of the language,
and completely off-topic here.

Try a gcc support group, one of their mailing lists.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
 
J

Joe Wright

Divya said:
I want to use indent to selectively format some code anomalies. For
example, braces after if, etc. But, when I use the indent progam with -
bl option, it does other things as well and changes the whole source
code to some coding style. It's probably the GNU coding style. But, I
want only the "braces after if" to be fixed and rest of the source
code to be untouched. How can this be done?
GNU indent is available in source code. I recommend you download it and
compile indent for your own system.

Then examine the source code. See how it works. Tweak it here and there
until it does what you want.
 
T

Thomas Dickey

Jack Klein said:
Try a gcc support group, one of their mailing lists.

yawn - a regular poster operating on the assumption that giving misleading
advice is preferable to letting the rest of the mob cast stones.
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top