summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/dist/s_whitespace
blob: 38eb5d6c2df75d0427ad39c2873ca61daa53104c (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
50
#! /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 examples ext src test \
    -name '*.[chi]' -o \
    -name '*.dox' -o \
    -name '*.in' -o \
    -name 'Makefile.am'`; do
	if expr "$f" : ".*/Makefile.in" > /dev/null; then
		continue
	fi
	whitespace_and_empty_line $f
done

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