Change 29901 by [EMAIL PROTECTED] on 2007/01/20 23:44:56
Integrate:
[ 27265]
Can merge the two arms of Perl_magic_getglob to save space.
[ 27268]
Test warnings for converting globs to other forms.
[ 27269]
sv_dump should report the PV for PVGVs, as it can get set.
(Typeglobs stringify via a call to GET magic, which uses the PV slot.)
[ 27322]
With PERL_DONT_CREATE_GVSV, don't need to create a new GvSV in
Perl_save_scalar.
Affected files ...
... //depot/maint-5.8/perl/dump.c#60 edit
... //depot/maint-5.8/perl/ext/Devel/Peek/t/Peek.t#10 integrate
... //depot/maint-5.8/perl/mg.c#125 integrate
... //depot/maint-5.8/perl/scope.c#54 integrate
... //depot/maint-5.8/perl/t/op/gv.t#8 integrate
Differences ...
==== //depot/maint-5.8/perl/dump.c#60 (text) ====
Index: perl/dump.c
--- perl/dump.c#59~29898~ 2007-01-20 10:43:49.000000000 -0800
+++ perl/dump.c 2007-01-20 15:44:56.000000000 -0800
@@ -1178,7 +1178,7 @@
SvREFCNT_dec(d);
return;
}
- if (type <= SVt_PVLV) {
+ if (type <= SVt_PVLV || type == SVt_PVGV) {
if (SvPVX_const(sv)) {
Perl_dump_indent(aTHX_ level, file," PV = 0x%"UVxf" ",
PTR2UV(SvPVX_const(sv)));
if (SvOOK(sv))
==== //depot/maint-5.8/perl/ext/Devel/Peek/t/Peek.t#10 (text) ====
Index: perl/ext/Devel/Peek/t/Peek.t
--- perl/ext/Devel/Peek/t/Peek.t#9~29776~ 2007-01-12 06:24:33.000000000
-0800
+++ perl/ext/Devel/Peek/t/Peek.t 2007-01-20 15:44:56.000000000 -0800
@@ -303,6 +303,7 @@
FLAGS = \\(GMG,SMG,MULTI(?:,IN_PAD)?\\)
IV = 0
NV = 0
+ PV = 0
MAGIC = $ADDR
MG_VIRTUAL = &PL_vtbl_glob
MG_TYPE = PERL_MAGIC_glob\(\*\)
==== //depot/maint-5.8/perl/mg.c#125 (text) ====
Index: perl/mg.c
--- perl/mg.c#124~29897~ 2007-01-20 10:14:46.000000000 -0800
+++ perl/mg.c 2007-01-20 15:44:56.000000000 -0800
@@ -1833,14 +1833,15 @@
int
Perl_magic_getglob(pTHX_ SV *sv, MAGIC *mg)
{
+ const U32 wasfake = SvFLAGS(sv) & SVf_FAKE;
PERL_UNUSED_ARG(mg);
- if (SvFAKE(sv)) { /* FAKE globs can get coerced */
- SvFAKE_off(sv);
- gv_efullname3(sv,((GV*)sv), "*");
- SvFAKE_on(sv);
- }
- else
- gv_efullname3(sv,((GV*)sv), "*"); /* a gv value, be nice */
+
+ /* FAKE globs can get coerced, so need to turn this off temporarily if it
+ is on. */
+ SvFAKE_off(sv);
+ gv_efullname3(sv,((GV*)sv), "*");
+ SvFLAGS(sv) |= wasfake;
+
return 0;
}
==== //depot/maint-5.8/perl/scope.c#54 (text) ====
Index: perl/scope.c
--- perl/scope.c#53~29897~ 2007-01-20 10:14:46.000000000 -0800
+++ perl/scope.c 2007-01-20 15:44:56.000000000 -0800
@@ -219,7 +219,7 @@
SV *
Perl_save_scalar(pTHX_ GV *gv)
{
- SV ** const sptr = &GvSV(gv);
+ SV ** const sptr = &GvSVn(gv);
PL_localizing = 1;
SvGETMAGIC(*sptr);
PL_localizing = 0;
@@ -285,7 +285,9 @@
IoFLAGS(gp->gp_io) |= IOf_ARGV|IOf_START;
}
GvGP(gv) = gp_ref(gp);
+#ifndef PERL_DONT_CREATE_GVSV
GvSV(gv) = newSV(0);
+#endif
GvLINE(gv) = CopLINE(PL_curcop);
/* XXX Ideally this cast would be replaced with a change to const char*
in the struct. */
==== //depot/maint-5.8/perl/t/op/gv.t#8 (xtext) ====
Index: perl/t/op/gv.t
--- perl/t/op/gv.t#7~29851~ 2007-01-17 07:41:23.000000000 -0800
+++ perl/t/op/gv.t 2007-01-20 15:44:56.000000000 -0800
@@ -12,7 +12,7 @@
use warnings;
require './test.pl';
-plan( tests => 131 );
+plan( tests => 147 );
# type coersion on assignment
$foo = 'foo';
@@ -89,6 +89,34 @@
is($msg, '');
*foo = undef;
like($msg, qr/Undefined value assigned to typeglob/);
+
+ no warnings 'once';
+ # test warnings for converting globs to other forms
+ my $copy = *PWOMPF;
+ foreach ($copy, *SKREEE) {
+ $msg = '';
+ my $victim = sprintf "%d", $_;
+ like($msg, qr/Argument "\*main::[A-Z]{6}" isn't numeric in sprintf/,
+ "Warning on conversion to IV");
+ is($victim, 0);
+
+ $msg = '';
+ $victim = sprintf "%u", $_;
+ like($msg, qr/Argument "\*main::[A-Z]{6}" isn't numeric in sprintf/,
+ "Warning on conversion to UV");
+ is($victim, 0);
+
+ $msg = '';
+ $victim = sprintf "%e", $_;
+ like($msg, qr/Argument "\*main::[A-Z]{6}" isn't numeric in sprintf/,
+ "Warning on conversion to NV");
+ like($victim, qr/^0\.0+E\+?00/i, "Expect floating point zero");
+
+ $msg = '';
+ $victim = sprintf "%s", $_;
+ is($msg, '', "No warning on stringification");
+ is($victim, '' . $_);
+ }
}
my $test = curr_test();
End of Patch.