Hi Geoff, the following code:
<!--#if expr="" --> <!--#perl sub="sub {print "MUST NOT BE PRINTED"}" --> <!--#else --> <!--#perl sub="sub {print "OK"}" --> <!--#endif --> produces: MUST NOT BE PRINTED OK I believe, this wrong. The first sub must even not be called. The attached patch cures it. It contains 2 additional tests and an additional line in IncludeHook.xs. Torsten
--- IncludeHook.xs~ 2005-04-12 17:26:27.000000000 +0200 +++ IncludeHook.xs 2005-06-29 19:19:15.329341356 +0200 @@ -41,6 +41,9 @@ request_rec *r_bogus, ap_filter_t *f, apr_bucket *head_ptr, apr_bucket **inserted_head) { + /* handle <!--#if ... --> statements correctly */ + if( !(ctx->flags & FLAG_PRINTING) ) return APR_SUCCESS; + /* prepare for 2.1 - get everything from f */ request_rec *r = f->r; server_rec *s = r->server; --- t/02perl-args.t~ 2005-04-12 17:25:15.000000000 +0200 +++ t/02perl-args.t 2005-06-29 19:48:34.182844274 +0200 @@ -9,11 +9,11 @@ # <!-- #perl arg="foo" sub="..."--> tests -plan tests => 5, (need_lwp && +plan tests => 7, (need_lwp && need_module('mod_perl.c') && need_module('include')); -foreach my $file (qw(empty good multi method anon)) { +foreach my $file (qw(empty if else good multi method anon)) { my $line = <DATA>; next if $line =~ m/^#/; @@ -52,6 +52,8 @@ __END__ 0|perl <!--#perl arg="" sub="My::PrintArgs" --> here 1|perl <!--#perl arg="one" sub="My::PrintArgs" --> here +1|<!--#if expr="1" -->perl <!--#perl arg="one" sub="My::PrintArgs" --> here<!--#else -->perl <!--#perl sub="sub {print 'must not be printed'}" --> here<!--#endif --> +1|<!--#if expr="" -->perl <!--#perl sub="sub {print 'must not be printed'}" --> here<!--#else -->perl <!--#perl arg="one" sub="My::PrintArgs" --> here<!--#endif --> 1|perl <!--#perl arg="one" arg="two" sub="My::PrintArgs" arg="three"--> here 1|perl <!--#perl arg="one" sub="My::PrintArgs->method_handler" --> here 1|perl <!--#perl sub="sub {
pgpusLo1LpNFj.pgp
Description: PGP signature