summaryrefslogtreecommitdiff
path: root/dist/s_whitespace
blob: 0de59bc58252b0fe01131e73d2716a0cec053900 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#! /bin/sh

# Single space and remove trailing whitespace from source files.
t=__wt.$$
trap 'rm -f $t' 0 1 2 3 13 15

# Clear lines that only contain whitespace, compress multiple empty lines
# into a single line, discard trailing empty lines.
whitespace()
{
	sed -e 's/[	 ][	 ]*$//' < $1 | \
	    cat -s | \
	    sed -e '${' -e '/^$/d' -e '}' > $t
	cmp $t $1 > /dev/null 2>&1 || (echo "$1" && cp $t $1)
}

cd ..

find bench dist examples ext src test \
    -name '*.[chi]' -o \
    -name '*.dox' -o \
    -name '*.in' -o \
    -name '*.py' -o \
    -name 's_*' -o \
    -name 'Makefile.am' |
    sed -e '/Makefile.in/d' \
        -e '/checksum\/power8/d' \
        -e '/3rdparty/d' \
        -e '/docs\/tools/d' \
| while read f ; do
	whitespace $f
done

exit 0