perl 3.0 patch #16 (combined patch)
[p5sagit/p5-mst-13.2.git] / evalargs.xc
index b9d4a26..76ac19a 100644 (file)
@@ -2,9 +2,21 @@
  * kit sizes from getting too big.
  */
 
-/* $Header: evalargs.xc,v 3.0 89/10/18 15:17:16 lwall Locked $
+/* $Header: evalargs.xc,v 3.0.1.4 90/02/28 17:38:37 lwall Locked $
  *
  * $Log:       evalargs.xc,v $
+ * Revision 3.0.1.4  90/02/28  17:38:37  lwall
+ * patch9: $#foo -= 2 didn't work
+ * 
+ * Revision 3.0.1.3  89/11/17  15:25:07  lwall
+ * patch5: constant numeric subscripts disappeared in ?:
+ * 
+ * Revision 3.0.1.2  89/11/11  04:33:05  lwall
+ * patch2: Configure now locates csh
+ * 
+ * Revision 3.0.1.1  89/10/26  23:12:55  lwall
+ * patch1: glob didn't free a temporary string
+ * 
  * Revision 3.0  89/10/18  15:17:16  lwall
  * 3.0 baseline
  * 
            break;
        case A_LARYSTAB:
            ++sp;
+           switch (optype) {
+               case O_ITEM2: argtype = 2; break;
+               case O_ITEM3: argtype = 3; break;
+               default:      argtype = anum; break;
+           }
            str = afetch(stab_array(argptr.arg_stab),
-               arg[anum].arg_len - arybase, TRUE);
+               arg[argtype].arg_len - arybase, TRUE);
 #ifdef DEBUGGING
            if (debug & 8) {
                (void)sprintf(buf,"LARYSTAB $%s[%d]",stab_name(argptr.arg_stab),
-                   arg[anum].arg_len);
+                   arg[argtype].arg_len);
                tmps = buf;
            }
 #endif
            goto do_crement;
        case A_ARYSTAB:
+           switch (optype) {
+               case O_ITEM2: argtype = 2; break;
+               case O_ITEM3: argtype = 3; break;
+               default:      argtype = anum; break;
+           }
            st[++sp] = afetch(stab_array(argptr.arg_stab),
-               arg[anum].arg_len - arybase, FALSE);
+               arg[argtype].arg_len - arybase, FALSE);
            if (!st[sp])
                st[sp] = &str_undef;
 #ifdef DEBUGGING
            if (debug & 8) {
                (void)sprintf(buf,"ARYSTAB $%s[%d]",stab_name(argptr.arg_stab),
-                   arg[anum].arg_len);
+                   arg[argtype].arg_len);
                tmps = buf;
            }
 #endif
            ++sp;
            stab = argptr.arg_stab;
            str = stab_array(argptr.arg_stab)->ary_magic;
-           if (argflags & (AF_PRE|AF_POST))
+           if (optype != O_SASSIGN || argflags & (AF_PRE|AF_POST))
                str_numset(str,(double)(stab_array(stab)->ary_fill+arybase));
 #ifdef DEBUGGING
            tmps = "LARYLEN";
            break;
        case A_WANTARRAY:
            {
-               extern int wantarray;
-
                if (wantarray == G_ARRAY)
                    st[++sp] = &str_yes;
                else
            argflags |= AF_POST;        /* enable newline chopping */
            last_in_stab = argptr.arg_stab;
            old_record_separator = record_separator;
-           if (csh > 0)
-               record_separator = 0;
-           else
-               record_separator = '\n';
+#ifdef CSH
+           record_separator = 0;
+#else
+           record_separator = '\n';
+#endif
            goto do_read;
        case A_READ:
            last_in_stab = argptr.arg_stab;
                            }
                        }
                        fp = nextargv(last_in_stab);
-                       if (!fp)  /* Note: fp != stab_io(last_in_stab)->ifp */
+                       if (!fp) { /* Note: fp != stab_io(last_in_stab)->ifp */
                            (void)do_close(last_in_stab,FALSE); /* now it does*/
+                           stab_io(last_in_stab)->flags |= IOF_START;
+                       }
                    }
                    else if (argtype == A_GLOB) {
                        (void) interp(str,stab_val(last_in_stab),sp);
                        st = stack->ary_array;
                        tmpstr = Str_new(55,0);
-                       if (csh > 0) {
-                           str_set(tmpstr,"/bin/csh -cf 'set nonomatch; glob ");
-                           str_scat(tmpstr,str);
-                           str_cat(tmpstr,"'|");
-                       }
-                       else {
-                           str_set(tmpstr, "echo ");
-                           str_scat(tmpstr,str);
-                           str_cat(tmpstr,
-                             "|tr -s ' \t\f\r' '\\012\\012\\012\\012'|");
-                       }
-                       (void)do_open(last_in_stab,tmpstr->str_ptr);
+#ifdef CSH
+                       str_nset(tmpstr,cshname,cshlen);
+                       str_cat(tmpstr," -cf 'set nonomatch; glob ");
+                       str_scat(tmpstr,str);
+                       str_cat(tmpstr,"'|");
+#else
+                       str_set(tmpstr, "echo ");
+                       str_scat(tmpstr,str);
+                       str_cat(tmpstr,
+                         "|tr -s ' \t\f\r' '\\012\\012\\012\\012'|");
+#endif
+                       (void)do_open(last_in_stab,tmpstr->str_ptr,
+                         tmpstr->str_cur);
                        fp = stab_io(last_in_stab)->ifp;
+                       str_free(tmpstr);
                    }
                }
            }