2014-09-11 14:38:32 +04:00
|
|
|
#!/bin/bash
|
2014-05-23 15:07:07 +04:00
|
|
|
|
2014-09-11 14:38:32 +04:00
|
|
|
ASTYLE=$(which astyle)
|
2014-05-23 15:07:07 +04:00
|
|
|
|
2014-09-11 14:38:32 +04:00
|
|
|
if [ ! -x $ASTYLE ]; then
|
|
|
|
echo "No astyle found in path, please install."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Need at least astyle 2.03 due to bugs in older versions
|
|
|
|
# indenting headers with extern "C"
|
|
|
|
STR_VERSION=$(($ASTYLE --version) 2>&1)
|
|
|
|
VERSION=$(echo $STR_VERSION | cut -d ' ' -f4)
|
|
|
|
MAJOR_VERSION=$(echo $VERSION | cut -d'.' -f1)
|
|
|
|
MINOR_VERSION=$(echo $VERSION | cut -d'.' -f2)
|
|
|
|
|
|
|
|
if [ "$MAJOR_VERSION" -lt "2" ]; then
|
|
|
|
echo "Your version of astyle($VERSION) is too old, need at least 2.03"
|
|
|
|
exit 1
|
|
|
|
fi
|
2014-08-18 21:34:33 +04:00
|
|
|
|
2014-09-11 14:38:32 +04:00
|
|
|
if [ "$MINOR_VERSION" -lt "3" ]; then
|
|
|
|
echo "Your version of astyle($VERSION) is too old, need at least 2.03"
|
|
|
|
exit 1
|
2014-05-23 15:07:07 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -le 0 ]; then
|
2014-09-11 14:38:32 +04:00
|
|
|
echo "Usage:"
|
|
|
|
echo -e "\t$0 <file1> [<file2> ...]"
|
|
|
|
exit 2
|
2014-05-23 15:07:07 +04:00
|
|
|
fi
|
|
|
|
|
2014-05-23 17:34:43 +04:00
|
|
|
$ASTYLE --lineend=linux --mode=c --indent=force-tab=4 --brackets=linux --pad-header \
|
2014-08-18 21:34:33 +04:00
|
|
|
--indent-switches --indent-cases --indent-preprocessor \
|
|
|
|
--indent-col1-comments --delete-empty-lines --break-closing-brackets \
|
|
|
|
--align-pointer=type --indent-labels --brackets=break \
|
2014-09-11 14:38:32 +04:00
|
|
|
--unpad-paren --break-blocks $@
|
|
|
|
exit $?
|