Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
DLR-AMR
GitHub Repository: DLR-AMR/t8code
Path: blob/main/scripts/indent_all_files.sh
900 views
1
#!/bin/bash
2
3
# This file is part of t8code.
4
# t8code is a C library to manage a collection (a forest) of multiple
5
# connected adaptive space-trees of general element classes in parallel.
6
#
7
# Copyright (C) 2023 the developers
8
#
9
# t8code is free software; you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation; either version 2 of the License, or
12
# (at your option) any later version.
13
#
14
# t8code is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU General Public License for more details.
18
#
19
# You should have received a copy of the GNU General Public License
20
# along with t8code; if not, write to the Free Software Foundation, Inc.,
21
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
23
# This script indents all .c .h .cxx and .hxx
24
# files in t8code.
25
#
26
# Returns 0 if yes and not 0 if not.
27
#
28
29
#
30
# This script must be executed from the scripts/ folder.
31
#
32
if [ `basename $PWD` != scripts ]
33
then
34
if [ -d scripts ]
35
then
36
# The directory stack is automatically reset on script exit.
37
pushd scripts/ > /dev/null
38
else
39
echo ERROR: scripts/ directory not found.
40
exit 1
41
fi
42
fi
43
44
# Find all files with the appropriate suffix.
45
# Excluding the sc/ and p4est/ subfolders.
46
files=`./find_all_source_files.sh`
47
48
notallindented=0
49
50
INDENT=./t8indent.sh
51
52
echo This script will change all source files found in
53
echo $PWD/../src/
54
echo $PWD/../example/
55
echo $PWD/../test/
56
echo $PWD/../tutorials/
57
echo $PWD/../benchmarks/
58
echo $PWD/../api/
59
echo $PWD/../mesh_handle/
60
echo
61
read -p "Are you sure? ('Y' or 'y' to continue)" -n 1 -r
62
echo
63
if [[ $REPLY =~ ^[Yy]$ ]]
64
then
65
echo Indenting all files...
66
for file in $files
67
do
68
# Find also give as directories,
69
# so we ensure that $file is a proper
70
# file before checking for indentation.
71
if [ -f $file ]
72
then
73
$INDENT $file
74
status=$?
75
if test $status -ne 0
76
then
77
echo "File $file is not indented."
78
notallindented=1
79
fi
80
fi
81
done
82
83
if test $notallindented -eq 0
84
then
85
echo All files are indented.
86
fi
87
echo done.
88
else
89
echo Aborted.
90
fi
91
92
exit $notallindented
93
94