diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-12-28 22:40:37 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-12-28 22:40:37 +0000 |
commit | f8503592a22431f4f2362d87270e54bfdb2d3177 (patch) | |
tree | 6f191f8e70da41a6f6a1b9e9ef14e5701687424f /op.c | |
parent | 931b58fb28fa5ca73161678109fa052134ce70b3 (diff) | |
download | perl-f8503592a22431f4f2362d87270e54bfdb2d3177.tar.gz |
With PAD_COMPNAME_GEN in SvUVX, SvCUR is trustworthy once more.
p4raw-id: //depot/perl@29633
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -4526,8 +4526,14 @@ Perl_newFOROP(pTHX_ I32 flags, char *label, line_t forline, OP *sv, OP *expr, OP } else Perl_croak(aTHX_ "Can't use %s for loop variable", PL_op_desc[sv->op_type]); - if (padoff && strEQ(PAD_COMPNAME_PV(padoff), "$_")) - iterpflags |= OPpITER_DEF; + if (padoff) { + SV *const namesv = PAD_COMPNAME_SV(padoff); + STRLEN len; + const char *const name = SvPV_const(namesv, len); + + if (len == 2 && name[0] == '$' && name[1] == '_') + iterpflags |= OPpITER_DEF; + } } else { const PADOFFSET offset = pad_findmy("$_"); @@ -6447,13 +6453,9 @@ Perl_ck_fun(pTHX_ OP *o) */ priv = OPpDEREF; if (kid->op_type == OP_PADSV) { - name = PAD_COMPNAME_PV(kid->op_targ); - /* SvCUR of a pad namesv can't be trusted - * (see PL_generation), so calc its length - * manually */ - if (name) - len = strlen(name); - + SV *const namesv + = PAD_COMPNAME_SV(kid->op_targ); + name = SvPV_const(namesv, len); } else if (kid->op_type == OP_RV2SV && kUNOP->op_first->op_type == OP_GV) |