Menu

#649 Two cases where if-else are not formatted as expected

Future
works-for-me
None
C++
5
2016-03-22
2015-08-12
No

Hi,
I found two bugs with the formatting of two if-else statement.

The params are
nl_if_leave_one_liners=true
nl_after_semicolon=true
nl_after_brace_open=false
nl_if_brace=force
nl_brace_else=force
nl_elseif_brace=force
nl_else_brace=force
nl_else_if=remove

1st

if(x){statement;}
else{statement;}

formated to

if (x) statement; else statement;

instead of

if (x) statement;
else statement;

2nd

if(x) {
   statement;
   statement;
}
else statement;

formatted to

if (x)
   {
   statement;
   statement;
   }
else {statement; }

instead to

if (x)
   {
   statement;
   statement;
   }
else
   {
   statement;
   }

I was using UniversalIndentGUI and then tried to use uncrustify on the command line but got the same issue. Attached config file, source code with the two examples and a file how it should be at the end.
Regards
Sandro

1 Attachments

Discussion

  • Sandro Piras

    Sandro Piras - 2015-08-12

    Note: With the parameters set like described a lot of other if-else examples work as expected, this two were the only ones I found which didn't worked as expected

     
  • Guy Maurel

    Guy Maurel - 2015-11-09

    please use the option:
    nl_if_leave_one_liners=false

     
  • Sandro Piras

    Sandro Piras - 2015-11-11

    checked all my different if cases, they are all ok now. Thank you for your help :-)

     

    Last edit: Sandro Piras 2015-11-24
  • Guy Maurel

    Guy Maurel - 2016-03-22
    • status: open --> works-for-me
    • assigned_to: Guy Maurel