summaryrefslogtreecommitdiff
path: root/v4l/scripts/strip-trailing-whitespaces.sh
blob: 6e6c7d8bbf1acb319c6bf9add378fc4026a783d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/sh

# tmp dir for my files
WORK="${TMPDIR-/tmp}/${0##*/}-$$"
mkdir "$WORK" || exit 1
trap 'rm -rf "$WORK"' EXIT

for file in *.[ch]; do
	tmpfile="$WORK/${file}.$$"
	perl -ne 's/[ \t]+$//; print' < "${file}" > "${tmpfile}"
	diff -u "${file}" "${tmpfile}" | sed 		\
		-e "s|^--- ${file}|--- ${file}.orig|"	\
		-e "s|^+++ ${tmpfile}|+++ ${file}|"
	rm -f "$tmpfile"
done