# note: this is testing unary qr, not binary =~
$subs{qr} = '(qr/%s/)';
- # XXX TODO qr overload with fallback calls "" and FETCH too often
- #push @tests, [ "abc", '"abc" =~ (%s)', '(qr)', '("")', [ 1, 2, 0 ], 0 ];
- push @tests, [ "abc", '"abc" =~ (%s)', '(qr)', '("")("")',
- [ 1, 2, 0, 1, 5, 0 ], 0 ];
+ push @tests, [ "abc", '"abc" =~ (%s)', '(qr)', '("")', [ 1, 2, 0 ], 0 ];
$e = '"abc" ~~ (%s)';
$subs{'~~'} = $e;
PM_SETRE(pm, re);
}
else {
- STRLEN len;
- const char *t = SvOK(tmpstr) ? SvPV_const(tmpstr, len) : "";
+ STRLEN len = 0;
+ const char *t = SvOK(tmpstr) ? SvPV_nomg_const(tmpstr, len) : "";
+
re = PM_GETRE(pm);
assert (re != (REGEXP*) &PL_sv_undef);
const char *const p = SvPV(tmpstr, len);
tmpstr = newSVpvn_flags(p, len, SVs_TEMP);
}
+ else if (SvAMAGIC(tmpstr)) {
+ /* make a copy to avoid extra stringifies */
+ SV* copy = newSV_type(SVt_PV);
+ sv_setpvn(copy, t, len);
+ if (SvUTF8(tmpstr))
+ SvUTF8_on(copy);
+ else
+ SvUTF8_off(copy);
+ sv_2mortal(copy);
+ tmpstr = copy;
+ }
if (eng)
PM_SETRE(pm, CALLREGCOMP_ENG(eng, tmpstr, pm_flags));