lkml.org 
[lkml]   [2007]   [Jul]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectFixing lables after GNU indent (Re: [PATCH 1/2] run scripts/Lindent on it to match Documentation/CodingStyle)
From
[]
> > > sed -i -e 's/^\t* \(\w*:\)/ \1/' "$@"
> > >
> > > which will replace the leading tabs and spaces with one space.
> > > It should leave case labels unmolested, as they should be indented with
> > > tabs, not 6 spaces.
> > >
> > > Any regexp ninjas want to have a go at something better?
> >
> > I'm the one. Trying to write portable, optimized and easy to
> > understand scripts [0].
> >
> > Please, describe more what must be done, and i will do it. Case labels
> > are handled very strangely in you example.
>
> OK. indent will indent labels to a column number that's a multiple of
> 8, plus 6. So it may start in column 6, 14, 20, 28, etc. I'm not quite
> sure what the definition of a label is; I had it as \w*: up there, but I
> don't know if that would match the _. The point is to *not* handle case
> labels, only goto labels.

t=`printf '\t'`
sed -i "s_^\($t*\) *\([^:]*:\)_\1\2_" "$@"
^-_
I'm not sure about leaving one space `here, otherwise it removes
spaces between (supposedly right indented) line start, i.e. nothing or
tab(s), and a label, i.e. `label_name:' without space before colon;
`label_name' here actually not a colon, let's leave that kind of
breakage to compiler.

The variable $t is used for readability of the regex and because POSIX
BREs leave undefined characters after a backslash, POSIX sed defines
only \n as a new line.

--
-o--=O`C
#oo'L O
<___=E M
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-07-21 06:21    [W:0.069 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site