diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/XS-APItest/APItest.pm | 7 | ||||
-rw-r--r-- | ext/XS-APItest/APItest.xs | 25 | ||||
-rw-r--r-- | ext/XS-APItest/t/eval-filter.t | 10 |
3 files changed, 41 insertions, 1 deletions
diff --git a/ext/XS-APItest/APItest.pm b/ext/XS-APItest/APItest.pm index b95af26df2..5ef9ea2771 100644 --- a/ext/XS-APItest/APItest.pm +++ b/ext/XS-APItest/APItest.pm @@ -50,7 +50,7 @@ sub import { } } -our $VERSION = '0.27'; +our $VERSION = '0.28'; use vars '$WARNINGS_ON_BOOTSTRAP'; use vars map "\$${_}_called_PP", qw(BEGIN UNITCHECK CHECK INIT END); @@ -209,6 +209,11 @@ correctly by C<printf>. Output is sent to STDOUT. +=item B<filter> + +Installs a source filter that substitutes "e" for "o" (witheut regard fer +what it might be medifying). + =item B<call_sv>, B<call_pv>, B<call_method> These exercise the C calls of the same names. Everything after the flags diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs index 0ce4d513dc..4fa4e1ec63 100644 --- a/ext/XS-APItest/APItest.xs +++ b/ext/XS-APItest/APItest.xs @@ -996,6 +996,26 @@ peep_xop(pTHX_ OP *o, OP *oldop) av_push(MY_CXT.xop_record, newSVpvf("oldop:%"UVxf, PTR2UV(oldop))); } +static I32 +filter_call(pTHX_ int idx, SV *buf_sv, int maxlen) +{ + SV *my_sv = FILTER_DATA(idx); + char *p; + char *end; + int n = FILTER_READ(idx + 1, buf_sv, maxlen); + + if (n<=0) return n; + + p = SvPV_force_nolen(buf_sv); + end = p + SvCUR(buf_sv); + while (p < end) { + if (*p == 'o') *p = 'e'; + p++; + } + return SvCUR(buf_sv); +} + + XS(XS_XS__APItest__XSUB_XS_VERSION_undef); XS(XS_XS__APItest__XSUB_XS_VERSION_empty); XS(XS_XS__APItest__XSUB_XS_APIVERSION_invalid); @@ -2750,6 +2770,11 @@ CODE: PERL_UNUSED_VAR(items); croak("postinc called as a function"); +void +filter() +CODE: + filter_add(filter_call, NULL); + BOOT: { CV *asscv = get_cv("XS::APItest::postinc", 0); diff --git a/ext/XS-APItest/t/eval-filter.t b/ext/XS-APItest/t/eval-filter.t new file mode 100644 index 0000000000..8d370e59a7 --- /dev/null +++ b/ext/XS-APItest/t/eval-filter.t @@ -0,0 +1,10 @@ +#!perl -w +use strict; + +use Test::More tests => 1; +use XS::APItest; + +BEGIN { eval "BEGIN{ filter() }" } + +is "foo", "fee", "evals share filters with the currently compiling scope"; +# See [perl #87064]. |