3 # Filter NUT C source file style to conform to recommendations of
4 # https://www.networkupstools.org/docs/developer-guide.chunked/ar01s03.html#_coding_style
5 # Note that the sed filter "command does a reasonable job of converting
6 # most C++ style comments (but not URLs and DOCTYPE strings)" so a manual
7 # pass may be needed to revise the changes.
9 # Since that the result is not always immediately acceptable, so this script
10 # is not part of e.g. automated testing - but it helps clean up much of the
11 # codebase to be up to a common spec.
13 # Script wrapping (C) 2017 by Jim Klimov
14 # Rules (C) long ago by NUT project team
18 TMPFILE
=".style-tmp.$$"
19 trap 'EXITCODE=$? ; rm -f "$TMPFILE" ; exit $EXITCODE' 0 1 2 3 15
24 # TODO: The indent below does a poor job for C++
26 | indent
-kr -i8 -T FILE
-l1000 -nhnl \
27 |
sed 's#\(^\|[ \t]\)//[ \t]*\(.*\)[ \t]*#/* \2 */#' \
30 if [ "$STEPCODE" != 0 ]; then
32 echo "FAILED to process file: $SRCFILE" >&2
36 if diff -q "$SRCFILE" "$TMPFILE" ; then
37 echo "File was not changed: $SRCFILE" >&2
39 echo "File was changed: $SRCFILE - please revise the differences" >&2
40 meld
"$SRCFILE" "$TMPFILE"
46 git ls-files |
grep -E '\.(c|h)$' |
while read F
; do
52 echo "Usage: $0 [file.c] [header.h] - process listed file(s)"
53 echo "Usage: $0 - process all .c and .h files currently tracked in Git repo"