mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Verych <olecom@flower.upol.cz>
To: kbuild-devel@lists.sourceforge.net
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	Jan Engelhardt <jengelh@computergmbh.de>,
	Sam Ravnborg <sam@ravnborg.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [patch] scripts: clean-whitespace.sh
Date: Fri, 8 Jun 2007 08:40:42 +0200	[thread overview]
Message-ID: <E1HwY9K-0008Jz-CG@flower> (raw)
In-Reply-To: <4668929C.7040209@zytor.com>

After running this script with filename as parameter,
look (with diff) for, what can be corrected.

Only "*.diff" and "*.patch" files are handled as patches.

Signed-off-by: Oleg Verych <olecom@flower.upol.cz>
--
 Two clean rules added, that can change look of damaged lines.
 Yet script still fits one ordinary screen, so read the code!

 test cases: include/linux/ipv6.h, arch/x86_64/lib/{copy_user, memcpy}.S

 It's like lguest -- just for fun.

 clean-whitespace.sh |   28 ++++++++++++++++++++++++++++
  1 file changed, 28 insertions(+)

--- /dev/null	2007-04-04 10:55:19.204075250 +0200
+++ linux-just-for-fun/scripts/clean-whitespace.sh	2007-06-08 07:53:21.000000000 +0200
@@ -0,0 +1,28 @@
+#!/bin/sh -e
+# clean whitespace damage; i/o = $1/$1.clean
+
+IFS='' ; t="`printf '\t'`" ; s=' ' ; s4="$s$s$s$s" ; w79=79 ;
+i="$1" ; o="$1.clean"
+strip_file_end='/^$/{N;s_^\n$_&_;T e;:n;N;s_^.*\n\n$_&_;t n;:e;};'
+not_patch_line='/^+[^+]/'
+
+case $1 in *[.]diff | *[.]patch)
+	file=patch ; sp='+[!+]' ; p='+' ; addr="$not_patch_line";;
+esac
+
+sed -n "${addr:-$strip_file_end} {
+s|[$t$s]*$||;	# trailing whitespace
+:next;		# x*8 spaces on the line start -> x*tabs
+s|^\([\n]*\)$p\($t*\)$s4$s4|\1$p\2$t|;t next;	# \n is needed after N command
+s|^\([\n]*\)$p\($t*\)$s*$t|\1$p\2$t|g;		# strip spaces between tabs
+s|$s4$s4$s$s*|$t$t|g				# more than 8 spaces -> 2 tabs
+s|$s*$t|$t|g	# strip spaces before tab; tradeoff: may break some alignment !
+};p" -- "$i" >"$o" && echo "
+please, see clean ${file:=source} file: $o
+"
+exec expand $i | while read -r line # check for long line
+do   [ ${#line} -gt $w79 ] && case "$line" in $sp*) echo \
+"at least one line wider than $w79 chars, found
+check your $file, please
+" 1>&2 ; exit ;; esac
+done

  parent reply	other threads:[~2007-06-08  6:28 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-03 20:47 [PATCH 08/19] scripts: Make cleanfile/cleanpatch warn about long lines 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
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                         ` Oleg Verych [this message]
2007-06-08  6:44                           ` [patch] scripts: clean-whitespace.sh 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=E1HwY9K-0008Jz-CG@flower \
    --to=olecom@flower.upol.cz \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=jengelh@computergmbh.de \
    --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®