my $qr = bless qr/y/, "QRonly";
ok("x" =~ $qr, "qr with qr-overload uses overload");
ok("y" !~ $qr, "qr with qr-overload uses overload");
- {
- local $::TODO = '?? fails with "qr with qr"' ;
- ok("x" =~ /^(??{$qr})$/, "qr with qr-overload with ?? uses overload");
- ok("y" !~ /^(??{$qr})$/, "qr with qr-overload with ?? uses overload");
- }
+ ok("x" =~ /^(??{$qr})$/, "qr with qr-overload with ?? uses overload");
+ ok("y" !~ /^(??{$qr})$/, "qr with qr-overload with ?? uses overload");
is("$qr", "".qr/y/, "qr with qr-overload stringify");
my $rx = $$qr;
/* before restoring everything, evaluate the returned
* value, so that 'uninit' warnings don't use the wrong
- * PL_op or pad. Also need to process any magic vars (e.g.
- * $1 *before* parentheses are restored */
+ * PL_op or pad. Also need to process any magic vars
+ * (e.g. $1) *before* parentheses are restored */
PL_op = NULL;
logical = 0;
}
else { /* /(??{}) */
- SV *sv = ret;
re_sv = NULL;
- if (SvROK(sv))
- sv = SvRV(sv);
- if (SvTYPE(sv) == SVt_REGEXP)
- re_sv = (REGEXP*) sv;
- else if (SvSMAGICAL(sv)) {
- MAGIC *mg = mg_find(sv, PERL_MAGIC_qr);
- if (mg)
- re_sv = (REGEXP *) mg->mg_obj;
- }
+ /* if its overloaded, let the regex compiler handle
+ * it; otherwise extract regex, or stringify */
+ if (!SvAMAGIC(ret)) {
+ SV *sv = ret;
+ if (SvROK(sv))
+ sv = SvRV(sv);
+ if (SvTYPE(sv) == SVt_REGEXP)
+ re_sv = (REGEXP*) sv;
+ else if (SvSMAGICAL(sv)) {
+ MAGIC *mg = mg_find(sv, PERL_MAGIC_qr);
+ if (mg)
+ re_sv = (REGEXP *) mg->mg_obj;
+ }
- /* force any magic, undef warnings here */
- if (!re_sv && !SvAMAGIC(ret)) {
- ret = sv_mortalcopy(ret);
- (void) SvPV_force_nolen(ret);
+ /* force any magic, undef warnings here */
+ if (!re_sv) {
+ ret = sv_mortalcopy(ret);
+ (void) SvPV_force_nolen(ret);
+ }
}
}