astyle.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/bash
  2. ###########################################################################
  3. # astyle.sh
  4. # ---------------------
  5. # Date : August 2008
  6. # Copyright : (C) 2008 by Juergen E. Fischer
  7. # Email : jef at norbit dot de
  8. ###########################################################################
  9. # #
  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. #
  14. # #
  15. ###########################################################################
  16. if ! hash astyle 2>/dev/null; then
  17. echo "astyle not found - please install astyle on your system" >&2
  18. exit 1
  19. fi
  20. if ! type -p flip >/dev/null; then
  21. flip() {
  22. :
  23. }
  24. fi
  25. set -e
  26. MY_ARTISTIC_STYLE_OPTIONS=" \
  27. --preserve-date \
  28. --indent-preprocessor \
  29. --convert-tabs \
  30. --indent=spaces=2 \
  31. --indent-classes \
  32. --indent-labels \
  33. --indent-namespaces \
  34. --indent-switches \
  35. --max-instatement-indent=40 \
  36. --min-conditional-indent=-1 \
  37. --suffix=none \
  38. --break-after-logical \
  39. --style=allman \
  40. --align-pointer=name \
  41. --align-reference=name \
  42. --keep-one-line-statements \
  43. --keep-one-line-blocks \
  44. --pad-paren-in \
  45. --pad-oper \
  46. --unpad-paren \
  47. --pad-header"
  48. for f in "$@"; do
  49. case "$f" in
  50. *.cpp|*.h|*.c|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.hpp|*.mm)
  51. cmd="astyle $MY_ARTISTIC_STYLE_OPTIONS"
  52. ;;
  53. *.ui|*.qgm|*.txt|*.t2t|*.sip|resources/context_help/*)
  54. cmd=:
  55. ;;
  56. *)
  57. echo -ne "$f skipped $elcr"
  58. continue
  59. ;;
  60. esac
  61. if ! [ -f "$f" ]; then
  62. echo "$f not found" >&2
  63. continue
  64. fi
  65. flip -ub "$f"
  66. #qgsloggermig.pl "$f"
  67. eval "$cmd '$f'"
  68. done