Have you got sick of fixing your sources CodingStyle by hand? Are you 
reintroducing violations because you've always programmed in a certain style 
and those kernel hacker have dictated an insane one which you'll never learn?

Stop that, the spamful company "BlaisorBlade Inc. " has the right solution for 
you, and this spam letter is going to explain ;-) !

Without using lindent, and with just a few sed/vim substitutions, it fixes 
most of the problems we keep having. I wrote most of it with vim, and I 
discovered it has another advantage: most of the substitutions also work on 
patches (well, not so straightforward, but anyway good).

Also, it calls quilt to create a patch for all this stuff, and can optionally 
do binary comparison to verify substitutions are safe (this is only coded, 
not tested).

The only exception is the one to move labels to the first column - a slightly 
different sub would be needed:

        sed -e 's/\<return\>(\(.*\))/return \1/' \
         -e 's/\<if\> \?(\(.*\)){/if (\1) {/'  \
         -e 's/\<if\>(\(.*\))/if (\1)/' \
         -e 's/\<for\> \?(\(.*\)){/for (\1) {/' \
         -e 's/\<for\>(\(.*\))/for (\1)/' \
         -e 's/\<while\> \?(\(.*\)){/while (\1) {/' \
         -e 's/\<while\>(\(.*\))/while (\1)/' \
         -e 's/^ \([a-z_]*:\)/\1/' \

This:
         -e 's/^ \([a-z_]*:\)/\1/'
would become this:
         -e 's/^\([ +-]\) \([a-z_]*:\)/\1\2/'

To yet test well:
- spaces to tabs (easy)
- binary comparison
Missing features:
- break if (foo) bar(); on two lines (probably won't do this one)
- do the work on patches
- have a sane cmd line interface (most of config is inside it).

Results: 
*) in less than 10 seconds (cache-hot) generates a 416k on arch/um and 
include/asm-um:

$ diffstat $(quilt top)|tail -n 1
 147 files changed, 2360 insertions(+), 2360 deletions(-)

*) doesn't clutter the source tree nor temp directories, if you have quilt 
installed.

I attach this with no guarantee at all, however! Bye!
-- 
Inform me of my mistakes, so I can add them to my list!
Paolo Giarrusso, aka Blaisorblade
http://www.user-mode-linux.org/~blaisorblade

Attachment: do-src-style-fix
Description: application/shellscript

Reply via email to