postgresql/src/tools/find_baddefs
2001-10-25 01:29:37 +00:00

21 lines
463 B
Bash
Executable File

#!/bin/sh
# This script attempts to find bad ifdef's, i.e. ifdef's that use braces
# but not the do { ... } while (0) syntax
#
# This is useful for running before pgindent
for FILE
do
awk ' BEGIN {was_define = "N"}
{ if (was_define == "Y" &&
$0 ~ /^{/)
printf "%s %d\n", FILENAME, NR
if ($0 ~ /^#define/)
was_define = "Y"
else
was_define = "N"
}' "$FILE"
grep -on '^#define.*{' "$FILE" | grep -v 'do[ ]*{'
done