Skip to content

Commit 76ccf71

Browse files
committedSep 14, 2015
Remove utf-8 BOM in astyle.sh
1 parent 343cc54 commit 76ccf71

File tree

1 file changed

+50
-43
lines changed

1 file changed

+50
-43
lines changed
 

‎scripts/astyle.sh

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ if [ -z "$ASTYLE" ]; then
2929
fi
3030

3131
if ! type -p flip >/dev/null; then
32-
if type -p dos2unix >/dev/null; then
33-
flip() {
34-
dos2unix -k $2
35-
}
36-
else
37-
echo "flip not found" >&2
38-
flip() {
39-
:
40-
}
41-
fi
32+
if type -p dos2unix >/dev/null; then
33+
flip() {
34+
dos2unix -k $2
35+
}
36+
else
37+
echo "flip not found" >&2
38+
flip() {
39+
:
40+
}
41+
fi
4242
fi
4343

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

7777
for f in "$@"; do
7878
case "$f" in
79-
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)
80-
echo -ne "$f skipped $elcr"
81-
continue
82-
;;
83-
84-
*.cpp|*.h|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.hpp)
85-
if [ -x "$f" ]; then
86-
chmod a-x "$f"
87-
fi
88-
cmd=astyleit
89-
;;
90-
91-
*.ui|*.qgm|*.txt|*.t2t|resources/context_help/*)
92-
cmd=:
93-
;;
94-
95-
*.py)
96-
#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"
97-
cmd="autopep8 --in-place --ignore=E261,E402,E501"
98-
;;
99-
100-
*.sip)
101-
cmd="perl -i.prepare -pe 's/[\r\t ]+$//; s#^(\s*)/\*[*!]\s*([^\s*].*)\s*\$#\$1/** \u\$2\n#;'"
102-
;;
103-
104-
*)
105-
echo -ne "$f skipped $elcr"
106-
continue
107-
;;
108-
esac
79+
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)
80+
echo -ne "$f skipped $elcr"
81+
continue
82+
;;
83+
84+
*.cpp|*.h|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.hpp)
85+
if [ -x "$f" ]; then
86+
chmod a-x "$f"
87+
fi
88+
cmd=astyleit
89+
;;
90+
91+
*.ui|*.qgm|*.txt|*.t2t|resources/context_help/*)
92+
cmd=:
93+
;;
94+
95+
*.py)
96+
#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"
97+
cmd="autopep8 --in-place --ignore=E261,E402,E501"
98+
;;
99+
100+
*.sip)
101+
cmd="perl -i.prepare -pe 's/[\r\t ]+$//; s#^(\s*)/\*[*!]\s*([^\s*].*)\s*\$#\$1/** \u\$2\n#;'"
102+
;;
103+
104+
*)
105+
echo -ne "$f skipped $elcr"
106+
continue
107+
;;
108+
esac
109109

110110
if ! [ -f "$f" ]; then
111111
echo "$f not found" >&2
112112
continue
113-
fi
113+
fi
114+
115+
flip -ub "$f"
116+
eval "$cmd '$f'"
117+
if [[ -f $f && `head -c 3 $f` == $'\xef\xbb\xbf' ]]; then
118+
mv $f $f.bom
119+
tail -c +4 $f.bom > $f
120+
echo "removed BOM from $f"
121+
fi
114122

115-
flip -ub "$f"
116123
#qgsloggermig.pl "$f"
117-
eval "$cmd '$f'"
124+
eval "$cmd '$f'"
118125
done

0 commit comments

Comments
 (0)
Please sign in to comment.