Skip to content

Commit

Permalink
Remove utf-8 BOM in astyle.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Sep 14, 2015
1 parent 343cc54 commit 76ccf71
Showing 1 changed file with 50 additions and 43 deletions.
93 changes: 50 additions & 43 deletions scripts/astyle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ if [ -z "$ASTYLE" ]; then
fi

if ! type -p flip >/dev/null; then
if type -p dos2unix >/dev/null; then
flip() {
dos2unix -k $2
}
else
echo "flip not found" >&2
flip() {
:
}
fi
if type -p dos2unix >/dev/null; then
flip() {
dos2unix -k $2
}
else
echo "flip not found" >&2
flip() {
:
}
fi
fi

if ! type -p autopep8 >/dev/null; then
Expand Down Expand Up @@ -76,43 +76,50 @@ astyleit()

for f in "$@"; do
case "$f" in
src/app/gps/qwtpolar-*|src/core/gps/qextserialport/*|src/plugins/grass/qtermwidget/*|src/astyle/*|python/ext-libs/*|src/providers/spatialite/qspatialite/*|src/plugins/dxf2shp_converter/dxflib/src/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*|python/ext-libs/*|*/ui_*.py)
echo -ne "$f skipped $elcr"
continue
;;

*.cpp|*.h|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.hpp)
if [ -x "$f" ]; then
chmod a-x "$f"
fi
cmd=astyleit
;;

*.ui|*.qgm|*.txt|*.t2t|resources/context_help/*)
cmd=:
;;

*.py)
#cmd="autopep8 --in-place --ignore=E111,E128,E201,E202,E203,E211,E221,E222,E225,E226,E227,E231,E241,E261,E265,E272,E302,E303,E501,E701"
cmd="autopep8 --in-place --ignore=E261,E402,E501"
;;

*.sip)
cmd="perl -i.prepare -pe 's/[\r\t ]+$//; s#^(\s*)/\*[*!]\s*([^\s*].*)\s*\$#\$1/** \u\$2\n#;'"
;;

*)
echo -ne "$f skipped $elcr"
continue
;;
esac
src/app/gps/qwtpolar-*|src/core/gps/qextserialport/*|src/plugins/grass/qtermwidget/*|src/astyle/*|python/ext-libs/*|src/providers/spatialite/qspatialite/*|src/plugins/dxf2shp_converter/dxflib/src/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*|python/ext-libs/*|*/ui_*.py)
echo -ne "$f skipped $elcr"
continue
;;

*.cpp|*.h|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.hpp)
if [ -x "$f" ]; then
chmod a-x "$f"
fi
cmd=astyleit
;;

*.ui|*.qgm|*.txt|*.t2t|resources/context_help/*)
cmd=:
;;

*.py)
#cmd="autopep8 --in-place --ignore=E111,E128,E201,E202,E203,E211,E221,E222,E225,E226,E227,E231,E241,E261,E265,E272,E302,E303,E501,E701"
cmd="autopep8 --in-place --ignore=E261,E402,E501"
;;

*.sip)
cmd="perl -i.prepare -pe 's/[\r\t ]+$//; s#^(\s*)/\*[*!]\s*([^\s*].*)\s*\$#\$1/** \u\$2\n#;'"
;;

*)
echo -ne "$f skipped $elcr"
continue
;;
esac

if ! [ -f "$f" ]; then
echo "$f not found" >&2
continue
fi
fi

flip -ub "$f"
eval "$cmd '$f'"
if [[ -f $f && `head -c 3 $f` == $'\xef\xbb\xbf' ]]; then
mv $f $f.bom
tail -c +4 $f.bom > $f
echo "removed BOM from $f"
fi

flip -ub "$f"
#qgsloggermig.pl "$f"
eval "$cmd '$f'"
eval "$cmd '$f'"
done

0 comments on commit 76ccf71

Please sign in to comment.