mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Verych <olecom@flower.upol.cz>
To: Matthew Wilcox <matthew@wil.cx>
Cc: Simon Arlott <simon@fire.lp0.eu>, Denis Cheng <crquan@gmail.com>,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Fixing lables after GNU indent (Re: [PATCH 1/2] run scripts/Lindent on it to match Documentation/CodingStyle)
Date: Sat, 21 Jul 2007 06:32:56 +0200	[thread overview]
Message-ID: <20070721043256.GH475@flower.upol.cz> (raw)
In-Reply-To: <20070720205418.GK14791@parisc-linux.org>

[]
> > > 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

  reply	other threads:[~2007-07-21  4:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-15  8:52 [PATCH 1/2] run scripts/Lindent on it to match Documentation/CodingStyle Denis Cheng
2007-07-15  8:52 ` [PATCH 2/2] add static delaration and init_module fixes Denis Cheng
2007-07-15  9:20 ` [PATCH 1/2] run scripts/Lindent on it to match Documentation/CodingStyle Christoph Hellwig
2007-07-15  9:53 ` Simon Arlott
2007-07-20 17:07   ` Matthew Wilcox
2007-07-20 17:36     ` Simon Arlott
2007-07-20 18:00       ` Matthew Wilcox
2007-07-21  6:11         ` Simon Arlott
2007-07-21 13:47           ` rae l
2007-07-21 13:52           ` Matthew Wilcox
2007-07-21 19:17             ` diffutils: C labels misdetected as functions (Was: [PATCH 1/2] run scripts/Lindent on it to match Documentation/CodingStyle) Simon Arlott
2007-07-22 18:38               ` diffutils: C labels misdetected as functions Paul Eggert
2007-07-22 19:16                 ` Simon Arlott
2007-07-22 21:30                   ` Junio C Hamano
2007-07-21  6:12         ` [PATCH 1/2] run scripts/Lindent on it to match Documentation/CodingStyle Simon Arlott
2007-07-20 20:50     ` Oleg Verych
2007-07-20 20:54       ` Matthew Wilcox
2007-07-21  4:32         ` Oleg Verych [this message]
2007-07-21 16:17     ` Jan Engelhardt
2007-07-20 17:33   ` Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070721043256.GH475@flower.upol.cz \
    --to=olecom@flower.upol.cz \
    --cc=crquan@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew@wil.cx \
    --cc=simon@fire.lp0.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®