I would like to have different settings for "pad parenthesis" for "constructs" and function calls. At the end I want to be able to really configure "kernel style" which looks like this: if (foo()) int foo(void) for (i = 0; i <= 10; i++) i.e. padding is outside for for/if/while and the like, but no padding for function calls and declarations. Reproducible: Always
Created attachment 73146 [details] Adds option to enable/disable padding parenthesis headers.
The attached patch should fix the issue. It applies to version 4.3.1 and the current trunk. I think the built in code style should be rechecked, if the padding should be really "outside" or just "headers". The patch enables padding parenthesis headers by default. However one problem remains (when using Qt): "foreach" is not in astyle's headers list for C/C++. It would be simple to change the astyle code to add "foreach". Though I think it would be better to make astyle more flexible at this point... http://astyle.sourceforge.net/astyle.html#_pad-header explains padding parenthesis headers.
Wow very cool, I thought astyle was simply too dump to figure this out and thought this was a wontfix. Thanks Rawk, could you please extend the patch to include "foreach" in the list of headers? And please put the patch on reviewboard.
The patch is now in reviewboard: https://git.reviewboard.kde.org/r/106032/ "foreach" is added to the list of headers and it is assured that "&" and "*" are not treated as operators at this point. Additionally the KDELibs style is fixed according to http://techbase.kde.org/Policies/Kdelibs_Coding_Style#Artistic_Style_.28astyle.29_automatic_code_formatting
Git commit 2862a82438fbbf8129f1c56234ccb482e41ca412 by Milian Wolff, on behalf of Dominic Tubach. Committed on 16/08/2012 at 20:46. Pushed by mwolff into branch '4.4'. Astyle formatter: add support for padding parenthesis headers The patch adds an option to enable/disable padding parenthesis headers in the astyle code formatter. For improved Qt compatibility, "foreach" is added to the list of headers and it is assured that "&" and "*" are not treated as operators at this point. The KDELibs and Qt styles are fixed to properly use this new feature. REVIEW: 106032 M +12 -1 formatters/astyle/astyle_formatter.cpp M +1 -0 formatters/astyle/astyle_formatter.h M +15 -0 formatters/astyle/astyle_preferences.cpp M +27 -17 formatters/astyle/astyle_preferences.ui M +3 -1 formatters/astyle/lib/ASFormatter.cpp M +6 -0 formatters/astyle/lib/ASResource.cpp http://commits.kde.org/kdevelop/2862a82438fbbf8129f1c56234ccb482e41ca412