Change 33766 by [EMAIL PROTECTED] on 2008/04/30 08:17:51
Subject: [PATCH] Double magic/warnings with binmode $fh, undef
From: "Vincent Pit" <[EMAIL PROTECTED]>
Date: Tue, 29 Apr 2008 19:33:21 +0200 (CEST)
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/doio.c#369 edit
... //depot/perl/embed.fnc#614 edit
... //depot/perl/embed.h#760 edit
... //depot/perl/op.c#1003 edit
... //depot/perl/pp_sys.c#559 edit
... //depot/perl/proto.h#948 edit
... //depot/perl/t/lib/warnings/9uninit#27 edit
Differences ...
==== //depot/perl/doio.c#369 (text) ====
Index: perl/doio.c
--- perl/doio.c#368~33310~ 2008-02-14 07:44:14.000000000 -0800
+++ perl/doio.c 2008-04-30 01:17:51.000000000 -0700
@@ -1096,12 +1096,10 @@
}
int
-Perl_mode_from_discipline(pTHX_ SV *discp)
+Perl_mode_from_discipline(pTHX_ const char *s, STRLEN len)
{
int mode = O_BINARY;
- if (discp) {
- STRLEN len;
- const char *s = SvPV_const(discp,len);
+ if (s) {
while (*s) {
if (*s == ':') {
switch (s[1]) {
==== //depot/perl/embed.fnc#614 (text) ====
Index: perl/embed.fnc
--- perl/embed.fnc#613~33706~ 2008-04-17 05:47:39.000000000 -0700
+++ perl/embed.fnc 2008-04-30 01:17:51.000000000 -0700
@@ -525,7 +525,7 @@
Ap |I32 |mg_size |NN SV* sv
Ap |void |mini_mktime |NN struct tm *ptm
EXp |OP* |mod |NULLOK OP* o|I32 type
-p |int |mode_from_discipline|NULLOK SV* discp
+p |int |mode_from_discipline|NULLOK const char* s|STRLEN len
Ap |const char* |moreswitches |NN const char* s
p |OP* |my |NN OP* o
Ap |NV |my_atof |NN const char *s
==== //depot/perl/embed.h#760 (text+w) ====
Index: perl/embed.h
--- perl/embed.h#759~33702~ 2008-04-17 00:58:29.000000000 -0700
+++ perl/embed.h 2008-04-30 01:17:51.000000000 -0700
@@ -2801,7 +2801,7 @@
#define mod(a,b) Perl_mod(aTHX_ a,b)
#endif
#ifdef PERL_CORE
-#define mode_from_discipline(a) Perl_mode_from_discipline(aTHX_ a)
+#define mode_from_discipline(a,b) Perl_mode_from_discipline(aTHX_ a,b)
#endif
#define moreswitches(a) Perl_moreswitches(aTHX_ a)
#ifdef PERL_CORE
==== //depot/perl/op.c#1003 (text) ====
Index: perl/op.c
--- perl/op.c#1002~33710~ 2008-04-18 03:42:17.000000000 -0700
+++ perl/op.c 2008-04-30 01:17:51.000000000 -0700
@@ -7415,7 +7415,9 @@
if (table) {
SV **svp = hv_fetchs(table, "open_IN", FALSE);
if (svp && *svp) {
- const I32 mode = mode_from_discipline(*svp);
+ STRLEN len = 0;
+ const char *d = SvPV_const(*svp, len);
+ const I32 mode = mode_from_discipline(d, len);
if (mode & O_BINARY)
o->op_private |= OPpOPEN_IN_RAW;
else if (mode & O_TEXT)
@@ -7424,7 +7426,9 @@
svp = hv_fetchs(table, "open_OUT", FALSE);
if (svp && *svp) {
- const I32 mode = mode_from_discipline(*svp);
+ STRLEN len = 0;
+ const char *d = SvPV_const(*svp, len);
+ const I32 mode = mode_from_discipline(d, len);
if (mode & O_BINARY)
o->op_private |= OPpOPEN_OUT_RAW;
else if (mode & O_TEXT)
==== //depot/perl/pp_sys.c#559 (text) ====
Index: perl/pp_sys.c
--- perl/pp_sys.c#558~33706~ 2008-04-17 05:47:39.000000000 -0700
+++ perl/pp_sys.c 2008-04-30 01:17:51.000000000 -0700
@@ -762,8 +762,12 @@
PUTBACK;
{
- const int mode = mode_from_discipline(discp);
- const char *const d = (discp ? SvPV_nolen_const(discp) : NULL);
+ STRLEN len = 0;
+ const char *d = NULL;
+ int mode;
+ if (discp)
+ d = SvPV_const(discp, len);
+ mode = mode_from_discipline(d, len);
if (PerlIO_binmode(aTHX_ fp, IoTYPE(io), mode, d)) {
if (IoOFP(io) && IoOFP(io) != IoIFP(io)) {
if (!PerlIO_binmode(aTHX_ IoOFP(io), IoTYPE(io), mode, d)) {
==== //depot/perl/proto.h#948 (text+w) ====
Index: perl/proto.h
--- perl/proto.h#947~33706~ 2008-04-17 05:47:39.000000000 -0700
+++ perl/proto.h 2008-04-30 01:17:51.000000000 -0700
@@ -1885,7 +1885,7 @@
assert(ptm)
PERL_CALLCONV OP* Perl_mod(pTHX_ OP* o, I32 type);
-PERL_CALLCONV int Perl_mode_from_discipline(pTHX_ SV* discp);
+PERL_CALLCONV int Perl_mode_from_discipline(pTHX_ const char* s, STRLEN
len);
PERL_CALLCONV const char* Perl_moreswitches(pTHX_ const char* s)
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_MORESWITCHES \
==== //depot/perl/t/lib/warnings/9uninit#27 (text) ====
Index: perl/t/lib/warnings/9uninit
--- perl/t/lib/warnings/9uninit#26~33758~ 2008-04-27 03:20:10.000000000
-0700
+++ perl/t/lib/warnings/9uninit 2008-04-30 01:17:51.000000000 -0700
@@ -1125,7 +1125,6 @@
Use of uninitialized value $m1 in umask at - line 19.
Use of uninitialized value $g1 in umask at - line 20.
Use of uninitialized value $m1 in binmode at - line 23.
-Use of uninitialized value $m1 in binmode at - line 23.
########
use warnings 'uninitialized';
my ($m1);
End of Patch.