summaryrefslogtreecommitdiff
path: root/v4l/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'v4l/scripts')
-rw-r--r--v4l/scripts/strip-trailing-whitespaces.sh15
1 files changed, 11 insertions, 4 deletions
diff --git a/v4l/scripts/strip-trailing-whitespaces.sh b/v4l/scripts/strip-trailing-whitespaces.sh
index 592320e6a..6e6c7d8bb 100644
--- a/v4l/scripts/strip-trailing-whitespaces.sh
+++ b/v4l/scripts/strip-trailing-whitespaces.sh
@@ -1,8 +1,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
- echo "### file"
- tmpfile="${file}.$$"
- perl -ne 's/[ \t]+$//; print' < "${file}" > "$tmpfile"
- diff -u "$file" "$tmpfile"
+ 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