Blame scripts/format_code.sh

Packit Service bb5c11
#!/bin/bash
Packit Service bb5c11
Packit Service bb5c11
ASTYLE=$(which astyle)
Packit Service bb5c11
Packit Service bb5c11
if [ ! -x $ASTYLE ]; then
Packit Service bb5c11
  echo "No astyle found in path, please install."
Packit Service bb5c11
  exit 1
Packit Service bb5c11
fi
Packit Service bb5c11
Packit Service bb5c11
# Need at least astyle 2.03 due to bugs in older versions
Packit Service bb5c11
# indenting headers with extern "C"
Packit Service bb5c11
STR_VERSION=$($ASTYLE --version 2>&1)
Packit Service bb5c11
VERSION=$(echo $STR_VERSION | cut -d ' ' -f4)
Packit Service bb5c11
MAJOR_VERSION=$(echo $VERSION | cut -d'.' -f1)
Packit Service bb5c11
MINOR_VERSION=$(echo $VERSION | cut -d'.' -f2)
Packit Service bb5c11
Packit Service bb5c11
if [ "$MAJOR_VERSION" -lt "2" ];
Packit Service bb5c11
then
Packit Service bb5c11
  echo "Your version of astyle($VERSION) is too old, need at least 2.03"
Packit Service bb5c11
  exit 1
Packit Service bb5c11
elif [ "$MAJOR_VERSION" -eq "2" ];
Packit Service bb5c11
then
Packit Service bb5c11
  if [ "$MINOR_VERSION" -lt "3" ];
Packit Service bb5c11
  then
Packit Service bb5c11
    echo "Your version of astyle($VERSION) is too old, need at least 2.03"
Packit Service bb5c11
    exit 1
Packit Service bb5c11
  fi
Packit Service bb5c11
fi
Packit Service bb5c11
Packit Service bb5c11
if [ $# -le 0 ]; then
Packit Service bb5c11
  echo "Usage:"
Packit Service bb5c11
  echo -e "\t$0 <file1> [<file2> ...]"
Packit Service bb5c11
  exit 2
Packit Service bb5c11
fi
Packit Service bb5c11
Packit Service bb5c11
$ASTYLE --lineend=linux --mode=c --indent=tab=4 --pad-header --pad-oper --style=allman --min-conditional-indent=0 \
Packit Service bb5c11
        --indent-switches --indent-cases --indent-preprocessor -k1 --max-code-length=100 \
Packit Service bb5c11
        --indent-col1-comments --delete-empty-lines --break-closing-brackets \
Packit Service bb5c11
        --align-pointer=type --indent-labels -xe --break-after-logical \
Packit Service bb5c11
        --unpad-paren --break-blocks $@
Packit Service bb5c11
Packit Service bb5c11
exit $?