void identity(MATRIX m) { for (int i = 0 ; i < CMAX; i++) for (int j = 0; j < RMAX; j++) if (i == j) m[j][i] = 1.0; else m[j][i] = 0.0; }
becomes
void identity(MATRIX m) { for (int i = 0 ; i < CMAX; i++) for (int j = 0; j < RMAX; j++) if (i == j) { m[j][i] = 1.0; } else { m[j][i] = 0.0; } }
but it should have become
void identity(MATRIX m) { for (int i = 0 ; i < CMAX; i++) { for (int j = 0; j < RMAX; j++) { if (i == j) { m[j][i] = 1.0; } else { m[j][i] = 0.0; } } } }
astyle --version
Artistic Style Version 2.03
This bug is also in Artistic Style Version 2.05.1.
Upon some further searching, this looks like a duplicate of 320.
This has been annoying me for some time so i decided to fix it.
I've attached the patch files.
Feel free to modify / test till you heart's content.
UPDATE: I thought i had fixed it, turns out i didn't.
Last edit: Kaylx 2015-09-11
When making changes like this it is usually best to use the AStyleTest program.
It is probably going to require making the addBracketsToStatement() method recursive.
I didn't know such a thing existed. :)
I just modified the 2.05.1 Windows download code.
I see AStyleTest is in the code repo.
I will use it next time.
Thanks for pointing it out.