STRLEN len;
const char *p = NULL, *r = SvPV_const(sv, len);
+ if (len >= 1 && *r == '$') {
+ ++r;
+ --len;
+ s = strchr(s, '$');
+ if (!s)
+ return NULL;
+ }
+
p = strstr(s, r);
while (p) {
p += len;
const char *s = PL_parser->oldbufptr, *t = PL_parser->bufptr - 1;
while (s < t && isSPACE(*s)) ++s;
- while (t > s && isSPACE(*t)) --t;
- sv = sv_2mortal(newSVpvn(s, t - s + 1));
-
- indirect_map_store(o, s, sv);
+ if (*s == '$' && ++s <= t) {
+ while (s < t && isSPACE(*s)) ++s;
+ while (s < t && isSPACE(*t)) --t;
+ if (!isALPHA(*s))
+ return o;
+ sv = sv_2mortal(newSVpvn("$", 1));
+ sv_catpvn_nomg(sv, s, t - s + 1);
+ indirect_map_store(o, s, sv);
+ }
}
return o;
use strict;
use warnings;
-use Test::More tests => 44 * 4 + 2;
+use Test::More tests => 44 * 6 + 2;
my ($obj, $x);
our ($y, $bloop);
sub expect {
my ($pkg) = @_;
- return qr/^warn:Indirect call of method "(?:new|meh|$pkg$pkg)" on object "(?:$pkg|newnew|\$(?:[xy_]|(?:sploosh::)?sploosh|(?:main::)?bloop))"/
+ return qr/^warn:Indirect call of method "(?:new|meh|$pkg$pkg)" on object "(?:$pkg|newnew|\$(?:[xy_]|(?:sploosh::)?sploosh|(?:main::)?bloop))"/
}
{
eval "die qq{the code compiled but it shouldn't have\n}; $_";
}
like($@, expect('Dongs'), "no indirect, defined: $_");
+ s/\$/\$ \n\t /g;
+ s/Dongs/Hlagh/g;
+ {
+ use indirect;
+ eval "die qq{ok\\n}; $_";
+ }
+ is($@, "ok\n", "use indirect, spaces: $_");
+ {
+ no indirect;
+ eval "die qq{the code compiled but it shouldn't have\n}; $_";
+ }
+ like($@, expect('Hlagh'), "no indirect, spaces: $_");
}
}