* [KJ] [patch] scripts: clean-whitespace.sh
@ 2007-06-09 3:13 Oleg Verych
2007-06-09 3:32 ` WANG Cong
2007-06-09 4:19 ` Oleg Verych
0 siblings, 2 replies; 3+ messages in thread
From: Oleg Verych @ 2007-06-09 3:13 UTC (permalink / raw)
To: kernel-janitors
If somebody have problems with whitespace damage: can't see it, don't
know how to deal with it, please see my proposition.
----- Forwarded message -----
Date: Fri, 8 Jun 2007 08:40:42 +0200
From: Oleg Verych
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" ; w79y ;
+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
----- End forwarded message -----
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [KJ] [patch] scripts: clean-whitespace.sh
2007-06-09 3:13 [KJ] [patch] scripts: clean-whitespace.sh Oleg Verych
@ 2007-06-09 3:32 ` WANG Cong
2007-06-09 4:19 ` Oleg Verych
1 sibling, 0 replies; 3+ messages in thread
From: WANG Cong @ 2007-06-09 3:32 UTC (permalink / raw)
To: kernel-janitors
On Sat, Jun 09, 2007 at 05:13:36AM +0200, Oleg Verych wrote:
>If somebody have problems with whitespace damage: can't see it, don't
>know how to deal with it, please see my proposition.
>
In fact, there's already a Perl script that can do this in kernel source.
See scripts/cleanfile to learn more.
--
You talk of times of peace for all, and then prepare for war.
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [KJ] [patch] scripts: clean-whitespace.sh
2007-06-09 3:13 [KJ] [patch] scripts: clean-whitespace.sh Oleg Verych
2007-06-09 3:32 ` WANG Cong
@ 2007-06-09 4:19 ` Oleg Verych
1 sibling, 0 replies; 3+ messages in thread
From: Oleg Verych @ 2007-06-09 4:19 UTC (permalink / raw)
To: kernel-janitors
On Sat, Jun 09, 2007 at 11:32:05AM +0800, WANG Cong wrote:
> On Sat, Jun 09, 2007 at 05:13:36AM +0200, Oleg Verych wrote:
> >If somebody have problems with whitespace damage: can't see it, don't
> >know how to deal with it, please see my proposition.
> >
>
> In fact, there's already a Perl script that can do this in kernel source.
>
> See scripts/cleanfile to learn more.
Exactly. That's why i've wrote this
- user-friendly, rather than "this
can be a highly destructive operation. Use with caution." one.
- PATCH and SOURCE files supporting
- 1024 bytes with all comments
script!
____
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-06-09 4:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-09 3:13 [KJ] [patch] scripts: clean-whitespace.sh Oleg Verych
2007-06-09 3:32 ` WANG Cong
2007-06-09 4:19 ` Oleg Verych
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.