2 ###########################################################################
4 # ---------------------
6 # Copyright : (C) 2008 by Juergen E. Fischer
7 # Email : jef at norbit dot de
8 ###########################################################################
10 # This program is free software; you can redistribute it and/or modify #
11 # it under the terms of the GNU General Public License as published by #
12 # the Free Software Foundation; either version 2 of the License, or #
13 # (at your option) any later version. #
15 ###########################################################################
17 for ASTYLE in ${OPJSTYLE} $(dirname $0)/opjstyle $(dirname $0)/RelWithDebInfo/opjstyle
19 if type -p $ASTYLE >/dev/null; then
25 if [ -z "$ASTYLE" ]; then
26 echo "opjstyle not found - please enable WITH_ASTYLE in cmake and build it" >&2
30 if type -p tput >/dev/null; then
31 elcr="$ASTYLEPROGRESS$(tput el)$(tput cr)"
33 elcr="$ASTYLEPROGRESS \r"
36 if ! type -p flip >/dev/null; then
37 if type -p dos2unix >/dev/null; then
42 echo "flip not found" >&2
49 if ! type -p autopep8 >/dev/null; then
50 echo "autopep8 not found" >&2
56 ASTYLEOPTS=$(dirname $0)/astyle.options
57 if type -p cygpath >/dev/null; then
58 ASTYLEOPTS="$(cygpath -w $ASTYLEOPTS)"
64 $ASTYLE --options="$ASTYLEOPTS" "$1"
65 #modified=$1.unify_includes_modified
67 #scripts/unify_includes.pl "$modified"
68 #scripts/doxygen_space.pl "$modified"
69 #diff "$1" "$modified" >/dev/null || mv "$modified" "$1"
76 echo -ne "$f skipped $elcr"
80 *.cpp|*.h|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.hpp)
88 #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"
89 echo -ne "Formatting $f $elcr"
90 cmd="autopep8 --in-place --ignore=E261,E265,E402,E501"
95 echo -ne "$f skipped $elcr"
100 if ! [ -f "$f" ]; then
101 echo "$f not found" >&2
105 if [[ -f $f && `head -c 3 $f` == $'\xef\xbb\xbf' ]]; then
107 tail -c +4 $f.bom > $f
108 echo "removed BOM from $f"
111 modified=$f.flip_modified
114 diff "$f" "$modified" >/dev/null || mv "$modified" "$f"