@@ -3449,20 +3449,30 @@ sub B::REGEXP::save {
34493449 $cur -= length ($sv -> PV) - length ($pv );
34503450 my $cstr = cstring($pv );
34513451 # Unfortunately this XPV is needed temp. Later replaced by struct regexp.
3452- $xpvsect -> add( sprintf ( " %s {0}, %u , %u " , $PERL514 ? " Nullhv, " : " " , $cur , 0 ) );
3452+ $xpvsect -> add(sprintf (" %s {0}, %u , %u " , $PERL514 ? " Nullhv, " : " " , $cur , 0 ) );
34533453 $svsect -> add(sprintf (" &xpv_list[%d ], $u32fmt , 0x%x , {%s }" ,
34543454 $xpvsect -> index , $sv -> REFCNT, $sv -> FLAGS, $] > 5.017006 ? " NULL" : $cstr ));
34553455 my $ix = $svsect -> index ;
34563456 warn " Saving RX $cstr to sv_list[$ix ]\n " if $debug {rx } or $debug {sv };
3457+ # The SvPV field: since df6b4bd56551f2d39f7c again the PV, before the RX
3458+ my $rx_or_pv = (!$CPERL51 and $] < 5.027003) or ($CPERL51 and $] < 5.027002) ? 1 : 0;
3459+ my $initpm = $init ;
34573460 if ($] > 5.011) {
34583461 my $pmflags = $PERL522 ? $sv -> compflags : $sv -> EXTFLAGS;
3459- my $initpm = re_does_swash($cstr , $pmflags ) ? $init1 : $init ;
3462+ $initpm = $init1 if re_does_swash($cstr , $pmflags );
34603463 if ($PERL518 and $sv -> EXTFLAGS & RXf_EVAL_SEEN) {
34613464 $initpm -> add(" PL_hints |= HINT_RE_EVAL;" );
34623465 }
3463- $initpm -> add(# replace sv_any->XPV with struct regexp. need pv and extflags
3464- sprintf (" SvANY(&sv_list[%d ]) = SvANY(CALLREGCOMP(newSVpvn(%s , %d ), 0x%x ));" ,
3465- $ix , $cstr , $cur , $pmflags ));
3466+ $initpm -> add(" {" ,
3467+ sprintf (" SV* sv = newSVpvn(%s , %d );" , $cstr , $cur ),
3468+ # replace sv_any->XPV with struct regexp. need pv and extflags
3469+ sprintf (" sv_list[$ix ].sv_any = SvANY(CALLREGCOMP(sv, 0x%x ));" ,
3470+ $pmflags ),
3471+ $rx_or_pv
3472+ # and set the pv or rx field
3473+ ? " sv_list[$ix ].sv_u.svu_rx = (struct regexp*)SvANY(&sv_list[$ix ]);"
3474+ : " sv_list[$ix ].sv_u.svu_pv = sv->sv_u.svu_pv;" ,
3475+ " }" );
34663476 if ($PERL518 and $sv -> EXTFLAGS & RXf_EVAL_SEEN) {
34673477 $initpm -> add(" PL_hints &= ~HINT_RE_EVAL;" );
34683478 }
@@ -3471,15 +3481,11 @@ sub B::REGEXP::save {
34713481 # since 5.17.6 the SvLEN stores RX_WRAPPED(rx)
34723482 $init -> add(sprintf (" SvCUR(&sv_list[%d ]) = %d ;" , $ix , $cur ),
34733483 " SvLEN(&sv_list[$ix ]) = 0;" );
3474- } elsif ((!$CPERL51 and $] < 5.027003)
3475- or ($CPERL51 and $] < 5.027002)) {
3476- $init -> add(" sv_list[$ix ].sv_u.svu_rx = (struct regexp*)sv_list[$ix ].sv_any;" );
3477- } else { # since df6b4bd56551f2d39f7c
3478- if ($sv -> FLAGS & SVt_PVLV) {
3479- $init -> add(" { struct regexp* rx = (struct regexp*)sv_list[$ix ].sv_any;" ,
3484+ } elsif (!$rx_or_pv and $sv -> FLAGS & SVt_PVLV) { # since df6b4bd56551f2d39f7c
3485+ # $init->add("sv_list[$ix].sv_u.svu_pv = (char*)sv_list[$ix].sv_any;");
3486+ $initpm -> add(" { struct regexp* rx = (struct regexp*)sv_list[$ix ].sv_any;" ,
34803487 " rx->xpv_len_u.xpvlenu_rx = (struct regexp*)sv_list[$ix ].sv_any;" ,
34813488 " }" );
3482- }
34833489 }
34843490 $svsect -> debug( $fullname , $sv -> flagspv ) if $debug {flags };
34853491 $sym = savesym( $sv , sprintf ( " &sv_list[%d ]" , $ix ) );
0 commit comments