Home | History | Annotate | Download | only in tools
      1 #!/bin/sh
      2 set -e
      3 astyle --style=java --indent=spaces=2 --indent-switches\
      4        --min-conditional-indent=0 \
      5        --pad-oper --pad-header --unpad-paren \
      6        --align-pointer=name \
      7        --indent-preprocessor --convert-tabs --indent-labels \
      8        --suffix=none --quiet --max-instatement-indent=80 "$@"
      9 # Disabled, too greedy?
     10 #sed -i 's;[[:space:]]\{1,\}\[;[;g' "$@"
     11 
     12 sed_i() {
     13   # Incompatible sed parameter parsing.
     14   if sed -i 2>&1 | grep -q 'requires an argument'; then
     15     sed -i '' "$@"
     16   else
     17     sed -i "$@"
     18   fi
     19 }
     20 
     21 sed_i -e 's/[[:space:]]\{1,\}\([,;]\)/\1/g' \
     22       -e 's/[[:space:]]\{1,\}\([+-]\{2\};\)/\1/g' \
     23       -e 's/,[[:space:]]*}/}/g' \
     24       -e 's;//\([^/[:space:]].*$\);// \1;g' \
     25       -e 's/^\(public\|private\|protected\):$/ \1:/g' \
     26       -e 's/[[:space:]]\{1,\}$//g' \
     27       "$@"
     28