views:

246

answers:

2

I'm using astyle which is great for applying standard style to existing code. However I've noticed that when it comes across this:

ostringstream myStream;
myStream << 1
         << 2;

it reformats to this:

ostringstream myStream;
myStream << 1
<< 2;

Here's my options file: (version 1.23)

--indent=spaces
--brackets=break
--indent-switches
--indent-namespaces
--min-conditional-indent=4
--break-closing-brackets
--pad-paren-in
--unpad-paren
--convert-tabs

Is there any way to make it line up the "<<" on the next line?

Edit:

I also tried version 1.22 with the following file (test.cpp):

void main()
{
    ostringstream myStream;
    myStream << 1
             << 2;
}

with the following options (format.txt):

--indent=spaces
--brackets=break-closing
--indent-switches
--indent-namespaces
--min-conditional-indent=4
--pad=paren-in
--unpad=paren
--convert-tabs

and the following command line:

astyle --options=format.txt test.cpp

which produced this:

void main()
{
    ostringstream myStream;
    myStream << 1
    << 2;
}
+4  A: 

Final Conclusion is it's a bug see bottom

I tried to replicate your problem and was unable to get the behavior you are talking about (OP question update negates this)

Edit: (deleted content to update)

Parameter names have changed between 1.22 and 1.23.

If neither solves your problem, try uploading more code as an example, or otherwise try to replicate your problem using only the code you pasted here. (Done by OP)

I've also found that the order of the options seems to have made a difference on occasion. For example:

astyle --indent=tab --style=ansi test.cpp

is not the same as:

astyle --style=ansi --indent=tab test.cpp

Specifying the "--style=ansi" second effectively negates the "--indent=tab".

I would not be surprised if this might be your issue.

...But after playing around with this for 20 min, I'm convinced it's an astyle bug.

Edit to include link to bug: bug Thanks Markh44

Catskul
Thanks for the reply. I was using v1.23 and those options are correct for that version. I got version 1.22 and changed the options for that version but I get the same problem (see updated question).
markh44
+2  A: 

@Catskul, you're right, it's a bug.

I eventually found this:

http://sourceforge.net/tracker/index.php?func=detail&amp;aid=1713990&amp;group_id=2319&amp;atid=102319

markh44