Blame


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