Re: [dev] Tools that can format C code into dwm.c/st.c style
I've fiddled with it a bit, but it doesn't seem like there's a set of
flags that will Just Work.
Suckless style seems to be not to put spaces around binary operators (in
most cases), which indent(1) disagrees with quite stubbornly. At the
same time, indent(1) indents all comments by using tabs, which st.c
clearly doesn't do.
You can get kinda-sorta close with the braces and such, for actual code
that is, with the following:
indent a.c -brs -nprs -npcs -i8 -fc1 -br -brf -nsaf -nsai -nsaw -ncs \
-nfca -il0 -ce -nss -c0 -cd0 -ut -o out.c
sed -E -i 's/([^\t]+)\t+\/\*/\1 \/*/g' out.c # space comments
sed -i 's/switch (/switch(/g' out.c # simulate -nsas
If you put this in a script, you could try calling it on a range (say, a
function) in Vim to avoid mucking up the carefully hand-spaced enums in
the rest of the code.
Hope that helps.
Regards,
Wander
Received on Sat Jan 03 2015 - 00:27:57 CET
This archive was generated by hypermail 2.3.0
: Sat Jan 03 2015 - 00:36:07 CET