grass_indent.sh 1012 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh
  2. # Indent source code according to GRASS GIS submitting rules
  3. # Should be in sync with:
  4. # https://trac.osgeo.org/grass/wiki/Submitting/C
  5. # http://grasswiki.osgeo.org/wiki/Development#Explanation_of_C_indentation_rules
  6. # Dependencies:
  7. # indent
  8. # Changes and their reasons:
  9. # -ts8 -ut -> --no-tabs
  10. # Do not use 8 space wide tabs when indent level is 4
  11. # TODO: replace short flags by long ones to improve readability
  12. if [ $# -lt 1 ] ; then
  13. echo "No files specified (give file name(s) as parameter)"
  14. exit 1
  15. else
  16. indent -npro -bad -bap -bbb -br -bli0 -bls -cli0 -ncs -fc1 -hnl -i4 \
  17. -nbbo -nbc -nbfda -nbfde -ncdb -ncdw -nce -nfca -npcs -nprs \
  18. -npsl -nsc -nsob -saf -sai -saw -sbi0 -ss --no-tabs "$@"
  19. # fix broken gettext macros:
  20. grep -l '\<_$' "$@" | \
  21. while read file ; do sed -i -e '/[( \t]_$/{;N;s/\n[ \t]*//;}' $file ; done
  22. # restore original file with timestamp if indent did not change anything
  23. cmp "$@"~ "$@" > /dev/null && mv -f "$@"~ "$@"
  24. fi