aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-03-24 22:58:54 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-03-24 22:58:54 -0700
commit7ff3eec770fec644870762c31f433c497ee93f05 (patch)
treef6fb8368601cbb67f6ca3158189dfe017a3291c4
parentf7dd08d2791fa4cdb45e494fe604e2017bfcb49b (diff)
downloadcppawk-7ff3eec770fec644870762c31f433c497ee93f05.tar.gz
cppawk-7ff3eec770fec644870762c31f433c497ee93f05.tar.bz2
cppawk-7ff3eec770fec644870762c31f433c497ee93f05.zip
New --dump-macros option.
-rwxr-xr-xcppawk5
-rw-r--r--cppawk.17
-rw-r--r--testcases5
3 files changed, 17 insertions, 0 deletions
diff --git a/cppawk b/cppawk
index af17e5c..bf9ad2d 100755
--- a/cppawk
+++ b/cppawk
@@ -30,6 +30,7 @@
# site configuration
prepro=cpp
incopt=-iquote # GNU extension: must be changed to -I for traditional cpp
+dumpopt=-dM # GNU cpp option to dump macros
awk=gawk
prepro_opts="-D__gawk__=1 -D__cppawk_ver=20220324"
@@ -137,6 +138,10 @@ while [ $# -gt 0 ] ; do
--nobash )
bash=
;;
+ --dump-macros )
+ prepro_opts="$prepro_opts $dumpopt"
+ prepro_only=y
+ ;;
-U* | -D* | -I* | -iquote* )
prepro_opts="$prepro_opts $(quote "$1")"
;;
diff --git a/cppawk.1 b/cppawk.1
index 9aed0b5..3253d09 100644
--- a/cppawk.1
+++ b/cppawk.1
@@ -90,6 +90,13 @@ Pretend that the shell which executes
isn't GNU Bash, even if it is. This has the effect of disabling
the use of process substitution in favor of the use of a temporary file.
+.IP "\fB\-\-dump-macros\fR"
+Instruct the preprocessor to dump all of the
+.BI #define
+directives instead of the preprocessed output. Since this is only useful with
+.BI --prepro-only
+that option is implied.
+
.IP "\fB\-M\fR, \fB\--bignum\fR"
These two equivalent GNU Awk options are passed through to
.BR awk ,
diff --git a/testcases b/testcases
index 19d0c29..6e256ce 100644
--- a/testcases
+++ b/testcases
@@ -240,3 +240,8 @@ BEGIN { print __LINE__
$cppawk -f testdir/name.cwk
:
testdir/name.cwk
+--
+42:
+$cppawk --dump-macros '#define foo_bar 42' | grep foo_bar
+:
+#define foo_bar 42