summaryrefslogtreecommitdiffstats
path: root/src/tools/pginclude/pgdefine
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/pginclude/pgdefine')
-rwxr-xr-xsrc/tools/pginclude/pgdefine25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tools/pginclude/pgdefine b/src/tools/pginclude/pgdefine
new file mode 100755
index 0000000..242d035
--- /dev/null
+++ b/src/tools/pginclude/pgdefine
@@ -0,0 +1,25 @@
+:
+# create macro calls for all defines in the file
+
+# src/tools/pginclude/pgdefine
+
+trap "rm -f /tmp/$$" 0 1 2 3 15
+for FILE
+do
+ cat "$FILE" | grep "^#define" >/tmp/$$
+ cat /tmp/$$ | sed -n 's/^#define[ ][ ]*\([a-zA-Z0-9_]*\)[ ][ ]*[^ ].*\\\\$/\1;/p'
+ cat /tmp/$$ | sed -n 's/^#define[ ][ ]*\([a-zA-Z0-9_]*\)[ ][ ]*[^ ].*[^\\\\]$/(void)\1;/p'
+
+ (
+ cat /tmp/$$ | sed -n 's/^#define[ ][ ]*\([a-zA-Z0-9_]*([^)]*)\).*\\\\$/\1;/p'
+ cat /tmp/$$ | sed -n 's/^#define[ ][ ]*\([a-zA-Z0-9_]*([^)]*)\).*[^\\\\]$/(=void)\1;/p'
+ ) |
+ sed 's/([a-zA-Z0-9_ ][a-zA-Z0-9_ ]*)/(0)/g' |
+ sed 's/([a-zA-Z0-9_ ]*,/(0,/g' |
+ sed 's/,[a-zA-Z0-9_ ]*,/,0,/g' |
+ sed 's/,[a-zA-Z0-9_ ]*)/,0)/g' |
+ # do not cast 'return' macros as (void)
+ sed 's/(=void)\(.*return\)/\1/g' |
+ sed 's/(=void)\(.*RETURN\)/\1/g' |
+ sed 's/(=void)/(void)/g'
+done