mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Verych <olecom@flower.upol.cz>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	kbuild-devel@lists.sourceforge.net,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [kbuild-devel] [PATCH 08/19] scripts: Make cleanfile/cleanpatch warn about long lines
Date: Tue, 5 Jun 2007 16:57:59 +0200	[thread overview]
Message-ID: <20070605145759.GP7266@flower.upol.cz> (raw)
In-Reply-To: <20070605141254.GA24722@uranus.ravnborg.org>

On Tue, Jun 05, 2007 at 04:12:54PM +0200, Sam Ravnborg wrote:
> On Tue, Jun 05, 2007 at 03:38:34PM +0200, Oleg Verych wrote:
> > On Tue, Jun 05, 2007 at 10:19:59AM +0200, Sam Ravnborg wrote:
> > []
> > > If on the other hand you are proposing a script to clean whitespace
> > > damage in the code then git already does this nicely.
> > 
> > I've read that too quickly, sorry. What then all that clean scripts
> > are for?
> cleanfile compress spaces to tabs where appropriate. It does more
> than just warn about too long lines and remove leading whitespace.

Ah!

It's not an occasion, that this script does job of two, you are referring
to. I should add documentation to this script, that will far longer, that
script itself.

-*- slightly i/o optimized <clean-whitespace.sh> -*-
#!/bin/sh -e
# clean whitespace damage; i/o=stdin/stdout
#
IFS='' ; t="`printf '\t'`" ; s=' ' ; s7="$s$s$s$s$s$s$s" ; w79=79 ;
case $0 in *diff* | *patch*) p='+' ; s='';; esac

expand | while read line
do case "$line" in
   ++*) echo "$line";;
   $p*)	[ ${#line} -gt $w79 ] && : ${long:=line}
	echo "$line" | sed "/^$p/{s_ *\$__;s_^$p$s7${s}_$p${t}_;s_$s7 _${t}_g}"
	;;
     *) echo "$line";;
   esac
done
[ -n "$long" ] && echo "at least one line, wider than $w79 chars, found" 1>&2

-*-

First line stops word splitting, puts tab symbol in t, space in s,
seven spaces to s7 and line width limit to w79.

Second -- adjust set variables for need of unified diff processing, if
name of the script $0 (can be changed to match command-line
parameters) have "diff" or "patch".

Last -- bark, if there is at least one line longer that w79.

Rest is processing of files/patches to expand(posix tool) tabs to spaces
then:
- patches are processed only by lines, starting from `+', but not `++'
- remove trailing whitespace;
- substitute eight spaces to one tab symbol
- patches have "linestart`+tab'" expanded to seven spaces, due to `+' and
  tabstop, thus seven spaces are substituted in this case.

Anything else, if have not noticed in whitespace damage matching can be
added on request ;)

> Please look at latest -git tree if you are trying to improve
> the clean* scripts or add counterparts.
> 
> Thanks,
> 	Sam
____

  reply	other threads:[~2007-06-05 14:47 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-03 20:47 Sam Ravnborg
2007-06-04 16:07 ` Jan Engelhardt
2007-06-05  7:33 ` [kbuild-devel] " Oleg Verych
2007-06-05  8:19   ` Sam Ravnborg
2007-06-05 12:48     ` Oleg Verych
2007-06-05 13:38     ` Oleg Verych
2007-06-05 14:12       ` Sam Ravnborg
2007-06-05 14:57         ` Oleg Verych [this message]
2007-06-05 15:11           ` Oleg Verych
2007-06-06 17:45             ` Another version of cleanfile/cleanpatch (Re: [PATCH 08/19] scripts: Make cleanfile/cleanpatch warn about long lines) Oleg Verych
2007-06-06 17:50               ` Sam Ravnborg
2007-06-06 19:14                 ` Another version of cleanfile/cleanpatch Oleg Verych
2007-06-07 14:36                   ` Jan Engelhardt
2007-06-07 23:06                     ` Oleg Verych
2007-06-07 23:19                       ` [kbuild-devel] " H. Peter Anvin
2007-06-08  1:35                         ` Oleg Verych
2007-06-08  6:40                         ` [patch] scripts: clean-whitespace.sh Oleg Verych
2007-06-08  6:44                           ` Andrew Morton
2007-06-08 14:28                             ` Sam Ravnborg
2007-06-08 15:02                               ` Oleg Verych
2007-06-08 19:05                                 ` Sam Ravnborg
2007-06-08 21:07                                   ` Oleg Verych
2007-06-08  5:27                       ` Another version of cleanfile/cleanpatch Jan Engelhardt

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=20070605145759.GP7266@flower.upol.cz \
    --to=olecom@flower.upol.cz \
    --cc=akpm@linux-foundation.org \
    --cc=kbuild-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sam@ravnborg.org \
    /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®