File: cleanup_code.sh

package info (click to toggle)
simutrans 124.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,880 kB
  • sloc: cpp: 160,224; ansic: 9,382; sh: 1,237; awk: 1,081; makefile: 932; javascript: 2
file content (9 lines) | stat: -rwxr-xr-x 534 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
#
# properly rename include guards (needs perl)
echo "Checking include guards"
find . -type f -name "*.h" | grep -v "squirrel/" | while read f; do guard="$(echo $f | cut -b 3- | tr '[[:lower:]]' '[[:upper:]]' | tr -C '[[:alnum:]]' '_' | rev | cut -c2- | rev)"; perl -i -p0e "s/(\n){2,}#ifndef [^\n]*\n#define [^\n]*(\n)+/\n\n#ifndef $guard\n#define $guard\n\n\n/" $f; done

#
# remove trailing spaces
echo "Removing trailing whitespaces"
find . -type f -name "*.h" -o -name "*.cc" | grep -v "squirrel" | xargs sed -i -e "s/[ \t]*$//"