From da0f21e66775ad7f0b61a19cbee1d0394c6cf35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Sun, 19 May 2019 17:52:06 +0200 Subject: [PATCH] add script to replace tabs by spaces and removing trailing whitespaces --- .../remove_tabs_and_trailing_whitespaces.sh | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Scripts/developer_scripts/remove_tabs_and_trailing_whitespaces.sh diff --git a/Scripts/developer_scripts/remove_tabs_and_trailing_whitespaces.sh b/Scripts/developer_scripts/remove_tabs_and_trailing_whitespaces.sh new file mode 100644 index 00000000000..0e5c1ca9406 --- /dev/null +++ b/Scripts/developer_scripts/remove_tabs_and_trailing_whitespaces.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if ! git diff --exit-code > /dev/null || ! git diff --staged --exit-code > /dev/null ; then + echo 'Your working directory contains local modifications!' >&2 + exit 1 +fi + +if [ ! -f Installation/include/CGAL/version.h ]; then + echo "This script should be run at the root of a CGAL branch" >&2 + exit 1 +fi + +# replace tabs by two spaces in AABB-tree and Minkowski_sum_2 packages +find AABB_tree -name '*.h' -o -name '*.cpp' -o -name '*.txt' | xargs sed -i -E 's/\t/ /g' +find Minkowski_sum_2 -name '*.h' -o -name '*.cpp' -o -name '*.txt' | xargs sed -i -E 's/\t/ /g' + +#replace tabs by 8 spaces for all other packages +find . -name '*.h' -o -name '*.cpp' -o -name '*.hpp' -o -name '*.tcc' -o -name '*.txt' | xargs sed -i -E 's/\t/ /g' + +#remove trailing whitespace +find . -name '*.h' -o -name '*.cpp' -o -name '*.hpp' -o -name '*.tcc' -o -name '*.txt' | xargs sed -i -E 's/\s+$//'