Blame view
misc/maintenance/fix_include_guards.sh
776 Bytes
8dcb6dfcb first commit |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
#!/usr/bin/env bash # To run this, cd to the top level of the repo and type # misc/maintenance/fix_include_guards.sh set -e cd src rm -rf tmp for x in */*.h ; do name=`echo $x | tr '[a-z]/.-' '[A-Z]___' ` m=KALDI_${name}_ n=`grep ifndef $x | awk '{print $2}' | head -n 1` if [ "$m" != "$n" ]; then echo "$m != $n"; if [ ! -z "$n" ]; then cp $x tmp; sed s/$n/$m/ <tmp >$x; else echo "Something wrong for file $x, maybe no include guard." fi fi done for x in */*.h ; do name=`echo $x | tr '[a-z]/.-' '[A-Z]___' ` m=KALDI_${name}_ n=`grep endif $x | grep _H_ | sed s://:: | awk '{print $2}' | head -n 1` if [ ! -s $n ] && [ "$m" != "$n" ]; then echo "#endif: $m != $n"; cp $x tmp; sed s/$n/$m/ <tmp > $x; fi done |