summaryrefslogtreecommitdiff
path: root/cmd.c
diff options
context:
space:
mode:
authorLarry Wall <lwall@jpl-devvax.jpl.nasa.gov>1989-11-17 03:02:33 +0000
committerLarry Wall <lwall@jpl-devvax.jpl.nasa.gov>1989-11-17 03:02:33 +0000
commit0d3e774cdb279a1eadd8282d49334b9b1bfd42ed (patch)
treefb045eec0f917ecabe28bd3c3c3d20dcdd27aae2 /cmd.c
parentae98613044a1084886d80b8283b25bad38cfd171 (diff)
downloadperl-0d3e774cdb279a1eadd8282d49334b9b1bfd42ed.tar.gz
perl 3.0 patch #5 (combined patch)
Some machines have bcopy() but not bzero(), so Configure tests for them separately now. Likewise for symlink() and lstat(). Some systems have dirent.h but not readdir(). The symbols BZERO, LSTAT and READDIR are now used to differentiate. Some machines have <time.h> including <sys/time.h>. Some do the opposite. Some don't even have <sys/time.h>. Configure now looks for both kinds of include, and the saga continues... Configure tested twice for the presence of -lnm because x2p/Makefile.SH had a reference to the obsolete $libnm variable. It now tests only once. Some machines have goodies stashed in /usr/include/sun, /usr/include/bsd, -lsun and -lbsd. Configure now checks those locations. Configure could sometimes add an option to a default of none, producing [none -DDEBUGGING] prompts. This is fixed. Many of the units in metaconfig used the construct if xxx=`loc...`; then On most machines the exit status of loc ends up in $?, but on a few machines, the assignment apparently sets $? to 0, since it always succeeds. Oh well... The tests for byte order had difficulties with illegal octal digits and constants that were too long, as well as not defining the union in try.c correctly. When <dirent.h> was missing, it was assumed that the field d_namlen existed. There is now an explicit check of <sys/dir.h> for the field. The tests of <signal.h> to see how signal() is declared needed to have signal.h run through the C preprocessor first because of POSIX ifdefs. The type returned by getgroups() was defaulting wrong on Suns and such. Configure now checks against the lint library if it exists to produce a better default. The construct foreach $elem (@array) { foreach $elem (@array) { ... } } didn't work right because the iterator for the array was stored with the array rather than with the node in the syntax tree. If you said defined $foo{'bar'} it would create the element $foo{'bar'} while returning the correct value. It now no longer creates the value. The grep() function was occasionally losing arguments or dumping core. This was because it called eval() on each argument but didn't account for the fact that eval() is capable of reallocating the stack. If you said $something ? $foo[1] : $foo[2] you ended up (usually) with $something ? $foo[0] : $foo[0] because of the way the ?: operator tries to fool the stack into thinking there's only one argument there instead of three. This only happened to constant subscripts. Interestingly enough, $abc[1] ? $foo[1] : $bar[1] would have worked, since the first argument has the same subscript. Some machines already define TRUE and FALSE, so we have to undef them to avoid warnings. Several people sent in some fixes for manual typos and indent problems. There was a reqeust to clarify the difference between $! and $@, and I added a gratuitous warning about print making an array context for its arguments, since people seem to run into that frequently. suidperl could correctly emulate a setgid script, but then it could get confused about what the actual effective gid was. Some machine or other defines sighandler(), so perl's sighandler() needed to be made static. We changed uchar to unchar for Crays, and it turns out that lots of SysV machines typedef unchar instead. Sigh. It's now un_char. If you did substitutions to chop leading components off a string, and then set the string from <filehandle>, under certain circumstances the input string could be corrupted because str_gets() called str_grow() without making sure to change the strings current length to be the number of characters just read, rather than the old length. op.stat occasionally failed with NFS race condition, so it now waits two seconds instead of one to guarantee that the NFS server advances its clock at least one second. IBM PC/RT compiler can't deal with UNI() and LOP() macros. If you define CRIPPLED_CC it now will recast those macros as subroutines, which runs a little slower but doesn't give the compiler heartburn. The } character can terminate either an associative array subscript or a BLOCK. These set up different expectations as to whether the next token might be a term or an operator. There was a faulty heuristic based on whether there was an intervening newline. It turns out that if } simply leaves the current expectations along, the right thing happens. The command y/abcde// didn't work because the length of the first part was not correctly copied to the second part. In s2p, line labels without a subsequent statement were done wrong, since an extra semicolon needs to be supplied. It wasn't always suppplied, and when it was supplied, it was in the wrong place. S2p also needed to remove its /tmp files better. A2p translates for (a in b) to foreach $a} (keys(%b)) on Pyramids, because index(s, '}' + 128) doesn't find a } with the top bit set. This has been fixed.
Diffstat (limited to 'cmd.c')
-rw-r--r--cmd.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/cmd.c b/cmd.c
index 7fc742707d..c623d544ae 100644
--- a/cmd.c
+++ b/cmd.c
@@ -1,4 +1,4 @@
-/* $Header: cmd.c,v 3.0.1.2 89/11/11 04:08:56 lwall Locked $
+/* $Header: cmd.c,v 3.0.1.3 89/11/17 15:04:36 lwall Locked $
*
* Copyright (c) 1989, Larry Wall
*
@@ -6,6 +6,9 @@
* as specified in the README file that comes with the perl 3.0 kit.
*
* $Log: cmd.c,v $
+ * Revision 3.0.1.3 89/11/17 15:04:36 lwall
+ * patch5: nested foreach on same array didn't work
+ *
* Revision 3.0.1.2 89/11/11 04:08:56 lwall
* patch2: non-BSD machines required two ^D's for <>
* patch2: grow_dlevel() not inside #ifdef DEBUGGING
@@ -528,24 +531,26 @@ until_loop:
retstr = &str_chop;
goto flipmaybe;
case CFT_ARRAY:
- ar = stab_array(cmd->c_expr[1].arg_ptr.arg_stab);
- match = ar->ary_index; /* just to get register */
+ match = cmd->c_short->str_u.str_useful; /* just to get register */
if (match < 0) { /* first time through here? */
+ ar = stab_array(cmd->c_expr[1].arg_ptr.arg_stab);
aryoptsave = savestack->ary_fill;
savesptr(&stab_val(cmd->c_stab));
- saveint(&ar->ary_index);
+ savelong(&cmd->c_short->str_u.str_useful);
}
+ else
+ ar = stab_xarray(cmd->c_expr[1].arg_ptr.arg_stab);
if (match >= ar->ary_fill) { /* we're in LAST, probably */
retstr = &str_undef;
- ar->ary_index = -1; /* this is actually redundant */
+ cmd->c_short->str_u.str_useful = -1; /* actually redundant */
match = FALSE;
}
else {
match++;
retstr = stab_val(cmd->c_stab) = ar->ary_array[match];
- ar->ary_index = match;
+ cmd->c_short->str_u.str_useful = match;
match = TRUE;
}
newsp = -2;