This is my patch patch.1n for perl5.001.
[p5sagit/p5-mst-13.2.git] / toke.c
diff --git a/toke.c b/toke.c
index 0d3f74a..cdb12a3 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -1018,7 +1018,8 @@ filter_add(funcp, datasv)
     IoDIRP(datasv) = (DIR*)funcp; /* stash funcp into spare field */
     if (filter_debug)
        warn("filter_add func %lx (%s)", funcp, SvPV(datasv,na));
-    av_push(rsfp_filters, datasv);
+    av_unshift(rsfp_filters, 1);
+    av_store(rsfp_filters, 0, datasv) ;
     return(datasv);
 }
  
@@ -1033,8 +1034,10 @@ filter_del(funcp)
     if (!rsfp_filters || AvFILL(rsfp_filters)<0)
        return;
     /* if filter is on top of stack (usual case) just pop it off */
-    if (IoDIRP(FILTER_DATA(AvFILL(rsfp_filters))) == (void*)funcp){
-       sv_free(av_pop(rsfp_filters));
+    if (IoDIRP(FILTER_DATA(0)) == (void*)funcp){
+       /* sv_free(av_pop(rsfp_filters)); */
+       sv_free(av_shift(rsfp_filters));
+
         return;
     }
     /* we need to search for the correct entry and clear it    */
@@ -1051,12 +1054,12 @@ filter_read(idx, buf_sv, maxlen)
 {
     filter_t funcp;
     SV *datasv = NULL;
+
     if (!rsfp_filters)
        return -1;
     if (idx > AvFILL(rsfp_filters)){       /* Any more filters?        */
        /* Provide a default input filter to make life easy.    */
        /* Note that we append to the line. This is handy.      */
-       /* We ignore maxlen here                                */
        if (filter_debug)
            warn("filter_read %d: from rsfp\n", idx);
        if (maxlen) { 
@@ -2324,8 +2327,9 @@ yylex()
                    /* If not a declared subroutine, it's an indirect object. */
                    /* (But it's an indir obj regardless for sort.) */
 
-                   if (last_lop_op == OP_SORT ||
-                     (!immediate_paren && (!gv || !GvCV(gv))) ) {
+                   if ((last_lop_op == OP_SORT ||
+                         (!immediate_paren && (!gv || !GvCV(gv))) ) &&
+                        (last_lop_op != OP_MAPSTART && last_lop_op != OP_GREPSTART)){
                        expect = (last_lop == oldoldbufptr) ? XTERM : XOPERATOR;
                        goto bareword;
                    }
@@ -2417,12 +2421,18 @@ yylex()
            TERM(THING);
        }
 
+       case KEY___DATA__:
        case KEY___END__: {
            GV *gv;
 
            /*SUPPRESS 560*/
-           if (!in_eval) {
-               gv = gv_fetchpv("main::DATA",TRUE, SVt_PVIO);
+           if (!in_eval || tokenbuf[2] == 'D') {
+               char dname[256];
+               char *pname = "main";
+               if (tokenbuf[2] == 'D')
+                   pname = HvNAME(curstash ? curstash : defstash);
+               sprintf(dname,"%s::DATA", pname);
+               gv = gv_fetchpv(dname,TRUE, SVt_PVIO);
                SvMULTI_on(gv);
                if (!GvIO(gv))
                    GvIOp(gv) = newIO();
@@ -3308,6 +3318,7 @@ I32 len;
        if (d[1] == '_') {
            if (strEQ(d,"__LINE__"))            return -KEY___LINE__;
            if (strEQ(d,"__FILE__"))            return -KEY___FILE__;
+           if (strEQ(d,"__DATA__"))            return KEY___DATA__;
            if (strEQ(d,"__END__"))             return KEY___END__;
        }
        break;
@@ -4765,9 +4776,7 @@ start_subparse()
     sv_upgrade((SV *)compcv, SVt_PVCV);
 
     comppad = newAV();
-    SAVEFREESV((SV*)comppad);
     comppad_name = newAV();
-    SAVEFREESV((SV*)comppad_name);
     comppad_name_fill = 0;
     min_intro_pending = 0;
     av_push(comppad, Nullsv);
@@ -4777,8 +4786,8 @@ start_subparse()
 
     comppadlist = newAV();
     AvREAL_off(comppadlist);
-    av_store(comppadlist, 0, SvREFCNT_inc((SV*)comppad_name));
-    av_store(comppadlist, 1, SvREFCNT_inc((SV*)comppad));
+    av_store(comppadlist, 0, (SV*)comppad_name);
+    av_store(comppadlist, 1, (SV*)comppad);
 
     CvPADLIST(compcv) = comppadlist;
     CvOUTSIDE(compcv) = (CV*)SvREFCNT_inc((SV*)outsidecv);