5 echo "usage: $0 <patch file>"
9 if [ "$1" = "" ] ; then
13 if [ "$1" = "--compile" ] ; then
18 SCRIPT_DIR
=$
(dirname $0)
19 if [ -e $SCRIPT_DIR/kchecker
] ; then
20 KCHECKER
=$SCRIPT_DIR/kchecker
21 STRIP
=$SCRIPT_DIR/strip_whitespace.pl
22 elif which kchecker |
grep kchecker
> /dev
/null
; then
24 STRIP
=strip_whitespace.pl
27 echo "kchecker script not found."
33 files
=$
(grep ^
+++ $PATCH | cut
-f 1 | cut
-b 5-)
34 if [ "$files" = "" ] ; then
38 if ! cat $PATCH |
patch -p1 --dry-run > /dev
/null
; then
39 echo "Couldn't apply patch"
43 before
=$
(mktemp
/tmp
/before.XXXXXXXXXX
)
44 after
=$
(mktemp
/tmp
/after.XXXXXXXXXX
)
47 for file in $files ; do
50 $STRIP $file > $before
51 if [ "$compile" = "true" ] ; then
52 if ! $KCHECKER --test-parsing --outfile=$before $file ; then
53 echo "warning: compile failed."
56 $STRIP $file > $before
57 cat $tmpfile >> $before
59 cat $PATCH |
patch -p1
61 if [ "$compile" = "true" ] ; then
62 if ! $KCHECKER --test-parsing --outfile=$after $file ; then
63 echo "warning: compile failed. *again*"
67 cat $tmpfile >> $after
69 cat $PATCH |
patch -p1 -R
71 if [ ! -s $before ] ; then
72 echo "Error: No result"
76 if diff $before $after > /dev
/null
; then
78 echo Only white space changed
81 echo '!!#$%@$%@^@#$^@#%@$%@$%@#%$@#%!!'
83 echo '!! This patch changes stuff !!'
85 echo '!!#$%@$%@^@#$^@#%@$%@$%@#%$@#%!!'
87 diff -u $before $after
89 rm -f $before $after $tmpfile