LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [RFC] Auto-fixups for CodingStyle against major UML violations
@ 2007-03-31 15:37 Blaisorblade
  0 siblings, 0 replies; only message in thread
From: Blaisorblade @ 2007-03-31 15:37 UTC (permalink / raw)
  To: Jeff Dike, user-mode-linux-devel, LKML, Andrew Morton

[-- Attachment #1: Type: text/plain, Size: 2117 bytes --]

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 #2: do-src-style-fix --]
[-- Type: application/x-shellscript, Size: 2699 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-03-31 15:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-31 15:37 [RFC] Auto-fixups for CodingStyle against major UML violations Blaisorblade

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).