From 311bcfc6b3acdd6fd152798c7f287ddf74fa2a98 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 16 Apr 2024 21:46:48 +0200 Subject: Adding upstream version 15.4. Signed-off-by: Daniel Baumann --- src/tools/find_badmacros | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 src/tools/find_badmacros (limited to 'src/tools/find_badmacros') diff --git a/src/tools/find_badmacros b/src/tools/find_badmacros new file mode 100755 index 0000000..58f4308 --- /dev/null +++ b/src/tools/find_badmacros @@ -0,0 +1,22 @@ +#!/bin/sh + +# This script attempts to find bad ifdef's, i.e. ifdef's that use braces +# but not the do { ... } while (0) syntax +# +# src/tools/find_badmacros +# +# 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 -- cgit v1.2.3