Change 30065 by [EMAIL PROTECTED] on 2007/01/29 18:52:30
Integrate:
[ 29040]
panic if we attempt to sv_setsv to or from an already freed SV.
[ 29097]
No warning was produced if perl failed to load PerlIO::scalar
(contrary to other PerlIO layers.)
[ 29108]
Fix small leak with -F at interpreter destruction
[ 29116]
Subject: Re: [perl #40583] sprintf "%#04X" also uppercases the 0x-prefix
From: SADAHIRO Tomoyuki <[EMAIL PROTECTED]>
Date: Fri, 27 Oct 2006 00:19:34 +0900
Message-Id: <[EMAIL PROTECTED]>
[ 29143]
Change the non-mkstemp, non-win32 code path of PerlIO_tmpfile
to use PerlIO_fdopen so that when the tmpfile is closed we do
not decrement a ref count that doesn't exist or is zero.
Affected files ...
... //depot/maint-5.8/perl/perl.c#197 integrate
... //depot/maint-5.8/perl/perlio.c#101 integrate
... //depot/maint-5.8/perl/pod/perlfunc.pod#90 integrate
... //depot/maint-5.8/perl/sv.c#333 integrate
... //depot/maint-5.8/perl/t/op/sprintf.t#19 integrate
Differences ...
==== //depot/maint-5.8/perl/perl.c#197 (text) ====
Index: perl/perl.c
--- perl/perl.c#196~30061~ 2007-01-29 09:39:20.000000000 -0800
+++ perl/perl.c 2007-01-29 10:52:30.000000000 -0800
@@ -963,6 +963,11 @@
SvREFCNT_dec(PL_rsfp_filters);
PL_rsfp_filters = NULL;
+ if (PL_minus_F) {
+ Safefree(PL_splitstr);
+ PL_splitstr = NULL;
+ }
+
/* switches */
PL_preprocess = FALSE;
PL_minus_n = FALSE;
==== //depot/maint-5.8/perl/perlio.c#101 (text) ====
Index: perl/perlio.c
--- perl/perlio.c#100~30057~ 2007-01-29 07:55:07.000000000 -0800
+++ perl/perlio.c 2007-01-29 10:52:30.000000000 -0800
@@ -1439,8 +1439,14 @@
/*
* For any scalar type load the handler which is bundled with perl
*/
- if (SvTYPE(sv) < SVt_PVAV)
- return PerlIO_find_layer(aTHX_ STR_WITH_LEN("scalar"), 1);
+ if (SvTYPE(sv) < SVt_PVAV) {
+ PerlIO_funcs *f = PerlIO_find_layer(aTHX_ STR_WITH_LEN("scalar"), 1);
+ /* This isn't supposed to happen, since PerlIO::scalar is core,
+ * but could happen anyway in smaller installs or with PAR */
+ if (!f && ckWARN(WARN_LAYER))
+ Perl_warner(aTHX_ packWARN(WARN_LAYER), "Unknown PerlIO layer
\"scalar\"");
+ return f;
+ }
/*
* For other types allow if layer is known but don't try and load it
@@ -5014,16 +5020,9 @@
# else /* !HAS_MKSTEMP, fallback to stdio tmpfile(). */
FILE * const stdio = PerlSIO_tmpfile();
- if (stdio) {
- if ((f = PerlIO_push(aTHX_(PerlIO_allocate(aTHX)),
- PERLIO_FUNCS_CAST(&PerlIO_stdio),
- "w+", NULL))) {
- PerlIOStdio * const s = PerlIOSelf(f, PerlIOStdio);
-
- if (s)
- s->stdio = stdio;
- }
- }
+ if (stdio)
+ f = PerlIO_fdopen(fileno(stdio), "w+");
+
# endif /* else HAS_MKSTEMP */
#endif /* else WIN32 */
return f;
==== //depot/maint-5.8/perl/pod/perlfunc.pod#90 (text) ====
Index: perl/pod/perlfunc.pod
--- perl/pod/perlfunc.pod#89~30058~ 2007-01-29 08:46:38.000000000 -0800
+++ perl/pod/perlfunc.pod 2007-01-29 10:52:30.000000000 -0800
@@ -5415,21 +5415,27 @@
=item flags
one or more of:
+
space prefix positive number with a space
+ prefix positive number with a plus sign
- left-justify within the field
0 use zeros, not spaces, to right-justify
- # prefix non-zero octal with "0", non-zero hex with "0x",
- non-zero binary with "0b"
+ # ensure the leading "0" for any octal,
+ prefix non-zero hexadecimal with "0x" or "0X",
+ prefix non-zero binary with "0b"
For example:
- printf '<% d>', 12; # prints "< 12>"
- printf '<%+d>', 12; # prints "<+12>"
- printf '<%6s>', 12; # prints "< 12>"
- printf '<%-6s>', 12; # prints "<12 >"
- printf '<%06s>', 12; # prints "<000012>"
- printf '<%#x>', 12; # prints "<0xc>"
+ printf '<% d>', 12; # prints "< 12>"
+ printf '<%+d>', 12; # prints "<+12>"
+ printf '<%6s>', 12; # prints "< 12>"
+ printf '<%-6s>', 12; # prints "<12 >"
+ printf '<%06s>', 12; # prints "<000012>"
+ printf '<%#o>', 12; # prints "<014>"
+ printf '<%#x>', 12; # prints "<0xc>"
+ printf '<%#X>', 12; # prints "<0XC>"
+ printf '<%#b>', 12; # prints "<0b1100>"
+ printf '<%#B>', 12; # prints "<0B1100>"
When a space and a plus sign are given as the flags at once,
a plus sign is used to prefix a positive number.
@@ -5437,6 +5443,13 @@
printf '<%+ d>', 12; # prints "<+12>"
printf '<% +d>', 12; # prints "<+12>"
+When the # flag and a precision are given in the %o conversion,
+the precision is incremented if it's necessary for the leading "0".
+
+ printf '<%#.5o>', 012; # prints "<00012>"
+ printf '<%#.5o>', 012345; # prints "<012345>"
+ printf '<%#.0o>', 0; # prints "<0>"
+
=item vector flag
This flag tells perl to interpret the supplied string as a vector of
==== //depot/maint-5.8/perl/sv.c#333 (text) ====
Index: perl/sv.c
--- perl/sv.c#332~30063~ 2007-01-29 10:20:31.000000000 -0800
+++ perl/sv.c 2007-01-29 10:52:30.000000000 -0800
@@ -3292,9 +3292,18 @@
if (sstr == dstr)
return;
+
+ if (SvIS_FREED(dstr)) {
+ Perl_croak(aTHX_ "panic: attempt to copy value %" SVf
+ " to a freed scalar %p", sstr, dstr);
+ }
SV_CHECK_THINKFIRST(dstr);
if (!sstr)
sstr = &PL_sv_undef;
+ if (SvIS_FREED(sstr)) {
+ Perl_croak(aTHX_ "panic: attempt to copy freed scalar %p to %p", sstr,
+ dstr);
+ }
stype = SvTYPE(sstr);
dtype = SvTYPE(dstr);
@@ -8543,7 +8552,8 @@
if (has_precis) {
if (precis > elen)
zeros = precis - elen;
- else if (precis == 0 && elen == 1 && *ptr == '0')
+ else if (precis == 0 && elen == 1 && *eptr == '0'
+ && !(base == 8 && alt)) /* "%#.0o" prints "0" */
elen = 0;
/* a precision nullifies the 0 flag. */
==== //depot/maint-5.8/perl/t/op/sprintf.t#19 (xtext) ====
Index: perl/t/op/sprintf.t
--- perl/t/op/sprintf.t#18~30058~ 2007-01-29 08:46:38.000000000 -0800
+++ perl/t/op/sprintf.t 2007-01-29 10:52:30.000000000 -0800
@@ -216,6 +216,26 @@
>% 6.5b< >12< > 01100<
>%06.5b< >12< > 01100< >0 flag with precision: no effect<
>%.5b< >12< >01100<
+>%.0b< >0< ><
+>%+.0b< >0< ><
+>% .0b< >0< ><
+>%-.0b< >0< ><
+>%#.0b< >0< ><
+>%#3.0b< >0< > <
+>%#3.1b< >0< > 0<
+>%#3.2b< >0< > 00<
+>%#3.3b< >0< >000<
+>%#3.4b< >0< >0000<
+>%.0b< >1< >1<
+>%+.0b< >1< >1<
+>% .0b< >1< >1<
+>%-.0b< >1< >1<
+>%#.0b< >1< >0b1<
+>%#3.0b< >1< >0b1<
+>%#3.1b< >1< >0b1<
+>%#3.2b< >1< >0b01<
+>%#3.3b< >1< >0b001<
+>%#3.4b< >1< >0b0001<
>%c< >ord('A')< >A<
>%10c< >ord('A')< > A<
>%#10c< >ord('A')< > A< ># modifier: no effect<
@@ -409,6 +429,28 @@
>% 4.o< >36< > 44<
>%04.o< >36< > 44< >0 flag with precision: no effect<
>%.3o< >18< >022<
+>%.0o< >0< ><
+>%+.0o< >0< ><
+>% .0o< >0< ><
+>%-.0o< >0< ><
+>%#.0o< >0< >0<
+>%#3.0o< >0< > 0<
+>%#3.1o< >0< > 0<
+>%#3.2o< >0< > 00<
+>%#3.3o< >0< >000<
+>%#3.4o< >0< >0000<
+>%.0o< >1< >1<
+>%+.0o< >1< >1<
+>% .0o< >1< >1<
+>%-.0o< >1< >1<
+>%#.0o< >1< >01<
+>%#3.0o< >1< > 01<
+>%#3.1o< >1< > 01<
+>%#3.2o< >1< > 01<
+>%#3.3o< >1< >001<
+>%#3.4o< >1< >0001<
+>%#.5o< >012345< >012345<
+>%#.5o< >012< >00012<
>%#4o< >17< > 021<
>%#-4o< >17< >021 <
>%-#4o< >17< >021 <
@@ -501,6 +543,23 @@
>% .0x< >0< ><
>%-.0x< >0< ><
>%#.0x< >0< ><
+>%#3.0x< >0< > <
+>%#3.1x< >0< > 0<
+>%#3.2x< >0< > 00<
+>%#3.3x< >0< >000<
+>%#3.4x< >0< >0000<
+>%.0x< >1< >1<
+>%+.0x< >1< >1<
+>% .0x< >1< >1<
+>%-.0x< >1< >1<
+>%#.0x< >1< >0x1<
+>%#3.0x< >1< >0x1<
+>%#3.1x< >1< >0x1<
+>%#3.2x< >1< >0x01<
+>%#3.3x< >1< >0x001<
+>%#3.4x< >1< >0x0001<
+>%#.5x< >0x12345< >0x12345<
+>%#.5x< >0x12< >0x00012<
>%#4x< >28< >0x1c<
>%#4.3x< >28< >0x01c<
>%#-4.3x< >28< >0x01c<
@@ -569,8 +628,12 @@
>%v#x< >''< >%v#x INVALID<
>%v02x< >"foo\012"< >66.6f.6f.0a<
>%#v.8b< >"\141\000\142"< >0b01100001.00000000.0b01100010<
>>perl #39530<
+>%#v.0o< >"\001\000\002\000"< >01.0.02.0<
+>%#v.1o< >"\001\000\002\000"< >01.0.02.0<
>%#v.4o< >"\141\000\142"< >0141.0000.0142< >perl #39530<
>%#v.3i< >"\141\000\142"< >097.000.098< >perl #39530<
+>%#v.0x< >"\001\000\002\000"< >0x1..0x2.<
+>%#v.1x< >"\001\000\002\000"< >0x1.0.0x2.0<
>%#v.2x< >"\141\000\142"< >0x61.00.0x62< >perl #39530<
>%#v.2X< >"\141\000\142"< >0X61.00.0X62< >perl #39530<
>%#v.8b< >"\141\017\142"< >0b01100001.0b00001111.0b01100010<
>>perl #39530<
End of Patch.