summaryrefslogtreecommitdiff
path: root/dist/s_whitespace
blob: 74820a4f0e9667876388cbcd3ce5ca1b8272ffda (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#! /bin/sh

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

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

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

cd ..

# Scripts.
for f in `find dist -name '*.py' -name 's_*'`; do
	whitespace_and_empty_line $f
done

# C-language sources.
for f in `find bench examples ext src test \
    -name '*.[chi]' -o \
    -name '*.dox' -o \
    -name '*.in' -o \
    -name 'Makefile.am' |
    sed -e '/Makefile.in/d' \
	-e '/support\/power8/d'`; do
	whitespace_and_empty_line $f
done

# Python sources.
for f in `find test \
    -name '*.py' | sed '/3rdparty/d'`; do
	whitespace $f
done