From: Larry Wall Date: Thu, 26 Oct 1989 10:31:40 +0000 (+0000) Subject: perl 3.0 patch #1 (combined patch) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=03a14243eca2d4d041778dac4abcfa3a19c06a56;p=p5sagit%2Fp5-mst-13.2.git perl 3.0 patch #1 (combined patch) Configure had difficulties if the user's path had weird components. Now Configure appends the user's path to its own. Some machines need included in order to define certain macros for packing or unpacking network order data. On Suns, the shared library is used by default. If it doesn't contain something contained in /lib/libc.a, then Configure was getting things wrong (such as gethostent()). Now Configure uses the shared library if it's there in preference to libc.a. When gcc was selected as the compiler, the cc flags defaulted to -fpcc_struct_return. Unfortunately, the underlines should be hyphens. Configure figures out if BSD shadow passwords are installed and the getpw* routines now return slightly different data in the affected fields. Some of the prompts in Configure with regard to gid and uid types were unclear as to their intended use. They are now a little clearer. Sometimes you could change a .h file and taintperl and suidperl didn't get remade correctly because of missing dependencies in the Makefile. The README file was misleading about the fact that you have to say "make test" before you can "cd t; TEST" The reverse operator was busted in two different ways. Should work better now. There are now regression tests for it. Some of the optimizations that perl does are disabled after period of time if perl decides they aren't doing any good. One of these caused a string to be freed that was later referenced via another pointer, causing core dumps. The free turned out to be unnecessary, so it was removed. The unless modifier was broken when run under the debugger, due to the invert() routine in perl.y inverting the logic on the DB subroutine call instead of the command the unless was modifying. Configure vfork test was backwards. It now works like other defines. The numeric switch optimization was broken, and caused code to be bypassed. This has been fixed. A split in a subroutine that has no target splits into @_. Unfortunately, this wrongly freed any referenced arguments passed in through @_, causing confusing behavior later in the program. File globbing () left one orphaned string each time it called the shell to do the glob. RCS expanded an unintended $Header in lib/perldb.pl. This has been fixed simply by replacing the $ with a . Some forward declarations of static functions were missing from malloc.c. There's a strut in malloc for mips machines to extend the overhead union to the size of a double. This was also enabled for sparc machines. DEC risc machines are reported to have a buggy memcmp. I've put some conditional code into perl.h which I think will undef MEMCMP appropriately. In perl.man.4, I documented the desirability of using parens even where they aren't strictly necessary. I've grandfathered "format stdout" to be the same as "format STDOUT". Unary operators can be called with no argument. The corresponding function call form using empty parens () didn't work right, though it did for certain functions in 2.0. It now works in 3.0. The string ordering tests were wrong for pairs of strings in which one string was a prefix of the other. This affected lt, le, gt, ge, and the sort operator when used with no subroutine. $/ didn't work with the stupid code used when STDSTDIO was undefined. The stupid code has been replaced with smarter code that can do it right. Special thanks to Piet van Oostrum for the code. Goulds work better if the union in STR is at an 8 byte boundary. The fields were rearranged somewhat to provide this. "sort keys %a" should now work right (though parens are still desirable for readability). bcopy() needed a forward declaration on some machines. In x2p/Makefile.SH, added dependency on ../config.sh so that it gets linked down from above if it got removed for some reason. --- diff --git a/Configure b/Configure index c3c65ea..a3aeb9b 100755 --- a/Configure +++ b/Configure @@ -8,14 +8,14 @@ # 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 89/10/18 15:04:55 lwall Locked $ +# $Header: Configure,v 3.0.1.1 89/10/26 22:58:02 lwall Locked $ # # Yes, you may rip this off to use in other distribution packages. # (Note: this Configure script was generated automatically. Rather than # working with this copy of Configure, you may wish to get metaconfig.) : sanity checks -PATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc:/usr/new:/usr/new/bin:/usr/nbin' +PATH=".:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc:/usr/new:/usr/new/bin:/usr/nbin:$PATH" export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$) if test ! -t 0; then @@ -157,6 +157,7 @@ i_dirent='' d_dirnamlen='' i_fcntl='' i_grp='' +i_niin='' i_pwd='' d_pwquota='' d_pwage='' @@ -424,7 +425,6 @@ Mcc cpp egrep test -uname " for file in $loclist; do xxx=`loc $file $file $pth` @@ -513,21 +513,17 @@ esac rmlist="$rmlist loc" : get list of predefined functions in a handy place -if $test -n "$uname"; then - os=`$uname -s` -else - os=unknown -fi echo " " -if test -f /lib/libc.a; then +set /usr/lib/libc.so.[0-9]* +eval set \$$# +if test -f "$1"; then + echo "Your shared C library is in $1." + libc="$1" +elif test -f /lib/libc.a; then echo "Your C library is in /lib/libc.a. You're normal." libc=/lib/libc.a else - if test "$os" = DomainOS ; then - ans=`loc libc blurfl/dyick $libpth` - else - ans=`loc libc.a blurfl/dyick $libpth` - fi + ans=`loc libc.a blurfl/dyick $libpth` if test ! -f "$ans"; then ans=`loc clib blurfl/dyick $libpth` fi @@ -573,11 +569,9 @@ $sed -n -e 's/^.* [AT] *_[_.]*//p' -e 's/^.* [AT] //p' libc.list if $contains '^printf$' libc.list >/dev/null 2>&1; then echo "done" else - if test "$os" = DomainOS ; then - $sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p' libc.list - else + $sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p' libc.list + $contains '^printf$' libc.list >/dev/null 2>&1 || \ $sed -n -e 's/^.* D __*//p' -e 's/^.* D //p' libc.list - fi $contains '^printf$' libc.list >/dev/null 2>&1 || \ $sed -n -e 's/^_//' \ -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p' libc.list @@ -1102,7 +1096,7 @@ esac case "$ccflags" in '') case "$cc" in - gcc) dflt='-fpcc_struct_return';; + gcc) dflt='-fpcc-struct-return';; *) dflt='none';; esac ;; @@ -1553,7 +1547,7 @@ else echo "dbm.h not found." fi -: see if this is an pwd system +: see if this is a pwd system echo " " if $test -r /usr/include/pwd.h ; then i_pwd="$define" @@ -1568,10 +1562,28 @@ if $test -r /usr/include/pwd.h ; then else d_pwage="$undef" fi + if $contains 'pw_change' /usr/include/pwd.h >/dev/null 2>&1; then + d_pwchange="$define" + else + d_pwchange="$undef" + fi + if $contains 'pw_class' /usr/include/pwd.h >/dev/null 2>&1; then + d_pwclass="$define" + else + d_pwclass="$undef" + fi + if $contains 'pw_expire' /usr/include/pwd.h >/dev/null 2>&1; then + d_pwexpire="$define" + else + d_pwexpire="$undef" + fi else i_pwd="$undef" d_pwquota="$undef" d_pwage="$undef" + d_pwchange="$undef" + d_pwclass="$undef" + d_pwexpire="$undef" echo "No pwd.h found." fi @@ -1868,7 +1880,7 @@ case "$gidtype" in esac cont=true echo " " -rp="What type are group ids on this system declared as? [$dflt]" +rp="What type are the group ids are returned by getgroups()? [$dflt]" $echo $n "$rp $c" . myread gidtype="$ans" @@ -1893,6 +1905,16 @@ else echo "No grp.h found." fi +: see if this is a netinet/in.h system +echo " " +if $test -r /usr/include/netinet/in.h ; then + i_niin="$define" + echo "netinet/in.h found." +else + i_niin="$undef" + echo "No netinet/in.h found." +fi + : see if this is a sys/dir.h system echo " " if $test -r /usr/include/sys/dir.h ; then @@ -2070,7 +2092,7 @@ case "$uidtype" in esac cont=true echo " " -rp="What type are user ids on this system declared as? [$dflt]" +rp="What type are user ids returned by getuid(), etc.? [$dflt]" $echo $n "$rp $c" . myread uidtype="$ans" @@ -2307,6 +2329,7 @@ i_dirent='$i_dirent' d_dirnamlen='$d_dirnamlen' i_fcntl='$i_fcntl' i_grp='$i_grp' +i_niin='$i_niin' i_pwd='$i_pwd' d_pwquota='$d_pwquota' d_pwage='$d_pwage' diff --git a/Makefile.SH b/Makefile.SH index 6e66a4c..6cb270f 100644 --- a/Makefile.SH +++ b/Makefile.SH @@ -25,9 +25,12 @@ esac echo "Extracting Makefile (with variable substitutions)" cat >Makefile <c_short->str_u.str_useful < 0) { - str_free(cmd->c_short); - cmd->c_short = Nullstr; cmdflags &= ~CF_OPTIMIZE; cmdflags |= CFT_EVAL; /* never try this optimization again */ cmd->c_flags = cmdflags; diff --git a/cmd.h b/cmd.h index 5e880a4..3a1d832 100644 --- a/cmd.h +++ b/cmd.h @@ -1,4 +1,4 @@ -/* $Header: cmd.h,v 3.0 89/10/18 15:09:15 lwall Locked $ +/* $Header: cmd.h,v 3.0.1.1 89/10/26 23:05:43 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.h,v $ + * Revision 3.0.1.1 89/10/26 23:05:43 lwall + * patch1: unless was broken when run under the debugger + * * Revision 3.0 89/10/18 15:09:15 lwall * 3.0 baseline * @@ -53,6 +56,7 @@ char *cmdname[] = { #define CF_ONCE 010000 /* we've already pushed the label on the stack */ #define CF_FLIP 020000 /* on a match do flipflop */ #define CF_TERM 040000 /* value of this cmd might be returned */ +#define CF_DBSUB 0100000 /* this is an inserted cmd for debugging */ #define CFT_FALSE 0 /* c_expr is always false */ #define CFT_TRUE 1 /* c_expr is always true */ diff --git a/config.h.SH b/config.h.SH index 5cf8ad1..7d069a2 100644 --- a/config.h.SH +++ b/config.h.SH @@ -385,11 +385,10 @@ sed <config.h -e 's!^#undef!/\*#undef!' */ #$d_varargs VARARGS /**/ -/* vfork: - * This symbol, if defined, remaps the vfork routine to fork if the - * vfork() routine isn't supported here. +/* VFORK: + * This symbol, if defined, indicates that vfork() exists. */ -#$d_vfork vfork fork /**/ +#$d_vfork VFORK /**/ /* VOIDSIG: * This symbol is defined if this system declares "void (*signal())()" in @@ -443,6 +442,12 @@ sed <config.h -e 's!^#undef!/\*#undef!' */ #$i_grp I_GRP /**/ +/* I_NETINET_IN: + * This symbol, if defined, indicates to the C program that it should + * include netinet/in.h. + */ +#$i_niin I_NETINET_IN /**/ + /* I_PWD: * This symbol, if defined, indicates to the C program that it should * include pwd.h. @@ -455,9 +460,24 @@ sed <config.h -e 's!^#undef!/\*#undef!' * This symbol, if defined, indicates to the C program that struct passwd * contains pw_age. */ +/* PWCHANGE: + * This symbol, if defined, indicates to the C program that struct passwd + * contains pw_change. + */ +/* PWCLASS: + * This symbol, if defined, indicates to the C program that struct passwd + * contains pw_class. + */ +/* PWEXPIRE: + * This symbol, if defined, indicates to the C program that struct passwd + * contains pw_expire. + */ #$i_pwd I_PWD /**/ #$d_pwquota PWQUOTA /**/ #$d_pwage PWAGE /**/ +#$d_pwage PWCHANGE /**/ +#$d_pwage PWCLASS /**/ +#$d_pwage PWEXPIRE /**/ /* I_SYSDIR: * This symbol, if defined, indicates to the C program that it should diff --git a/cons.c b/cons.c index 8e0c146..e85bc81 100644 --- a/cons.c +++ b/cons.c @@ -1,4 +1,4 @@ -/* $Header: cons.c,v 3.0 89/10/18 15:10:23 lwall Locked $ +/* $Header: cons.c,v 3.0.1.1 89/10/26 23:09:01 lwall Locked $ * * Copyright (c) 1989, Larry Wall * @@ -6,6 +6,10 @@ * as specified in the README file that comes with the perl 3.0 kit. * * $Log: cons.c,v $ + * Revision 3.0.1.1 89/10/26 23:09:01 lwall + * patch1: numeric switch optimization was broken + * patch1: unless was broken when run under the debugger + * * Revision 3.0 89/10/18 15:10:23 lwall * 3.0 baseline * @@ -285,11 +289,11 @@ int count; Newz(105,loc, max - min + 3, CMD*); loc++; + max -= min; + max++; while (count--) { i = (int)str_gnum(cur->c_short); i -= min; - max -= min; - max++; switch(cur->c_slen) { case O_LE: i++; @@ -314,6 +318,7 @@ int count; } loc--; min--; + max++; for (i = 0; i <= max; i++) if (!loc[i]) loc[i] = cur; @@ -378,7 +383,7 @@ CMD *cur; stab2arg(A_WORD,DBstab), make_list(arg), Nullarg); - cmd->c_flags |= CF_COND; + cmd->c_flags |= CF_COND|CF_DBSUB; cmd->c_line = head->c_line; cmd->c_label = head->c_label; cmd->c_file = filename; @@ -797,12 +802,14 @@ register ARG *arg; CMD * invert(cmd) -register CMD *cmd; +CMD *cmd; { - if (cmd->c_head) - cmd->c_head->c_flags ^= CF_INVERT; - else - cmd->c_flags ^= CF_INVERT; + register CMD *targ = cmd; + if (targ->c_head) + targ = targ->c_head; + if (targ->c_flags & CF_DBSUB) + targ = targ->c_next; + targ->c_flags ^= CF_INVERT; return cmd; } diff --git a/doio.c b/doio.c index c0ba205..a50d18f 100644 --- a/doio.c +++ b/doio.c @@ -1,4 +1,4 @@ -/* $Header: doio.c,v 3.0 89/10/18 15:10:54 lwall Locked $ +/* $Header: doio.c,v 3.0.1.1 89/10/26 23:10:05 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: doio.c,v $ + * Revision 3.0.1.1 89/10/26 23:10:05 lwall + * patch1: Configure now checks for BSD shadow passwords + * * Revision 3.0 89/10/18 15:10:54 lwall * 3.0 baseline * @@ -1580,6 +1583,9 @@ int *arglast; (void)astore(ary, ++sp, str = str_static(&str_no)); str_numset(str, (double)pwent->pw_gid); (void)astore(ary, ++sp, str = str_static(&str_no)); +#ifdef PWCHANGE + str_numset(str, (double)pwent->pw_change); +#else #ifdef PWQUOTA str_numset(str, (double)pwent->pw_quota); #else @@ -1587,14 +1593,23 @@ int *arglast; str_set(str, pwent->pw_age); #endif #endif +#endif (void)astore(ary, ++sp, str = str_static(&str_no)); +#ifdef PWCLASS + str_set(str,pwent->pw_class); +#else str_set(str, pwent->pw_comment); +#endif (void)astore(ary, ++sp, str = str_static(&str_no)); str_set(str, pwent->pw_gecos); (void)astore(ary, ++sp, str = str_static(&str_no)); str_set(str, pwent->pw_dir); (void)astore(ary, ++sp, str = str_static(&str_no)); str_set(str, pwent->pw_shell); +#ifdef PWEXPIRE + (void)astore(ary, ++sp, str = str_static(&str_no)); + str_numset(str, (double)pwent->pw_expire); +#endif } return sp; diff --git a/dolist.c b/dolist.c index e47c37d..0c3b6a6 100644 --- a/dolist.c +++ b/dolist.c @@ -1,4 +1,4 @@ -/* $Header: dolist.c,v 3.0 89/10/18 15:11:02 lwall Locked $ +/* $Header: dolist.c,v 3.0.1.1 89/10/26 23:11:51 lwall Locked $ * * Copyright (c) 1989, Larry Wall * @@ -6,6 +6,10 @@ * as specified in the README file that comes with the perl 3.0 kit. * * $Log: dolist.c,v $ + * Revision 3.0.1.1 89/10/26 23:11:51 lwall + * patch1: split in a subroutine wrongly freed referenced arguments + * patch1: reverse didn't work + * * Revision 3.0 89/10/18 15:11:02 lwall * 3.0 baseline * @@ -285,8 +289,12 @@ int *arglast; #endif ary = stab_xarray(spat->spat_repl[1].arg_ptr.arg_stab); if (ary && ((ary->ary_flags & ARF_REAL) || gimme != G_ARRAY)) { - ary->ary_flags |= ARF_REAL; realarray = 1; + if (!(ary->ary_flags & ARF_REAL)) { + ary->ary_flags |= ARF_REAL; + for (i = ary->ary_fill; i >= 0; i--) + ary->ary_array[i] = Nullstr; /* don't free mere refs */ + } ary->ary_fill = -1; sp = -1; /* temporarily switch stacks */ } @@ -754,8 +762,11 @@ int *arglast; } while (i-- > 0) { *up++ = *down; - *down-- = *up; + if (i-- > 0) + *down-- = *up; } + i = arglast[2] - arglast[1]; + Copy(down+1,up,i/2,STR*); return arglast[2] - 1; } diff --git a/evalargs.xc b/evalargs.xc index b9d4a26..d2b7c64 100644 --- a/evalargs.xc +++ b/evalargs.xc @@ -2,9 +2,12 @@ * 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.1 89/10/26 23:12:55 lwall Locked $ * * $Log: evalargs.xc,v $ + * 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 * @@ -275,6 +278,7 @@ } (void)do_open(last_in_stab,tmpstr->str_ptr); fp = stab_io(last_in_stab)->ifp; + str_free(tmpstr); } } } diff --git a/lib/perldb.pl b/lib/perldb.pl index 51f6c24..7b3e0aa 100644 --- a/lib/perldb.pl +++ b/lib/perldb.pl @@ -1,6 +1,6 @@ package DB; -$header = '$Header: perldb.pl,v 3.0 89/10/18 15:19:46 lwall Locked $'; +$header = '$Header: perldb.pl,v 3.0.1.1 89/10/26 23:14:02 lwall Locked $'; # # This file is automatically included if you do perl -d. # It's probably not useful to include this yourself. @@ -10,6 +10,9 @@ $header = '$Header: perldb.pl,v 3.0 89/10/18 15:19:46 lwall Locked $'; # have a breakpoint. It also inserts a do 'perldb.pl' before the first line. # # $Log: perldb.pl,v $ +# Revision 3.0.1.1 89/10/26 23:14:02 lwall +# patch1: RCS expanded an unintended $Header in lib/perldb.pl +# # Revision 3.0 89/10/18 15:19:46 lwall # 3.0 baseline # @@ -25,7 +28,7 @@ $| = 1; # for DB'OUT select(STDOUT); $| = 1; # for real STDOUT -$header =~ s/\$Header: perldb.pl,v 3.0 89/10/18 15:19:46 lwall Locked $/$1$2/; +$header =~ s/.Header: ([^,]+),v(\s+\S+\s+\S+).*$/$1$2/; print OUT "\nLoading DB from $header\n\n"; sub DB { diff --git a/malloc.c b/malloc.c index 62ff232..4318a2c 100644 --- a/malloc.c +++ b/malloc.c @@ -1,6 +1,10 @@ -/* $Header: malloc.c,v 3.0 89/10/18 15:20:39 lwall Locked $ +/* $Header: malloc.c,v 3.0.1.1 89/10/26 23:15:05 lwall Locked $ * * $Log: malloc.c,v $ + * Revision 3.0.1.1 89/10/26 23:15:05 lwall + * patch1: some declarations were missing from malloc.c + * patch1: sparc machines had alignment problems in malloc.c + * * Revision 3.0 89/10/18 15:20:39 lwall * 3.0 baseline * @@ -27,6 +31,8 @@ static char sccsid[] = "@(#)malloc.c 4.3 (Berkeley) 9/16/83"; #include "EXTERN.h" #include "perl.h" +static findbucket(), morecore(); + /* I don't much care whether these are defined in sys/types.h--LAW */ #define u_char unsigned char @@ -44,7 +50,7 @@ static char sccsid[] = "@(#)malloc.c 4.3 (Berkeley) 9/16/83"; */ union overhead { union overhead *ov_next; /* when free */ -#ifdef mips +#if defined (mips) || defined (sparc) double strut; /* alignment problems */ #endif struct { diff --git a/patchlevel.h b/patchlevel.h index 935ec35..110c86f 100644 --- a/patchlevel.h +++ b/patchlevel.h @@ -1 +1 @@ -#define PATCHLEVEL 0 +#define PATCHLEVEL 1 diff --git a/perl.h b/perl.h index 3ea3d82..4808d56 100644 --- a/perl.h +++ b/perl.h @@ -1,4 +1,4 @@ -/* $Header: perl.h,v 3.0 89/10/18 15:21:21 lwall Locked $ +/* $Header: perl.h,v 3.0.1.1 89/10/26 23:17:08 lwall Locked $ * * Copyright (c) 1989, Larry Wall * @@ -6,6 +6,11 @@ * as specified in the README file that comes with the perl 3.0 kit. * * $Log: perl.h,v $ + * Revision 3.0.1.1 89/10/26 23:17:08 lwall + * patch1: vfork now conditionally defined based on VFORK + * patch1: DEC risc machines have a buggy memcmp + * patch1: perl.h now includes if it exists + * * Revision 3.0 89/10/18 15:21:21 lwall * 3.0 baseline * @@ -24,6 +29,14 @@ # endif #endif +#ifndef VFORK +# define vfork fork +#endif + +#if defined(MEMCMP) && defined(mips) && BYTEORDER == 01234 +#undef MEMCMP +#endif + #ifdef MEMCPY extern char *memcpy(), *memset(); #define bcopy(s1,s2,l) memcpy(s2,s1,l) @@ -38,6 +51,10 @@ extern char *memcpy(), *memset(); #include #include /* if this needs types.h we're still wrong */ +#ifdef I_NETINET_IN +#include +#endif + #ifndef _TYPES_ /* If types.h defines this it's easy. */ #ifndef major /* Does everyone's types.h define this? */ #include diff --git a/perl.man.4 b/perl.man.4 index 953ca8b..af423de 100644 --- a/perl.man.4 +++ b/perl.man.4 @@ -1,7 +1,10 @@ ''' Beginning of part 4 -''' $Header: perl.man.4,v 3.0 89/10/18 15:21:55 lwall Locked $ +''' $Header: perl.man.4,v 3.0.1.1 89/10/26 23:18:43 lwall Locked $ ''' ''' $Log: perl.man.4,v $ +''' Revision 3.0.1.1 89/10/26 23:18:43 lwall +''' patch1: documented the desirability of unnecessary parentheses +''' ''' Revision 3.0 89/10/18 15:21:55 lwall ''' 3.0 baseline ''' @@ -992,6 +995,18 @@ doesn't mean that you have to make use of the defaults. The defaults are there for lazy systems programmers writing one-shot programs. If you want your program to be readable, consider supplying the argument. +.Sp +Along the same lines, just because you +.I can +omit parentheses in many places doesn't mean that you ought to: +.nf + + return print reverse sort num values array; + return print(reverse(sort num (values(%array)))); + +.fi +When in doubt, parenthesize. +At the very least it will let some poor schmuck bounce on the % key in vi. .Ip 2. 4 4 Don't go through silly contortions to exit a loop at the top or the bottom, when @@ -1017,6 +1032,8 @@ See last example. .Ip 6. 4 4 For portability, when using features that may not be implemented on every machine, test the construct in an eval to see if it fails. +If you know what version or patchlevel a particular feature was implemented, +you can test $] to see if it will be there. .Ip 4. 4 4 Choose mnemonic indentifiers. .Ip 5. 4 4 diff --git a/perl.y b/perl.y index 827448e..05e5a68 100644 --- a/perl.y +++ b/perl.y @@ -1,4 +1,4 @@ -/* $Header: perl.y,v 3.0 89/10/18 15:22:04 lwall Locked $ +/* $Header: perl.y,v 3.0.1.1 89/10/26 23:20:41 lwall Locked $ * * Copyright (c) 1989, Larry Wall * @@ -6,6 +6,10 @@ * as specified in the README file that comes with the perl 3.0 kit. * * $Log: perl.y,v $ + * Revision 3.0.1.1 89/10/26 23:20:41 lwall + * patch1: grandfathered "format stdout" + * patch1: operator(); is now normally equivalent to operator; + * * Revision 3.0 89/10/18 15:22:04 lwall * 3.0 baseline * @@ -276,7 +280,13 @@ decl : format ; format : FORMAT WORD '=' FORMLIST - { stab_form(stabent($2,TRUE)) = $4; Safefree($2);} + { if (strEQ($2,"stdout")) + stab_form(stabent("STDOUT",TRUE)) = $4; + else if (strEQ($2,"stderr")) + stab_form(stabent("STDERR",TRUE)) = $4; + else + stab_form(stabent($2,TRUE)) = $4; + Safefree($2);} | FORMAT '=' FORMLIST { stab_form(stabent("STDOUT",TRUE)) = $3; } ; @@ -632,6 +642,10 @@ term : '-' term %prec UMINUS Nullarg, Nullarg)); } | FUNC0 { $$ = make_op($1, 0, Nullarg, Nullarg, Nullarg); } + | FUNC1 '(' ')' + { $$ = make_op($1, 1, Nullarg, Nullarg, Nullarg); + if ($1 == O_EVAL || $1 == O_RESET) + $$ = fixeval($$); } | FUNC1 '(' expr ')' { $$ = make_op($1, 1, $3, Nullarg, Nullarg); if ($1 == O_EVAL || $1 == O_RESET) diff --git a/str.c b/str.c index 9df2913..0d19b59 100644 --- a/str.c +++ b/str.c @@ -1,4 +1,4 @@ -/* $Header: str.c,v 3.0 89/10/18 15:23:38 lwall Locked $ +/* $Header: str.c,v 3.0.1.1 89/10/26 23:23:41 lwall Locked $ * * Copyright (c) 1989, Larry Wall * @@ -6,6 +6,10 @@ * as specified in the README file that comes with the perl 3.0 kit. * * $Log: str.c,v $ + * Revision 3.0.1.1 89/10/26 23:23:41 lwall + * patch1: string ordering tests were wrong + * patch1: $/ now works even when STDSTDIO undefined + * * Revision 3.0 89/10/18 15:23:38 lwall * 3.0 baseline * @@ -604,14 +608,14 @@ register STR *str2; if (retval = memcmp(str1->str_ptr, str2->str_ptr, str1->str_cur)) return retval; else - return 1; + return -1; } else if (retval = memcmp(str1->str_ptr, str2->str_ptr, str2->str_cur)) return retval; else if (str1->str_cur == str2->str_cur) return 0; else - return -1; + return 1; } char * @@ -620,8 +624,6 @@ register STR *str; register FILE *fp; int append; { -#ifdef STDSTDIO /* Here is some breathtakingly efficient cheating */ - register char *bp; /* we're going to steal some values */ register int cnt; /* from the stdio struct and put EVERYTHING */ register STDCHAR *ptr; /* in the innermost loop into registers */ @@ -636,6 +638,8 @@ int append; newline = '\n'; oldbp = Nullch; /* remember last \n position (none) */ } +#ifdef STDSTDIO /* Here is some breathtakingly efficient cheating */ + cnt = fp->_cnt; /* get count into register */ str->str_nok = 0; /* invalidate number */ str->str_pok = 1; /* validate pointer */ @@ -686,16 +690,28 @@ thats_really_all_folks: #else /* !STDSTDIO */ /* The big, slow, and stupid way */ - static char buf[8192]; + { + static char buf[8192]; + char * bpe = buf + sizeof(buf) - 3; + +screamer: + bp = buf; +filler: + while ((i = getc(fp)) != EOF && (*bp++ = i) != newline && bp < bpe); + if (i == newline && get_paragraph && + (i = getc(fp)) != EOF && (*bp++ = i) != newline && bp < bpe) + goto filler; - if (fgets(buf, sizeof buf, fp) != Nullch) { + *bp = '\0'; if (append) str_cat(str, buf); else str_set(str, buf); + if (i != newline && i != EOF) { + append = -1; + goto screamer; + } } - else - str_set(str, No); #endif /* STDSTDIO */ diff --git a/str.h b/str.h index f4ea90f..2c14029 100644 --- a/str.h +++ b/str.h @@ -1,4 +1,4 @@ -/* $Header: str.h,v 3.0 89/10/18 15:23:49 lwall Locked $ +/* $Header: str.h,v 3.0.1.1 89/10/26 23:24:42 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: str.h,v $ + * Revision 3.0.1.1 89/10/26 23:24:42 lwall + * patch1: rearranged some structures to align doubles better on Gould + * * Revision 3.0 89/10/18 15:23:49 lwall * 3.0 baseline * @@ -13,6 +16,7 @@ struct string { char * str_ptr; /* pointer to malloced string */ + int str_len; /* allocated size */ union { double str_nval; /* numeric value, if any */ STAB *str_stab; /* magic stab for magic "key" string */ @@ -21,7 +25,6 @@ struct string { HASH *str_hash; /* string represents an assoc array (stab?) */ ARRAY *str_array; /* string represents an array */ } str_u; - int str_len; /* allocated size */ int str_cur; /* length of str_ptr as a C string */ STR *str_magic; /* while free, link to next free str */ /* while in use, ptr to "key" for magic items */ @@ -37,6 +40,7 @@ struct string { struct stab { /* should be identical, except for str_ptr */ STBP * str_ptr; /* pointer to malloced string */ + int str_len; /* allocated size */ union { double str_nval; /* numeric value, if any */ STAB *str_stab; /* magic stab for magic "key" string */ @@ -45,7 +49,6 @@ struct stab { /* should be identical, except for str_ptr */ HASH *str_hash; /* string represents an assoc array (stab?) */ ARRAY *str_array; /* string represents an array */ } str_u; - int str_len; /* allocated size */ int str_cur; /* length of str_ptr as a C string */ STR *str_magic; /* while free, link to next free str */ /* while in use, ptr to "key" for magic items */ diff --git a/t/op.sort b/t/op.sort index 89dafae..4243215 100644 --- a/t/op.sort +++ b/t/op.sort @@ -1,8 +1,8 @@ #!./perl -# $Header: op.sort,v 3.0 89/10/18 15:31:19 lwall Locked $ +# $Header: op.sort,v 3.0.1.1 89/10/26 23:25:37 lwall Locked $ -print "1..3\n"; +print "1..8\n"; sub reverse { $a lt $b ? 1 : $a gt $b ? -1 : 0; } @@ -17,3 +17,23 @@ print ($x eq 'xdogcatCainAbel' ? "ok 2\n" : "not ok 2\n"); $x = join('', sort @george, 'to', @harry); print ($x eq 'AbelAxedCainPunishedcatchaseddoggonetoxyz'?"ok 3\n":"not ok 3\n"); + +@a = (); +@b = reverse @a; +print ("@b" eq "" ? "ok 4\n" : "not ok 4 (@b)\n"); + +@a = (1); +@b = reverse @a; +print ("@b" eq "1" ? "ok 5\n" : "not ok 5 (@b)\n"); + +@a = (1,2); +@b = reverse @a; +print ("@b" eq "2 1" ? "ok 6\n" : "not ok 6 (@b)\n"); + +@a = (1,2,3); +@b = reverse @a; +print ("@b" eq "3 2 1" ? "ok 7\n" : "not ok 7 (@b)\n"); + +@a = (1,2,3,4); +@b = reverse @a; +print ("@b" eq "4 3 2 1" ? "ok 8\n" : "not ok 8 (@b)\n"); diff --git a/toke.c b/toke.c index 6b58074..2d83a71 100644 --- a/toke.c +++ b/toke.c @@ -1,4 +1,4 @@ -/* $Header: toke.c,v 3.0 89/10/18 15:32:33 lwall Locked $ +/* $Header: toke.c,v 3.0.1.1 89/10/26 23:26:21 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: toke.c,v $ + * Revision 3.0.1.1 89/10/26 23:26:21 lwall + * patch1: disambiguated word after "sort" better + * * Revision 3.0 89/10/18 15:32:33 lwall * 3.0 baseline * @@ -865,7 +868,15 @@ yylex() fatal("sort is now a reserved word"); if (isascii(*s) && (isalpha(*s) || *s == '_')) { for (d = s; isalpha(*d) || isdigit(*d) || *d == '_'; d++) ; - if (d >= bufend || isspace(*d)) + strncpy(tokenbuf,s,d-s); + if (strNE(tokenbuf,"keys") && + strNE(tokenbuf,"values") && + strNE(tokenbuf,"split") && + strNE(tokenbuf,"grep") && + strNE(tokenbuf,"readdir") && + strNE(tokenbuf,"unpack") && + strNE(tokenbuf,"do") && + (d >= bufend || isspace(*d)) ) *(--s) = '\\'; /* force next ident to WORD */ } LOP(O_SORT); diff --git a/util.h b/util.h index 391fe47..85862eb 100644 --- a/util.h +++ b/util.h @@ -1,4 +1,4 @@ -/* $Header: util.h,v 3.0 89/10/18 15:33:18 lwall Locked $ +/* $Header: util.h,v 3.0.1.1 89/10/26 23:28:25 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: util.h,v $ + * Revision 3.0.1.1 89/10/26 23:28:25 lwall + * patch1: declared bcopy if necessary + * * Revision 3.0 89/10/18 15:33:18 lwall * 3.0 baseline * @@ -30,3 +33,8 @@ char *rninstr(); char *nsavestr(); FILE *mypopen(); int mypclose(); +#ifndef BCOPY +#ifndef MEMCPY +char *bcopy(); +#endif +#endif diff --git a/x2p/Makefile.SH b/x2p/Makefile.SH index c451965..cbbde9a 100644 --- a/x2p/Makefile.SH +++ b/x2p/Makefile.SH @@ -18,9 +18,12 @@ case "$mallocsrc" in esac echo "Extracting x2p/Makefile (with variable substitutions)" cat >Makefile <.shlist +config.sh: ../config.sh + rm -f config.sh + ln ../config.sh . + # AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE $(obj): @ echo "You haven't done a "'"make depend" yet!'; exit 1