From 750ca3854099771112a2420784220d86f7e97af6 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 18 Mar 2022 09:31:20 -0700 Subject: Test -f option. Bugfix: because the preprocessed version of the file is in a temporary directory, #include "..." looks for files in that directory. We must tell the preprocessor to look for include files in the original directory. In the case when the awk script comes from the command line, we already took care of this by pointing the preprocessor to $(pwd). --- cppawk | 3 ++- testcases | 5 +++++ testdir/program.cwk | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 testdir/program.cwk diff --git a/cppawk b/cppawk index d89059b..86e4d27 100755 --- a/cppawk +++ b/cppawk @@ -128,7 +128,8 @@ trap 'rm -f $tmp_file' EXIT INT TERM if [ -n "$awk_file" ] ; then tmp_file=$(mktemp) - $delhashbang "$awk_file" | $prepro $(syntax "$prepro_opts") - > $tmp_file + $delhashbang "$awk_file" | \ + $prepro $incopt$(dirname "$awk_file") $(syntax "$prepro_opts") - > $tmp_file [ $prepro_only ] \ && cat $tmp_file \ || $awk $(syntax "$awk_opts") -f $tmp_file "$@" diff --git a/testcases b/testcases index 71b9169..8011eca 100644 --- a/testcases +++ b/testcases @@ -121,3 +121,8 @@ BEGIN { } ./cppawk -v foo="'\"" 'BEGIN { print foo }' : '" +-- +23: +./cppawk -f testdir/program.cwk +: +73 diff --git a/testdir/program.cwk b/testdir/program.cwk new file mode 100644 index 0000000..58ea47c --- /dev/null +++ b/testdir/program.cwk @@ -0,0 +1,7 @@ +/* + * cppawk program + */ + +#include "header.cwh" + +BEGIN { print max(42, 73) } -- cgit v1.2.3