From 9389987264218639c0ceaff09779061fe551ad22 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 28 Oct 2009 10:43:22 +0000 Subject: [PATCH] Added to repository. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1286 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scripts/list-conditional-defines | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 scripts/list-conditional-defines diff --git a/scripts/list-conditional-defines b/scripts/list-conditional-defines new file mode 100755 index 000000000..87def60fd --- /dev/null +++ b/scripts/list-conditional-defines @@ -0,0 +1,27 @@ +#!/bin/gawk -f + +# awk script that reads a patch from stdin and prints all #define statements +# that match the following patttern: +# +#ifndef +# +#define +# +#endif + +BEGIN { + previous_is_ifndef = 0 + symbol = "" +} + +{ + is_ifndef = match($0, "^+#ifndef (.*)$", a) + if (is_ifndef) + symbol = a[1] + is_define = previous_is_ifndef && match($0, "^+#define " + symbol) + if (is_define) + define = $0 + is_endif = match($0, "^+#endif$") + if (before_previous_is_ifndef && previous_is_define && is_endif) + print define + before_previous_is_ifndef = previous_is_ifndef + previous_is_ifndef = is_ifndef + previous_is_define = is_define +}