From 54614a34ed5861245634231145f1bbf9e179a05c Mon Sep 17 00:00:00 2001 From: "bsmedberg%covad.net" Date: Wed, 29 Sep 2004 13:10:50 +0000 Subject: [PATCH] Bug 260955 - add an #includesubst instruction r=Hixie --- config/preprocessor.pl | 13 +++++++++++++ config/preprocessor.txt | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/config/preprocessor.pl b/config/preprocessor.pl index 342f552c8d1..53f02a2602d 100755 --- a/config/preprocessor.pl +++ b/config/preprocessor.pl @@ -427,6 +427,19 @@ sub include { } } +sub includesubst { + my ($stack, $filename) = @_; + return if $stack->disabled; + die "argument expected\n" unless $filename; + $filename =~ s/@(\w+)@/$stack->get($1, 1)/gose; + $filename = File::Spec::_0_8::catpath(File::Spec::_0_8::splitpath($filename)); + if ($stack->{'dependencies'}) { + $stack->visit($filename); + } else { + main::include($stack, $filename); + } +} + sub filter { my $stack = shift; return if $stack->disabled; diff --git a/config/preprocessor.txt b/config/preprocessor.txt index 6965d71a108..a53534bf38b 100644 --- a/config/preprocessor.txt +++ b/config/preprocessor.txt @@ -33,6 +33,7 @@ The following preprocessor instructions are recognised. #endif #error STRING #include FILENAME + #includesubst @VAR@FILENAME #expand STRING #literal STRING #filter FILTER1 FILTER2 ... FILTERn @@ -115,6 +116,9 @@ There is no predefined limit to the depth of #includes, and there is no restriction on self-inclusion, so care should be taken to avoid infinite loops. +The #includesubst instruction behaves like #include, except that any +variables in @ATSIGNS@ are expanded, like the substitution filter. + The #expand instruction will print the given STRING with variable substitutions. See the substitution section below.