Change 12027 by jhi@alpha on 2001/09/15 12:33:49
Subject: Re: [ID 20010815.012] Unfortunate interaction between -0 cmd line arg
& (??{CODE}) regex
From: Hugo van der Sanden <[EMAIL PROTECTED]>
Date: Sun, 09 Sep 2001 18:41:54 +0100
Message-Id: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/Porting/findvars#4 edit
... //depot/perl/ext/ByteLoader/bytecode.h#23 edit
... //depot/perl/ext/Thread/Thread.xs#64 edit
... //depot/perl/mg.c#198 edit
... //depot/perl/op.c#444 edit
... //depot/perl/perl.c#370 edit
... //depot/perl/perl.h#393 edit
... //depot/perl/pp_ctl.c#283 edit
... //depot/perl/sv.c#469 edit
... //depot/perl/t/run/kill_perl.t#8 edit
... //depot/perl/thrdvar.h#49 edit
... //depot/perl/toke.c#385 edit
... //depot/perl/util.c#293 edit
... //depot/perl/wince/perldll.def#3 edit
Differences ...
==== //depot/perl/Porting/findvars#4 (xtext) ====
Index: perl/Porting/findvars
--- perl/Porting/findvars.~1~ Sat Sep 15 06:45:06 2001
+++ perl/Porting/findvars Sat Sep 15 06:45:06 2001
@@ -212,7 +212,6 @@
nice_chunk_size
ninterps
nomemok
-nrs
nthreads
nthreads_cond
numeric_local
==== //depot/perl/ext/ByteLoader/bytecode.h#23 (text) ====
Index: perl/ext/ByteLoader/bytecode.h
--- perl/ext/ByteLoader/bytecode.h.~1~ Sat Sep 15 06:45:06 2001
+++ perl/ext/ByteLoader/bytecode.h Sat Sep 15 06:45:06 2001
@@ -182,8 +182,6 @@
ENTER; \
SAVECOPFILE(&PL_compiling); \
SAVECOPLINE(&PL_compiling); \
- save_svref(&PL_rs); \
- sv_setsv(PL_rs, PL_nrs); \
if (!PL_beginav) \
PL_beginav = newAV(); \
av_push(PL_beginav, cv); \
==== //depot/perl/ext/Thread/Thread.xs#64 (text) ====
Index: perl/ext/Thread/Thread.xs
--- perl/ext/Thread/Thread.xs.~1~ Sat Sep 15 06:45:06 2001
+++ perl/ext/Thread/Thread.xs Sat Sep 15 06:45:06 2001
@@ -174,7 +174,6 @@
SvREFCNT_dec(PL_ofs_sv);
SvREFCNT_dec(PL_rs);
- SvREFCNT_dec(PL_nrs);
SvREFCNT_dec(PL_statname);
SvREFCNT_dec(PL_errors);
Safefree(PL_screamfirst);
==== //depot/perl/mg.c#198 (text) ====
Index: perl/mg.c
--- perl/mg.c.~1~ Sat Sep 15 06:45:06 2001
+++ perl/mg.c Sat Sep 15 06:45:06 2001
@@ -1911,10 +1911,8 @@
PL_multiline = (i != 0);
break;
case '/':
- SvREFCNT_dec(PL_nrs);
- PL_nrs = newSVsv(sv);
SvREFCNT_dec(PL_rs);
- PL_rs = SvREFCNT_inc(PL_nrs);
+ PL_rs = newSVsv(sv);
break;
case '\\':
if (PL_ors_sv)
==== //depot/perl/op.c#444 (text) ====
Index: perl/op.c
--- perl/op.c.~1~ Sat Sep 15 06:45:06 2001
+++ perl/op.c Sat Sep 15 06:45:06 2001
@@ -4957,8 +4957,6 @@
ENTER;
SAVECOPFILE(&PL_compiling);
SAVECOPLINE(&PL_compiling);
- save_svref(&PL_rs);
- sv_setsv(PL_rs, PL_nrs);
if (!PL_beginav)
PL_beginav = newAV();
==== //depot/perl/perl.c#370 (text) ====
Index: perl/perl.c
--- perl/perl.c.~1~ Sat Sep 15 06:45:06 2001
+++ perl/perl.c Sat Sep 15 06:45:06 2001
@@ -212,8 +212,7 @@
#endif
}
- PL_nrs = newSVpvn("\n", 1);
- PL_rs = SvREFCNT_inc(PL_nrs);
+ PL_rs = newSVpvn("\n", 1);
init_stacks();
@@ -540,9 +539,6 @@
SvREFCNT_dec(PL_rs); /* $/ */
PL_rs = Nullsv;
- SvREFCNT_dec(PL_nrs); /* $/ helper */
- PL_nrs = Nullsv;
-
PL_multiline = 0; /* $* */
Safefree(PL_osname); /* $^O */
PL_osname = Nullch;
@@ -1431,10 +1427,12 @@
PL_e_script = Nullsv;
}
- /* now that script is parsed, we can modify record separator */
- SvREFCNT_dec(PL_rs);
- PL_rs = SvREFCNT_inc(PL_nrs);
+/*
+ Not sure that this is still the right place to do this now that we
+ no longer use PL_nrs. HVDS 2001/09/09
+*/
sv_setsv(get_sv("/", TRUE), PL_rs);
+
if (PL_do_undump)
my_unexec();
@@ -2151,14 +2149,14 @@
I32 flags = 0;
numlen = 4;
rschar = (U32)grok_oct(s, &numlen, &flags, NULL);
- SvREFCNT_dec(PL_nrs);
+ SvREFCNT_dec(PL_rs);
if (rschar & ~((U8)~0))
- PL_nrs = &PL_sv_undef;
+ PL_rs = &PL_sv_undef;
else if (!rschar && numlen >= 2)
- PL_nrs = newSVpvn("", 0);
+ PL_rs = newSVpvn("", 0);
else {
char ch = rschar;
- PL_nrs = newSVpvn(&ch, 1);
+ PL_rs = newSVpvn(&ch, 1);
}
return s + numlen;
}
@@ -2288,11 +2286,11 @@
s += numlen;
}
else {
- if (RsPARA(PL_nrs)) {
+ if (RsPARA(PL_rs)) {
PL_ors_sv = newSVpvn("\n\n",2);
}
else {
- PL_ors_sv = newSVsv(PL_nrs);
+ PL_ors_sv = newSVsv(PL_rs);
}
}
return s;
==== //depot/perl/perl.h#393 (text) ====
Index: perl/perl.h
--- perl/perl.h.~1~ Sat Sep 15 06:45:06 2001
+++ perl/perl.h Sat Sep 15 06:45:06 2001
@@ -3067,7 +3067,7 @@
#define HINT_FILETEST_ACCESS 0x00400000
#define HINT_UTF8 0x00800000
-/* Various states of an input record separator SV (rs, nrs) */
+/* Various states of the input record separator SV (rs) */
#define RsSNARF(sv) (! SvOK(sv))
#define RsSIMPLE(sv) (SvOK(sv) && (! SvPOK(sv) || SvCUR(sv)))
#define RsPARA(sv) (SvPOK(sv) && ! SvCUR(sv))
==== //depot/perl/pp_ctl.c#283 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c.~1~ Sat Sep 15 06:45:06 2001
+++ perl/pp_ctl.c Sat Sep 15 06:45:06 2001
@@ -2894,8 +2894,6 @@
PL_error_count = 0;
PL_curcop = &PL_compiling;
PL_curcop->cop_arybase = 0;
- SvREFCNT_dec(PL_rs);
- PL_rs = newSVpvn("\n", 1);
if (saveop && saveop->op_flags & OPf_SPECIAL)
PL_in_eval |= EVAL_KEEPERR;
else
@@ -2933,8 +2931,6 @@
Perl_croak(aTHX_ "%sCompilation failed in regexp",
(*msg ? msg : "Unknown error\n"));
}
- SvREFCNT_dec(PL_rs);
- PL_rs = SvREFCNT_inc(PL_nrs);
#ifdef USE_5005THREADS
MUTEX_LOCK(&PL_eval_mutex);
PL_eval_owner = 0;
@@ -2943,8 +2939,6 @@
#endif /* USE_5005THREADS */
RETPUSHUNDEF;
}
- SvREFCNT_dec(PL_rs);
- PL_rs = SvREFCNT_inc(PL_nrs);
CopLINE_set(&PL_compiling, 0);
if (startop) {
*startop = PL_eval_root;
==== //depot/perl/sv.c#469 (text) ====
Index: perl/sv.c
--- perl/sv.c.~1~ Sat Sep 15 06:45:06 2001
+++ perl/sv.c Sat Sep 15 06:45:06 2001
@@ -5507,13 +5507,19 @@
register STDCHAR *bp;
register I32 cnt;
I32 i = 0;
+ I32 rspara = 0;
SV_CHECK_THINKFIRST(sv);
(void)SvUPGRADE(sv, SVt_PV);
SvSCREAM_off(sv);
- if (RsSNARF(PL_rs)) {
+ if (PL_curcop == &PL_compiling) {
+ /* we always read code in line mode */
+ rsptr = "\n";
+ rslen = 1;
+ }
+ else if (RsSNARF(PL_rs)) {
rsptr = NULL;
rslen = 0;
}
@@ -5545,6 +5551,7 @@
else if (RsPARA(PL_rs)) {
rsptr = "\n\n";
rslen = 2;
+ rspara = 1;
}
else {
/* Get $/ i.e. PL_rs into same encoding as stream wants */
@@ -5563,7 +5570,7 @@
rslast = rslen ? rsptr[rslen - 1] : '\0';
- if (RsPARA(PL_rs)) { /* have to do this both before and after */
+ if (rspara) { /* have to do this both before and after */
do { /* to make sure file boundaries work right */
if (PerlIO_eof(fp))
return 0;
@@ -5769,7 +5776,7 @@
}
}
- if (RsPARA(PL_rs)) { /* have to do this both before and after */
+ if (rspara) { /* have to do this both before and after */
while (i != EOF) { /* to make sure file boundaries work right */
i = PerlIO_getc(fp);
if (i != '\n') {
@@ -10175,7 +10182,6 @@
PL_tainted = proto_perl->Ttainted;
PL_curpm = proto_perl->Tcurpm; /* XXX No PMOP ref count */
- PL_nrs = sv_dup_inc(proto_perl->Tnrs, param);
PL_rs = sv_dup_inc(proto_perl->Trs, param);
PL_last_in_gv = gv_dup(proto_perl->Tlast_in_gv, param);
PL_ofs_sv = sv_dup_inc(proto_perl->Tofs_sv, param);
==== //depot/perl/t/run/kill_perl.t#8 (text) ====
Index: perl/t/run/kill_perl.t
--- perl/t/run/kill_perl.t.~1~ Sat Sep 15 06:45:06 2001
+++ perl/t/run/kill_perl.t Sat Sep 15 06:45:06 2001
@@ -802,3 +802,12 @@
EXPECT
Can't modify constant item in undef operator at - line 1, near "foo;"
Execution of - aborted due to compilation errors.
+######## (?{...}) compilation bounces on PL_rs
+-0
+{
+ /(?{ $x })/;
+ # {
+}
+BEGIN { print "ok\n" }
+EXPECT
+ok
==== //depot/perl/thrdvar.h#49 (text) ====
Index: perl/thrdvar.h
--- perl/thrdvar.h.~1~ Sat Sep 15 06:45:06 2001
+++ perl/thrdvar.h Sat Sep 15 06:45:06 2001
@@ -81,7 +81,7 @@
/* Fields used by magic variables such as $@, $/ and so on */
PERLVAR(Ttainted, bool) /* using variables controlled by $< */
PERLVAR(Tcurpm, PMOP *) /* what to do \ interps in REs from */
-PERLVAR(Tnrs, SV *)
+PERLVAR(Tunused_1, SV *) /* placeholder: was Tnrs */
/*
=for apidoc mn|SV*|PL_rs
==== //depot/perl/toke.c#385 (text) ====
Index: perl/toke.c
--- perl/toke.c.~1~ Sat Sep 15 06:45:06 2001
+++ perl/toke.c Sat Sep 15 06:45:06 2001
@@ -445,8 +445,6 @@
PL_oldoldbufptr = PL_oldbufptr = PL_bufptr = PL_linestart = SvPVX(PL_linestr);
PL_bufend = PL_bufptr + SvCUR(PL_linestr);
PL_last_lop = PL_last_uni = Nullch;
- SvREFCNT_dec(PL_rs);
- PL_rs = newSVpvn("\n", 1);
PL_rsfp = 0;
}
==== //depot/perl/util.c#293 (text) ====
Index: perl/util.c
--- perl/util.c.~1~ Sat Sep 15 06:45:06 2001
+++ perl/util.c Sat Sep 15 06:45:06 2001
@@ -3052,8 +3052,7 @@
PL_tainted = t->Ttainted;
PL_curpm = t->Tcurpm; /* XXX No PMOP ref count */
- PL_nrs = newSVsv(t->Tnrs);
- PL_rs = t->Tnrs ? SvREFCNT_inc(PL_nrs) : Nullsv;
+ PL_rs = newSVsv(t->Trs);
PL_last_in_gv = Nullgv;
PL_ofs_sv = t->Tofs_sv ? SvREFCNT_inc(PL_ofs_sv) : Nullsv;
PL_defoutgv = (GV*)SvREFCNT_inc(t->Tdefoutgv);
==== //depot/perl/wince/perldll.def#3 (text) ====
Index: perl/wince/perldll.def
--- perl/wince/perldll.def.~1~ Sat Sep 15 06:45:06 2001
+++ perl/wince/perldll.def Sat Sep 15 06:45:06 2001
@@ -184,7 +184,6 @@
PL_no_usym
PL_no_wrongref
PL_nomemok
- PL_nrs
PL_ofmt
PL_oldbufptr
PL_oldname
End of Patch.