bugGNU indent - Bugs: bug #42355, option to insert braces for...

 
 

bug #42355: option to insert braces for single-statements for conditionals

Submitted by:  None
Submitted on:  Wed 14 May 2014 12:52:05 PM UTC  
 
Category:  C Severity:  3 - Normal
Item Group:  Wishlist Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 14 May 2014 12:52:05 PM UTC, original submission:

(aka "One True Brace Style", OTBS, 1TBS, a stricter variant of K&R)

That is, to convert

if (a) foo();
if (b) bar(); else baz();
while (c) zap();
do re() while (mi);
for (...) blah();

into

if (a) {
foo();
}
if (b) {
bar();
} else {
baz();
}
while (c) {
zap();
}
do {
re();
} while (mi);
for (...) {
blah();
}

Handling of comments is a bit tricky, I guess the idea would be to insert the braces between the conditional and any possibly trailing comment:

if (a) /* foo */
/* bar */
foo(); /* baz */

would become

if (a) { /* foo */
/* bar */
foo(); /* baz */
}

I think there could be conversely an option to remove such braces, to turn

if (a) {
foo();
}

but that would be anti-1TBS...

into

if (a)
foo;

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

 

 

No changes have been made to this item

Back to the top


Powered by Savane 3.3