File indexing completed on 2025-01-18 10:17:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 check_style_errors=0
0016 IFS=$'\n'
0017
0018
0019 found="$(grep '\<\(if\|for\|while\|catch\)(\|){' "$@" -rn --color=always)"
0020 if [ -n "$found" ]; then
0021 echo -e '\033[31;01mError: found the following coding style problems:\033[0m'
0022 check_style_errors=1
0023 echo "${found//^/ /}"
0024 fi
0025
0026 found="$(awk '
0027 function prefix(filename, lineno) {
0028 return " \033[35m" filename "\033[36m:\033[32m" lineno "\033[36m:\033[0m"
0029 }
0030 function mark(pattern, string) { sub(pattern, "\033[01;31m&\033[0m", string); return string }
0031 last && /^\s*{/ {
0032 print prefix(FILENAME, FNR-1) mark("\\)\\s*$", last)
0033 print prefix(FILENAME, FNR) mark("^\\s*{", $0)
0034 last=""
0035 }
0036 { last = /(if|for|while|catch|switch)\s*\(.*\)\s*$/ ? $0 : "" }
0037 ' "$(find include -type f)" "$@")"
0038 if [ -n "$found" ]; then
0039 check_style_errors=1
0040 echo -e '\033[31;01mError: braces should occur on the same line as the if/while/.. statement. Found issues in the following files:\033[0m'
0041 echo "$found"
0042 fi
0043
0044 exit $check_style_errors