2014-09-17 10:30:33 +03:00
|
|
|
#!/bin/sh
|
|
|
|
set -euv
|
|
|
|
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
|
|
|
header_files="$script_dir"/../src/*/*.h
|
|
|
|
cpp_files="$script_dir"/../src/*/*.cpp
|
|
|
|
|
2014-09-19 15:54:23 +03:00
|
|
|
header_files+=" ""$script_dir"/../test/testmodules/*/*.h
|
2014-09-18 21:29:15 +03:00
|
|
|
cpp_files+=" ""$script_dir"/../test/testmodules/*/*.cpp
|
2014-09-17 10:30:33 +03:00
|
|
|
|
2014-09-19 12:48:34 +03:00
|
|
|
header_files+=" "$(find "$script_dir"/../builtin -name '*.h')
|
|
|
|
cpp_files+=" "$(find "$script_dir"/../builtin -name '*.cpp')
|
2014-09-17 10:30:33 +03:00
|
|
|
|
2014-09-19 18:44:26 +03:00
|
|
|
header_files+=" "$(find "$script_dir"/../3rdparty/c55lib -name '*.h')
|
|
|
|
cpp_files+=" "$(find "$script_dir"/../3rdparty/c55lib -name '*.cpp')
|
|
|
|
|
2014-09-17 10:30:33 +03:00
|
|
|
echo "header_files: $header_files"
|
|
|
|
echo "cpp_files: $cpp_files"
|
|
|
|
|
|
|
|
# Fix all that astyle is capable of
|
2014-09-17 11:43:46 +03:00
|
|
|
# Note: Astyle's character limit doesn't count tabs as multiple spaces.
|
2014-09-17 20:58:12 +03:00
|
|
|
basestyle="-n -z2 -W3 -k3 -p -Y -K -t4 -m1 -xC80"
|
|
|
|
astyle $basestyle -N $header_files
|
|
|
|
astyle $basestyle $cpp_files
|
2014-09-17 10:30:33 +03:00
|
|
|
|
|
|
|
# Remove spaces before semicolons
|
|
|
|
sed -i -e 's/ *;/;/g' $header_files $cpp_files
|
|
|
|
|
|
|
|
# Fiddle around with spacing
|
|
|
|
sed -i -e 's/\(for\|while\|if\) (/\1(/g' $header_files $cpp_files
|
|
|
|
sed -i -e 's/) {/){/g' $header_files $cpp_files
|
|
|
|
sed -i -e 's/}[\t ]*else[\t ]*{/} else {/g' $header_files $cpp_files
|
|
|
|
sed -i -e 's/ << /<</g' $header_files $cpp_files
|
|
|
|
sed -i -e 's/ >> />>/g' $header_files $cpp_files
|
|
|
|
sed -i -e 's/^\(\s*\(EXPORT\|virtual\|\)\s*[a-zA-Z0-9_:,]*\) \*\([a-zA-Z0-9_:,]*(\)/\1* \3/g' $header_files $cpp_files
|
|
|
|
sed -i -e 's/^\(\s*\(EXPORT\|virtual\|\)\s*[a-zA-Z0-9_:,]*\) &\([a-zA-Z0-9_:,]*(\)/\1& \3/g' $header_files $cpp_files
|
|
|
|
sed -i -e 's/ \*)/*)/g' $header_files $cpp_files
|
|
|
|
sed -i -e 's/ \*>/*>/g' $header_files $cpp_files
|
|
|
|
sed -i -e 's/ &)/&)/g' $header_files $cpp_files
|
|
|
|
sed -i -e 's/ &>/&>/g' $header_files $cpp_files
|
|
|
|
sed -i -e 's/\*\s\+>/\*>/g' $header_files $cpp_files
|
|
|
|
sed -i -e 's/ + "/+"/g' $header_files $cpp_files
|
|
|
|
sed -i -e 's/" + /"+/g' $header_files $cpp_files
|
2014-09-20 20:20:54 +03:00
|
|
|
sed -i -e 's/" *+$/"+/g' $header_files $cpp_files
|
2014-09-17 23:05:05 +03:00
|
|
|
sed -i -e 's/^\(\t\+\) \+/\1\t\t/g' $header_files $cpp_files
|
2014-09-17 10:30:33 +03:00
|
|
|
|