Change 29961 by [EMAIL PROTECTED] on 2007/01/24 22:12:24
Integrate:
[ 27948]
Subject: [perl #38475] attribute multiline fix (in tokenizer)
From: [EMAIL PROTECTED] (via RT) <[EMAIL PROTECTED]>
Date: Thu, 09 Feb 2006 06:33:51 -0800
Message-ID: <[EMAIL PROTECTED]>
[ 27950]
Add regression test for bug #38475
[ 27986]
[perl #39012] another REIFY bug
Affected files ...
... //depot/maint-5.8/perl/MANIFEST#294 integrate
... //depot/maint-5.8/perl/scope.c#61 integrate
... //depot/maint-5.8/perl/t/op/attrhand.t#1 branch
... //depot/maint-5.8/perl/t/op/local.t#10 integrate
... //depot/maint-5.8/perl/toke.c#144 integrate
Differences ...
==== //depot/maint-5.8/perl/MANIFEST#294 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST#293~29902~ 2007-01-20 15:57:28.000000000 -0800
+++ perl/MANIFEST 2007-01-24 14:12:24.000000000 -0800
@@ -2748,6 +2748,7 @@
t/op/arith.t See if arithmetic works
t/op/array.t See if array operations work
t/op/assignwarn.t See if OP= operators warn correctly for undef
targets
+t/op/attrhand.t See if attribute handlers work
t/op/attrs.t See if attributes on declarations work
t/op/auto.t See if autoincrement et all work
t/op/avhv.t See if pseudo-hashes work
==== //depot/maint-5.8/perl/scope.c#61 (text) ====
Index: perl/scope.c
--- perl/scope.c#60~29953~ 2007-01-24 09:01:34.000000000 -0800
+++ perl/scope.c 2007-01-24 14:12:24.000000000 -0800
@@ -858,9 +858,9 @@
value = (SV*)SSPOPPTR;
i = SSPOPINT;
av = (AV*)SSPOPPTR;
+ ptr = av_fetch(av,i,1);
if (!AvREAL(av) && AvREIFY(av)) /* undo reify guard */
SvREFCNT_dec(value);
- ptr = av_fetch(av,i,1);
if (ptr) {
sv = *(SV**)ptr;
if (sv && sv != &PL_sv_undef) {
==== //depot/maint-5.8/perl/t/op/attrhand.t#1 (text) ====
Index: perl/t/op/attrhand.t
--- /dev/null 2007-01-16 11:55:45.526841103 -0800
+++ perl/t/op/attrhand.t 2007-01-24 14:12:24.000000000 -0800
@@ -0,0 +1,37 @@
+#!/usr/bin/perl -w
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ require './test.pl';
+}
+
+plan tests => 1;
+
+# test for bug #38475: parsing errors with multiline attributes
+
+package Antler;
+
+use Attribute::Handlers;
+
+sub TypeCheck :ATTR(CODE,RAWDATA) {
+ ::ok(1);
+}
+
+sub WrongAttr :ATTR(CODE,RAWDATA) {
+ ::ok(0);
+}
+
+package Deer;
+use base 'Antler';
+
+sub something : TypeCheck(
+ QNET::Util::Object,
+ QNET::Util::Object,
+ QNET::Util::Object
+) { # WrongAttr (perl tokenizer bug)
+ # keep this ^ lined up !
+ return 42;
+}
+
+something();
==== //depot/maint-5.8/perl/t/op/local.t#10 (xtext) ====
Index: perl/t/op/local.t
--- perl/t/op/local.t#9~29943~ 2007-01-24 04:06:54.000000000 -0800
+++ perl/t/op/local.t 2007-01-24 14:12:24.000000000 -0800
@@ -5,7 +5,7 @@
@INC = qw(. ../lib);
require './test.pl';
}
-plan tests => 113;
+plan tests => 114;
my $list_assignment_supported = 1;
@@ -416,3 +416,15 @@
is($h{"\243"}, "pound");
is($h{"\302\240"}, "octects");
}
+
+# [perl #39012] localizing @_ element then shifting frees element too # soon
+
+{
+ my $x;
+ my $y = bless [], 'X39012';
+ sub X39012::DESTROY { $x++ }
+ sub { local $_[0]; shift }->($y);
+ ok(!$x, '[perl #39012]');
+
+}
+
==== //depot/maint-5.8/perl/toke.c#144 (text) ====
Index: perl/toke.c
--- perl/toke.c#143~29959~ 2007-01-24 12:33:04.000000000 -0800
+++ perl/toke.c 2007-01-24 14:12:24.000000000 -0800
@@ -3255,6 +3255,7 @@
attrs = NULL;
while (isIDFIRST_lazy_if(s,UTF)) {
I32 tmp;
+ SV *sv;
d = scan_word(s, PL_tokenbuf, sizeof PL_tokenbuf, FALSE, &len);
if (isLOWER(*s) && (tmp = keyword(PL_tokenbuf, len))) {
if (tmp < 0) tmp = -tmp;
@@ -3271,6 +3272,7 @@
break;
}
}
+ sv = newSVpvn(s, len);
if (*d == '(') {
d = scan_str(d,TRUE,TRUE);
if (!d) {
@@ -3281,11 +3283,11 @@
yyerror("Unterminated attribute parameter in attribute
list");
if (attrs)
op_free(attrs);
+ sv_free(sv);
return REPORT(0); /* EOF indicator */
}
}
if (PL_lex_stuff) {
- SV *sv = newSVpvn(s, len);
sv_catsv(sv, PL_lex_stuff);
attrs = append_elem(OP_LIST, attrs,
newSVOP(OP_CONST, 0, sv));
@@ -3293,7 +3295,8 @@
PL_lex_stuff = NULL;
}
else {
- if (len == 6 && strnEQ(s, "unique", len)) {
+ if (len == 6 && strnEQ(SvPVX(sv), "unique", len)) {
+ sv_free(sv);
if (PL_in_my == KEY_our)
#ifdef USE_ITHREADS
GvUNIQUE_on(cGVOPx_gv(yylval.opval));
@@ -3306,12 +3309,18 @@
/* NOTE: any CV attrs applied here need to be part of
the CVf_BUILTIN_ATTRS define in cv.h! */
- else if (!PL_in_my && len == 6 && strnEQ(s, "lvalue", len))
+ else if (!PL_in_my && len == 6 && strnEQ(SvPVX(sv),
"lvalue", len)) {
+ sv_free(sv);
CvLVALUE_on(PL_compcv);
- else if (!PL_in_my && len == 6 && strnEQ(s, "locked", len))
+ }
+ else if (!PL_in_my && len == 6 && strnEQ(SvPVX(sv),
"locked", len)) {
+ sv_free(sv);
CvLOCKED_on(PL_compcv);
- else if (!PL_in_my && len == 6 && strnEQ(s, "method", len))
+ }
+ else if (!PL_in_my && len == 6 && strnEQ(SvPVX(sv),
"method", len)) {
+ sv_free(sv);
CvMETHOD_on(PL_compcv);
+ }
/* After we've set the flags, it could be argued that
we don't need to do the attributes.pm-based setting
process, and shouldn't bother appending recognized
@@ -3325,7 +3334,7 @@
else
attrs = append_elem(OP_LIST, attrs,
newSVOP(OP_CONST, 0,
- newSVpvn(s, len)));
+ sv));
}
s = PEEKSPACE(d);
if (*s == ':' && s[1] != ':')
End of Patch.