1
0

ngindent.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. #
  3. # ngIRCd -- The Next Generation IRC Daemon
  4. # Copyright (c)2001-2019 Alexander Barton (alex@barton.de) and Contributors
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. # Please read the file COPYING, README and AUTHORS for more information.
  11. #
  12. # This script uses GNU indent(1) to format C source code files of ngIRCd.
  13. # Usage:
  14. # - ./contrib/ngindent.sh [<file> [<file> [...]]]
  15. # - cat ./src/ngircd/<c_file> | ./contrib/ngindent.sh
  16. # Use a coding-style based on "Kernighan & Ritchie" (-kr):
  17. INDENTARGS="-kr
  18. -bad
  19. -c3
  20. -cd41
  21. -i8
  22. -l80
  23. -ncs
  24. -psl
  25. -sob
  26. -ss
  27. -ts8
  28. -blf
  29. -il0
  30. "
  31. # check if indent(1) is available
  32. command -v indent >/dev/null 2>&1 && INDENT="indent"
  33. command -v gindent >/dev/null 2>&1 && INDENT="gindent"
  34. command -v gnuindent >/dev/null 2>&1 && INDENT="gnuindent"
  35. if [ -z "$INDENT" ]; then
  36. echo "Error: GNU \"indent\" not found!"
  37. exit 1
  38. fi
  39. # shellcheck disable=SC2086
  40. $INDENT -v $INDENTARGS "$@"
  41. # -eof-