From 7ff3eec770fec644870762c31f433c497ee93f05 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 24 Mar 2022 22:58:54 -0700 Subject: New --dump-macros option. --- cppawk | 5 +++++ cppawk.1 | 7 +++++++ testcases | 5 +++++ 3 files changed, 17 insertions(+) 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 -- cgit v1.2.3