summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/dist/s_whitespace
blob: 462504e40e7b462ce22dd4152988d95511ac8cee (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
#! /bin/sh

# Single space, newline at the end of file, 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.
# Add a newline to the end of the file if there is not one.
whitespace()
{
    ! head $1 | grep -q 'automatically generated by SWIG' || return
    (cat $1 && echo) | sed -e 's/[   ][      ]*$//' | \
        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 '*.[ch]' -o \
    -name '*.cpp' -o \
    -name '*.dox' -o \
    -name '*.in' -o \
    -name 's_*' -o \
    -name 'Makefile.am' |
    sed -e '/Makefile.in/d' \
        -e '/checksum\/power8/d' \
        -e '/3rdparty/d' \
        -e '/docs\/tools/d' \
        -e '/log\/log_auto/d' \
| while read f ; do
    whitespace $f
done

exit 0