Skip to content

Commit

Permalink
perl 3.0 patch #13 (combined patch)
Browse files Browse the repository at this point in the history
I added the list slice operator: (LIST)[LIST]

$hexdigit = (0..9,'a','b','c','d','e','f')[$fourbits]

There was no way to cut stuff out of the middle of an array
or to insert stuff without copying the head and tail of the array,
which is gross.  I added the splice operator to do this:

@oldelems = splice(@array,$offset,$len,LIST)

    Equivalencies:
splice(@array,0,1)
splice(@array,0,0,$x,$y)
splice(@array,-1,1)
splice(@array,$#array+1,0,$x,$y)
splice(@array,$x,1,$y)

Having -lPW as one of the libraries that Configure looks for
was causing lots of people grief.  It was only there for
people using bison who otherwise don't have alloca(), so I
zapped it.

Some of the questions that supported the ~name syntax didn't
say so, and some that should have supported it didn't.  Now they do.

If you selected the manp directory for your man pages, the manext
variable was left set to 'n'.

When Configure sees that the optional libraries have previously
been determined in config.sh, it now believes it rather than using
the list it generates.

In the test for byteorder, some compilers get indigestion on the
constant 0x0807060504030201.  It's now split into two parts.

Some compilers don't like it if you put CCFLAGS after the .c file
on the command line.  Some of the Configure tests did this.

On some systems, the test for vprintf() needs to have stdio.h
included in order to give valid results.

Some machines don't support the volatile declaration as applied
to a pointer.  The Configure test now checks for this.
Also, cmd.c had some VOLATILE declarations on pointed-to items
rather than the pointers themselves, causing MIPS heartburn.

In Makefile.SH, some of the t*.c files needed to have dependencies
on perly.h.  Additionally, some parallel makes can't handle a
dependency line with two targets, so the perly.h and perl.c lines
have been separated.  Also, when perly.h is generated, it will
now have a declaration added to it for yylval--bison wasn't supplying
this.

The construct "while (s/x//) {}" was partially fixed in patch 9, but
there were still some weirdnesses about it.  Hopefully these are
ironed out now.

If you did a switch structure based on numeric value, and there
was some action attached to when the variable is greater than
the maximum specified value, that action would not happen.  Instead,
any action for values under the minimum value happened.

The debugger had some difficulties after patch 9, due to changes
in the meaning of @array in a scalar context, and because of
an pointer error in patch 9.

Because of the fix in patch 9 to let return () work right, the
construct "return (@array)" did counter-intuitive things.  It
now returns an array value.  "return @array" and "return (@array)"
now mean the same thing.

A pack of ascii strings could call str_ncat() with negative length
when the length of the string was greater than the length specified
for the field.

Patch 9 fixed *name values so that the wouldn't collide with ordinary
string values, but there were two places I missed, one in perldb,
and one in the sprintf code.

Perl looks at commands it is going to execute to see if it can
bypass /bin/sh and execute them directly.  Ordinarily = is not
a shell metacharacter, but in a command like "system 'FOO=bar command'"i
it indicates that /bin/sh should be used, since it's setting an
environment variable.  It now does that (other than that construct,
the = character is still not a shell metacharacter).

If a runtime pattern to split happens to be null, it was being
interpreted as if it were a space, that is, as the awk-emulating
split.  It now splits all characters apart, since that's more in
line with what people expect, and the other behavior wasn't documented.

Patch 9 added the reserved word "pipe".  The scripts eg/g/gsh and
/eg/scan/scanner used pipe as filehandle since they were written
before the recommendation of upper-case filehandles was devised.
They now use PIPE.

The undef $/ command was supposed to let you slurp in an entire
binary file with one <>, but it didn't work as advertised.

Xenix systems have been having problems with Configure setting
up ndir right.  Hopefully this will work better now, but it's
possible the changes will blow someone else up.  Such is life...

The construct (LIST,) is now legal, so that you can say

@foo = (
1,
2,
3,
);

Various changes were made to the documentation.

In double quoted strings, you could say \0 to mean the null
character.  In pattern matches, only \000 was allowed since
\0 was taken to be a \<digit> backreference.  Since it doesn't
make sense to refer to the whole matched string before it's done,
there's no reason \0 can't mean null in a pattern too.  So now
it does.

You could modify a numeric variable by using substr as an lvalue,
and if you then reference the variable numerically, you'd get
the old number out rather than one derived from the new string.
Now the old number is invalidated on lvalued substr.

The test t/op.mkdir should create directories 0777 rather than 0666.

As Randal requested, the last semicolon of a program is now optional.
Actually, he just asked for -e 'prog' to have that behaviour, but
it seemed reasonable to generalize it slightly.  It's been that
way with eval for some time.
  • Loading branch information
Larry Wall committed Mar 12, 1990
1 parent 9f68db3 commit ff2452d
Show file tree
Hide file tree
Showing 11 changed files with 330 additions and 79 deletions.
53 changes: 27 additions & 26 deletions Configure
Expand Up @@ -8,7 +8,7 @@
# and edit it to reflect your system. Some packages may include samples
# of config.h for certain machines, so you might look for one of those.)
#
# $Header: Configure,v 3.0.1.5 90/02/28 16:17:50 lwall Locked $
# $Header: Configure,v 3.0.1.6 90/03/12 16:10:23 lwall Locked $
#
# Yes, you may rip this off to use in other distribution packages.
# (Note: this Configure script was generated automatically. Rather than
Expand Down Expand Up @@ -257,7 +257,7 @@ attrlist="$attrlist i186 __m88k__ m88k DGUX __DGUX__"
pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /usr/plx /usr/5bin /vol/local/bin /etc /usr/lib /lib /usr/local/lib /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/bin /bsd4.3/usr/ucb"
d_newshome="/usr/NeWS"
defvoidused=7
libswanted="net_s net nsl_s nsl socket nm ndir ndbm dbm sun bsd BSD x c_s PW"
libswanted="net_s net nsl_s nsl socket nm ndir ndbm dbm sun bsd BSD x c_s"
inclwanted='/usr/netinclude /usr/include/sun /usr/include/bsd /usr/include/lan'
: some greps do not return status, grrr.
echo "grimblepritz" >grimble
Expand Down Expand Up @@ -638,11 +638,11 @@ esac
cont=true
while $test "$cont" ; do
echo " "
rp="Where do you want to put the public executables? [$dflt]"
rp="Where do you want to put the public executables? (~name ok) [$dflt]"
$echo $n "$rp $c"
. myread
bin="$ans"
bin=`filexp $bin`
bin=`./filexp "$bin"`
if test -d $bin; then
cont=''
else
Expand Down Expand Up @@ -675,10 +675,10 @@ esac
cont=true
while $test "$cont" ; do
echo " "
rp="Where do the manual pages (source) go? [$dflt]"
rp="Where do the manual pages (source) go? (~name ok) [$dflt]"
$echo $n "$rp $c"
. myread
mansrc=`filexp "$ans"`
mansrc=`./filexp "$ans"`
if $test -d "$mansrc"; then
cont=''
else
Expand Down Expand Up @@ -707,7 +707,7 @@ case "$mansrc" in
manext=l
;;
*p)
manext=n
manext=p
;;
*C)
manext=C
Expand Down Expand Up @@ -1110,10 +1110,6 @@ rmlist="$rmlist pdp11"

echo " "
echo "Checking for optional libraries..."
case "$libs" in
'') dflt='';;
*) dflt="$libs";;
esac
case "$libswanted" in
'') libswanted='c_s';;
esac
Expand Down Expand Up @@ -1156,6 +1152,9 @@ done
set X $dflt
shift
dflt="$*"
case "$libs" in
*) dflt="$libs";;
esac
case "$dflt" in
'') dflt='none';;
esac
Expand Down Expand Up @@ -1206,15 +1205,15 @@ main()
} u;
if (sizeof(long) > 4)
u.l = 0x0807060504030201;
u.l = (0x08070605<<32) | 0x04030201;
else
u.l = 0x04030201;
for (i=0; i < sizeof(long); i++)
printf("%c",u.c[i]+'0');
printf("\n");
}
EOCP
if $cc try.c -o try >/dev/null 2>&1 ; then
if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
dflt=`./try`
case "$dflt" in
????|????????) echo "(The test program ran ok.)";;
Expand Down Expand Up @@ -1513,6 +1512,7 @@ if $contains '^vprintf$' libc.list >/dev/null 2>&1; then
echo 'vprintf() found.'
d_vprintf="$define"
cat >.ucbsprf.c <<'EOF'
#include <stdio.h>
#include <varargs.h>
main() { xxx("foo"); }
Expand Down Expand Up @@ -1948,7 +1948,7 @@ main()
foo = bar;
}
EOCP
if $cc -c try.c >/dev/null 2>&1 ; then
if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
d_strctcpy="$define"
echo "Yup, it can."
else
Expand Down Expand Up @@ -2007,9 +2007,9 @@ for s_timeval in '-DS_TIMEVAL' ''; do
for i_systime in '-DI_SYSTIME' ''; do
case "$flags" in
'') echo Trying $i_time $i_systime $d_systimekernel $s_timeval
if $cc try.c $ccflags \
if $cc $ccflags \
$i_time $i_systime $d_systimekernel $s_timeval \
-o try >/dev/null 2>&1 ; then
try.c -o try >/dev/null 2>&1 ; then
set X $i_time $i_systime $d_systimekernel $s_timeval
shift
flags="$*"
Expand Down Expand Up @@ -2067,11 +2067,12 @@ echo 'Checking to see if your C compiler knows about "volatile"...'
$cat >try.c <<'EOCP'
main()
{
volatile int foo;
char *volatile foo;
volatile int bar;
foo = foo;
}
EOCP
if $cc -c try.c >/dev/null 2>&1 ; then
if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
d_volatile="$define"
echo "Yup, it does."
else
Expand Down Expand Up @@ -2117,7 +2118,7 @@ main() {
exit(0);
}
EOCP
if $cc -S -DTRY=$defvoidused try.c >.out 2>&1 ; then
if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
voidflags=$defvoidused
echo "It appears to support void."
if $contains warning .out >/dev/null 2>&1; then
Expand All @@ -2126,14 +2127,14 @@ EOCP
fi
else
echo "Hmm, your compiler has some difficulty with void. Checking further..."
if $cc -S -DTRY=1 try.c >/dev/null 2>&1 ; then
if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1 ; then
echo "It supports 1..."
if $cc -S -DTRY=3 try.c >/dev/null 2>&1 ; then
if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1 ; then
voidflags=3
echo "And it supports 2 but not 4."
else
echo "It doesn't support 2..."
if $cc -S -DTRY=5 try.c >/dev/null 2>&1 ; then
if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1 ; then
voidflags=5
echo "But it supports 4."
else
Expand Down Expand Up @@ -2286,7 +2287,7 @@ main()
printf("%d\n", sizeof(int));
}
EOCP
if $cc try.c -o try >/dev/null 2>&1 ; then
if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
dflt=`./try`
else
dflt='4'
Expand Down Expand Up @@ -2317,10 +2318,10 @@ $cat <<EOM
The $package package has some auxiliary files that should be put in a library
that is accessible by everyone. Where do you want to put these "private"
EOM
$echo $n "but accessible files? [$dflt] $c"
$echo $n "but accessible files? (~name ok) [$dflt] $c"
rp="Put private files where? [$dflt]"
. myread
privlib="$ans"
privlib=`./filexp "$ans"`

: check for size of random number generator
echo " "
Expand All @@ -2344,7 +2345,7 @@ main()
printf("%d\n",i);
}
EOCP
if $cc try.c -o try >/dev/null 2>&1 ; then
if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
dflt=`./try`
else
dflt='?'
Expand Down
20 changes: 15 additions & 5 deletions Makefile.SH
Expand Up @@ -25,9 +25,14 @@ esac

echo "Extracting Makefile (with variable substitutions)"
cat >Makefile <<!GROK!THIS!
# $Header: Makefile.SH,v 3.0.1.4 90/02/28 16:19:43 lwall Locked $
# $Header: Makefile.SH,v 3.0.1.5 90/03/12 16:15:17 lwall Locked $
#
# $Log: Makefile.SH,v $
# Revision 3.0.1.5 90/03/12 16:15:17 lwall
# patch13: some dependencies missing on perly.h
# patch13: some relief for buggy parallel makes
# patch13: bison doesn't declare extern YYSTYPE yylval;
#
# Revision 3.0.1.4 90/02/28 16:19:43 lwall
# patch9: extraneous $ on suidperl in Makefile
#
Expand Down Expand Up @@ -167,7 +172,7 @@ tcmd.o: cmd.c $(h)
$(CC) -c -DTAINT $(CFLAGS) $(LARGE) tcmd.c
/bin/rm -f tcmd.c
tcons.o: cons.c $(h)
tcons.o: cons.c $(h) perly.h
/bin/rm -f tcons.c
$(SLN) cons.c tcons.c
$(CC) -c -DTAINT $(CFLAGS) $(LARGE) tcons.c
Expand Down Expand Up @@ -239,13 +244,13 @@ tstab.o: stab.c $(h)
$(CC) -c -DTAINT $(CFLAGS) $(LARGE) tstab.c
/bin/rm -f tstab.c
tstr.o: str.c $(h)
tstr.o: str.c $(h) perly.h
/bin/rm -f tstr.c
$(SLN) str.c tstr.c
$(CC) -c -DTAINT $(CFLAGS) $(LARGE) tstr.c
/bin/rm -f tstr.c
ttoke.o: toke.c $(h)
ttoke.o: toke.c $(h) perly.h
/bin/rm -f ttoke.c
$(SLN) toke.c ttoke.c
$(CC) -c -DTAINT $(CFLAGS) $(LARGE) ttoke.c
Expand All @@ -257,11 +262,16 @@ tutil.o: util.c $(h)
$(CC) -c -DTAINT $(CFLAGS) $(LARGE) tutil.c
/bin/rm -f tutil.c
perl.c perly.h: perl.y
perly.h: perl.c
@ echo Dummy dependency for dumb parallel make
touch perly.h
perl.c: perl.y
@ echo Expect 25 shift/reduce errors...
$(YACC) -d perl.y
mv y.tab.c perl.c
mv y.tab.h perly.h
echo 'extern YYSTYPE yylval;' >>perly.h
perl.o: perl.c perly.h $(h)
$(CC) -c $(CFLAGS) $(LARGE) perl.c
Expand Down
1 change: 1 addition & 0 deletions README
Expand Up @@ -80,6 +80,7 @@ Installation
Ultrix (2.3) may need to hand assemble teval.s with a -J switch.
Ultrix on MIPS machines may need -DLANGUAGE_C.
SCO Xenix may need -m25000 for yacc.
Xenix 386 needs -Sm10000 for yacc.
Genix needs to use libc rather than libc_s, or #undef VARARGS.
NCR Tower 32 (OS 2.01.01) may need -W2,-Sl,2000 and #undef MKDIR.
Machines with half-implemented dbm routines will need to #undef ODBM & NDBM.
Expand Down
16 changes: 13 additions & 3 deletions arg.h
@@ -1,11 +1,15 @@
/* $Header: arg.h,v 3.0.1.3 90/02/28 16:21:55 lwall Locked $
/* $Header: arg.h,v 3.0.1.4 90/03/12 16:18:21 lwall Locked $
*
* Copyright (c) 1989, Larry Wall
*
* You may distribute under the terms of the GNU General Public License
* as specified in the README file that comes with the perl 3.0 kit.
*
* $Log: arg.h,v $
* Revision 3.0.1.4 90/03/12 16:18:21 lwall
* patch13: added list slice operator (LIST)[LIST]
* patch13: added splice operator: @oldelems = splice(@array,$offset,$len,LIST)
*
* Revision 3.0.1.3 90/02/28 16:21:55 lwall
* patch9: added pipe function
*
Expand Down Expand Up @@ -261,7 +265,9 @@
#define O_SSOCKOPT 238
#define O_GETSOCKNAME 239
#define O_GETPEERNAME 240
#define MAXO 241
#define O_LSLICE 241
#define O_SPLICE 242
#define MAXO 243

#ifndef DOINIT
extern char *opname[];
Expand Down Expand Up @@ -508,7 +514,9 @@ char *opname[] = {
"SSOCKOPT",
"GETSOCKNAME",
"GETPEERNAME",
"241"
"LSLICE",
"SPLICE",
"243"
};
#endif

Expand Down Expand Up @@ -882,6 +890,8 @@ char opargs[MAXO+1] = {
A(1,1,1), /* SSOCKOPT */
A(1,0,0), /* GETSOCKNAME */
A(1,0,0), /* GETPEERNAME */
A(0,3,3), /* LSLICE */
A(0,3,1), /* SPLICE */
0
};
#undef A
Expand Down
17 changes: 11 additions & 6 deletions cmd.c
@@ -1,11 +1,16 @@
/* $Header: cmd.c,v 3.0.1.5 90/02/28 16:38:31 lwall Locked $
/* $Header: cmd.c,v 3.0.1.6 90/03/12 16:21:09 lwall Locked $
*
* Copyright (c) 1989, Larry Wall
*
* You may distribute under the terms of the GNU General Public License
* as specified in the README file that comes with the perl 3.0 kit.
*
* $Log: cmd.c,v $
* Revision 3.0.1.6 90/03/12 16:21:09 lwall
* patch13: fixed some backwards VOLATILE declarations
* patch13: while (s/x//) {} still caused some anomolies
* patch13: greater-than test of numeric switch structures did less-than action
*
* Revision 3.0.1.5 90/02/28 16:38:31 lwall
* patch9: volatilized some more variables for super-optimizing compilers
* patch9: nested foreach loops didn't reset inner loop on next to outer loop
Expand Down Expand Up @@ -77,8 +82,8 @@ VOLATILE int sp;
register char *go_to = goto_targ;
register int newsp = -2;
register STR **st = stack->ary_array;
VOLATILE FILE *fp;
VOLATILE ARRAY *ar;
FILE *VOLATILE fp;
ARRAY *VOLATILE ar;

lastsize = 0;
#ifdef DEBUGGING
Expand Down Expand Up @@ -461,9 +466,9 @@ VOLATILE int sp;
}
}
if (--cmd->c_short->str_u.str_useful < 0) {
cmdflags &= ~(CF_OPTIMIZE|CF_ONCE);
cmdflags &= ~CF_OPTIMIZE;
cmdflags |= CFT_EVAL; /* never try this optimization again */
cmd->c_flags = cmdflags;
cmd->c_flags = (cmdflags & ~CF_ONCE);
}
break; /* must evaluate */

Expand Down Expand Up @@ -681,7 +686,7 @@ VOLATILE int sp;
if (match < 0)
match = 0;
else if (match > cmd->ucmd.scmd.sc_max)
match = cmd->c_slen;
match = cmd->ucmd.scmd.sc_max;
cmd = cmd->ucmd.scmd.sc_next[match];
goto tail_recursion_entry;
case C_NEXT:
Expand Down
10 changes: 5 additions & 5 deletions cons.c
@@ -1,11 +1,14 @@
/* $Header: cons.c,v 3.0.1.4 90/02/28 16:44:00 lwall Locked $
/* $Header: cons.c,v 3.0.1.5 90/03/12 16:23:10 lwall Locked $
*
* Copyright (c) 1989, Larry Wall
*
* You may distribute under the terms of the GNU General Public License
* as specified in the README file that comes with the perl 3.0 kit.
*
* $Log: cons.c,v $
* Revision 3.0.1.5 90/03/12 16:23:10 lwall
* patch13: perl -d coredumped on scripts with subs that did explicit return
*
* Revision 3.0.1.4 90/02/28 16:44:00 lwall
* patch9: subs which return by both mechanisms can clobber local return data
* patch9: changed internal SUB label to _SUB_
Expand Down Expand Up @@ -74,10 +77,7 @@ CMD *cmd;
mycompblock.comp_alt = Nullcmd;
cmd = add_label(savestr("_SUB_"),make_ccmd(C_BLOCK,Nullarg,mycompblock));
saw_return = FALSE;
if (perldb)
cmd->c_next->c_flags |= CF_TERM;
else
cmd->c_flags |= CF_TERM;
cmd->c_flags |= CF_TERM;
}
sub->cmd = cmd;
stab_sub(stab) = sub;
Expand Down

0 comments on commit ff2452d

Please sign in to comment.