modernize: Reformat ALL the source... again!
[quassel.git] / scripts / manage / format_source.sh
1 #!/bin/sh 
2
3 # format_source.sh dirname  - indent the whole source tree
4 # format_source.sh filename - indent a single file
5
6 if [ -d "$1" ]; then
7 #echo "Dir ${1} exists"
8
9 file_list=`find ${1} -name "*.cpp" -or -name "*.h" -type f`
10 for file2indent in $file_list
11 do 
12 echo "Indenting file $file2indent"
13 #!/bin/bash
14 uncrustify -f "$file2indent" -c "./format_source.cfg" -o indentoutput.tmp
15 mv indentoutput.tmp "$file2indent"
16
17 done
18 else
19 if [ -f "$1" ]; then
20 echo "Indenting one file $1"
21 #!/bin/bash
22 uncrustify -f "$1" -c "./format_source.cfg" -o indentoutput.tmp
23 mv indentoutput.tmp "$1"
24
25 else
26 echo "ERROR: As parameter given directory or file does not exist!"
27 echo "Syntax is: format_source.sh dirname filesuffix"
28 echo "Syntax is: format_source.sh filename"
29 echo "Example: format_source.sh temp cpp"
30 exit 1
31 fi
32 fi