perl 3.0 patch #20 patch #19, continued
authorLarry Wall <lwall@jpl-devvax.jpl.nasa.gov>
Wed, 8 Aug 1990 17:07:00 +0000 (17:07 +0000)
committerLarry Wall <lwall@jpl-devvax.jpl.nasa.gov>
Wed, 8 Aug 1990 17:07:00 +0000 (17:07 +0000)
See patch #19.

14 files changed:
arg.h
cmd.c
cmd.h
config.h.SH
h2pl/cbreak.pl [new file with mode: 0644]
h2pl/cbreak2.pl [new file with mode: 0644]
msdos/README.msdos
os2/README.OS2 [new file with mode: 0644]
os2/config.h [new file with mode: 0644]
patchlevel.h
t/base.lex
t/comp.cpp
x2p/a2p.y
x2p/a2py.c

diff --git a/arg.h b/arg.h
index 2406cb9..dcfa370 100644 (file)
--- a/arg.h
+++ b/arg.h
@@ -1,4 +1,4 @@
-/* $Header: arg.h,v 3.0.1.5 90/03/27 15:29:41 lwall Locked $
+/* $Header: arg.h,v 3.0.1.6 90/08/09 02:25:14 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:       arg.h,v $
+ * Revision 3.0.1.6  90/08/09  02:25:14  lwall
+ * patch19: added require operator
+ * patch19: added truncate operator
+ * 
  * Revision 3.0.1.5  90/03/27  15:29:41  lwall
  * patch16: MSDOS support
  * 
 #define O_SEND 180
 #define O_RECV 181
 #define O_SSELECT 182
-#define O_SOCKETPAIR 183
+#define O_SOCKPAIR 183
 #define O_DBSUBR 184
 #define O_DEFINED 185
 #define O_UNDEF 186
 #define O_LSLICE 241
 #define O_SPLICE 242
 #define O_BINMODE 243
-#define MAXO 244
+#define O_REQUIRE 244
+#define O_TRUNCATE 245
+#define MAXO 246
 
 #ifndef DOINIT
 extern char *opname[];
@@ -460,7 +466,7 @@ char *opname[] = {
     "SEND",
     "RECV",
     "SSELECT",
-    "SOCKETPAIR",
+    "SOCKPAIR",
     "DBSUBR",
     "DEFINED",
     "UNDEF",
@@ -521,7 +527,9 @@ char *opname[] = {
     "LSLICE",
     "SPLICE",
     "BINMODE",
-    "244"
+    "REQUIRE",
+    "TRUNCATE",
+    "245"
 };
 #endif
 
@@ -837,7 +845,7 @@ char opargs[MAXO+1] = {
        A(1,1,3),       /* SEND */
        A(1,1,1),       /* RECV */
        A(1,1,1),       /* SSELECT */
-       A(1,1,1),       /* SOCKETPAIR */
+       A(1,1,1),       /* SOCKPAIR */
        A(0,3,0),       /* DBSUBR */
        A(1,0,0),       /* DEFINED */
        A(1,0,0),       /* UNDEF */
@@ -848,7 +856,7 @@ char opargs[MAXO+1] = {
        A(0,1,0),       /* LAELEM */
        A(0,1,0),       /* LHELEM */
        A(1,0,0),       /* LOCAL */
-       A(0,0,0),       /* PIPE */
+       A(1,1,0),       /* PIPE */
        A(1,0,0),       /* FILENO */
        A(1,0,0),       /* GHBYNAME */
        A(1,1,0),       /* GHBYADDR */
@@ -898,6 +906,8 @@ char opargs[MAXO+1] = {
        A(0,3,3),       /* LSLICE */
        A(0,3,1),       /* SPLICE */
        A(1,0,0),       /* BINMODE */
+       A(1,0,0),       /* REQUIRE */
+       A(1,1,0),       /* TRUNCATE */
        0
 };
 #undef A
diff --git a/cmd.c b/cmd.c
index 4f3c13a..844af22 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -1,4 +1,4 @@
-/* $Header: cmd.c,v 3.0.1.7 90/03/27 15:32:37 lwall Locked $
+/* $Header: cmd.c,v 3.0.1.8 90/08/09 02:28:49 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:       cmd.c,v $
+ * Revision 3.0.1.8  90/08/09  02:28:49  lwall
+ * patch19: did preliminary work toward debugging packages and evals
+ * patch19: conditionals now always supply a scalar context to expression
+ * patch19: switch optimizer was confused by negative fractional values
+ * 
  * Revision 3.0.1.7  90/03/27  15:32:37  lwall
  * patch16: non-terminal blocks should never have arrays requested of them
  * 
@@ -301,7 +306,7 @@ until_loop:
 
     /* Set line number so run-time errors can be located */
 
-    line = cmd->c_line;
+    curcmd = cmd;
 
 #ifdef DEBUGGING
     if (debug) {
@@ -615,7 +620,10 @@ until_loop:
            lastretstr = retstr;
        while (tmps_max > tmps_base)    /* clean up after last eval */
            str_free(tmps_list[tmps_max--]);
-       newsp = eval(cmd->c_expr,gimme && (cmdflags & CF_TERM),sp);
+       newsp = eval(cmd->c_expr,
+         gimme && (cmdflags & CF_TERM) && cmd->c_type == C_EXPR &&
+               !cmd->ucmd.acmd.ac_expr,
+         sp);
        st = stack->ary_array;  /* possibly reallocated */
        retstr = st[newsp];
        if (newsp > sp && retstr)
@@ -680,7 +688,15 @@ until_loop:
        }
        break;
     case C_NSWITCH:
-       match = (int)str_gnum(STAB_STR(cmd->c_stab));
+       {
+           double value = str_gnum(STAB_STR(cmd->c_stab));
+
+           match = (int)value;
+           if (value < 0.0) {
+               if (((double)match) > value)
+                   --match;            /* was fractional--truncate other way */
+           }
+       }
        goto doswitch;
     case C_CSWITCH:
        match = *(str_get(STAB_STR(cmd->c_stab))) & 255;
@@ -901,7 +917,7 @@ char *pat;
 {
     register int i;
 
-    fprintf(stderr,"%-4ld",(long)line);
+    fprintf(stderr,"%-4ld",(long)curcmd->c_line);
     for (i=0; i<dlevel; i++)
        fprintf(stderr,"%c%c ",debname[i],debdelim[i]);
     fprintf(stderr,pat,a1,a2,a3,a4,a5,a6,a7,a8);
@@ -916,7 +932,7 @@ va_dcl
     register int i;
 
     va_start(args);
-    fprintf(stderr,"%-4ld",(long)line);
+    fprintf(stderr,"%-4ld",(long)curcmd->c_line);
     for (i=0; i<dlevel; i++)
        fprintf(stderr,"%c%c ",debname[i],debdelim[i]);
 
diff --git a/cmd.h b/cmd.h
index 0c4a0b8..64fc5f5 100644 (file)
--- a/cmd.h
+++ b/cmd.h
@@ -1,4 +1,4 @@
-/* $Header: cmd.h,v 3.0.1.2 90/02/28 16:39:36 lwall Locked $
+/* $Header: cmd.h,v 3.0.1.3 90/08/09 02:29:58 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.3  90/08/09  02:29:58  lwall
+ * patch19: did preliminary work toward debugging packages and evals
+ * 
  * Revision 3.0.1.2  90/02/28  16:39:36  lwall
  * patch9: volatilized some more variables for super-optimizing compilers
  * 
@@ -131,6 +134,7 @@ struct cmd {
     } ucmd;
     short      c_slen;         /* len of c_short, if not null */
     VOLATILE short c_flags;    /* optimization flags--see above */
+    char       *c_pack;        /* package line was compiled in */
     char       *c_file;        /* file the following line # is from */
     line_t      c_line;         /* line # of this command */
     char       c_type;         /* what this command does */
@@ -141,6 +145,9 @@ struct cmd {
 EXT CMD * VOLATILE main_root INIT(Nullcmd);
 EXT CMD * VOLATILE eval_root INIT(Nullcmd);
 
+EXT CMD compiling;
+EXT CMD * VOLATILE curcmd INIT(&compiling);
+
 struct compcmd {
     CMD *comp_true;
     CMD *comp_alt;
index 7af917f..dce224c 100644 (file)
@@ -97,6 +97,12 @@ sed <<!GROK!THIS! >config.h -e 's!^#undef!/\*#undef!'
  */
 #$d_charsprf   CHARSPRINTF     /**/
 
+/* CHSIZE:
+ *     This symbol, if defined, indicates that the chsize routine is available
+ *     to truncate files.  You might need a -lx to get this routine.
+ */
+#$d_chsize     CHSIZE          /**/
+
 /* CRYPT:
  *     This symbol, if defined, indicates that the crypt routine is available
  *     to encrypt passwords and the like.
@@ -288,6 +294,12 @@ sed <<!GROK!THIS! >config.h -e 's!^#undef!/\*#undef!'
  */
 #$d_rmdir      RMDIR           /**/
 
+/* SELECT:
+ *     This symbol, if defined, indicates that the select routine is available
+ *     to select active file descriptors.
+ */
+#$d_select     SELECT          /**/
+
 /* SETEGID:
  *     This symbol, if defined, indicates that the setegid routine is available
  *     to change the effective gid of the current program.
@@ -409,6 +421,12 @@ sed <<!GROK!THIS! >config.h -e 's!^#undef!/\*#undef!'
  */
 #$d_syscall    SYSCALL         /**/
 
+/* TRUNCATE:
+ *     This symbol, if defined, indicates that the truncate routine is
+ *     available to truncate files.
+ */
+#$d_truncate   TRUNCATE                /**/
+
 /* VARARGS:
  *     This symbol, if defined, indicates to the C program that it should
  *     include varargs.h.
@@ -582,6 +600,13 @@ sed <<!GROK!THIS! >config.h -e 's!^#undef!/\*#undef!'
  */
 #define RANDBITS $randbits             /**/
 
+/* SCRIPTDIR:
+ *     This symbol holds the name of the directory in which the user wants
+ *     to put publicly executable scripts for the package in question.  It
+ *     is often a directory that is mounted across diverse architectures.
+ */
+#define SCRIPTDIR "$scriptdir"             /**/
+
 /* SIG_NAME:
  *     This symbol contains an list of signal names in order.
  */
diff --git a/h2pl/cbreak.pl b/h2pl/cbreak.pl
new file mode 100644 (file)
index 0000000..422185e
--- /dev/null
@@ -0,0 +1,34 @@
+$sgttyb_t   = 'C4 S';
+
+sub cbreak {
+    &set_cbreak(1);
+}
+
+sub cooked {
+    &set_cbreak(0);
+}
+
+sub set_cbreak {
+    local($on) = @_;
+
+    require 'sizeof.ph';
+    require 'sys/ioctl.ph';
+
+    ioctl(STDIN,&TIOCGETP,$sgttyb)
+        || die "Can't ioctl TIOCGETP: $!";
+
+    @ary = unpack($sgttyb_t,$sgttyb);
+    if ($on) {
+        $ary[4] |= &CBREAK;
+        $ary[4] &= ~&ECHO;
+    } else {
+        $ary[4] &= ~&CBREAK;
+        $ary[4] |= &ECHO;
+    }
+    $sgttyb = pack($sgttyb_t,@ary);
+    ioctl(STDIN,&TIOCSETP,$sgttyb)
+            || die "Can't ioctl TIOCSETP: $!";
+
+}
+
+1;
diff --git a/h2pl/cbreak2.pl b/h2pl/cbreak2.pl
new file mode 100644 (file)
index 0000000..8ac55a3
--- /dev/null
@@ -0,0 +1,33 @@
+$sgttyb_t   = 'C4 S';
+
+sub cbreak {
+    &set_cbreak(1);
+}
+
+sub cooked {
+    &set_cbreak(0);
+}
+
+sub set_cbreak {
+    local($on) = @_;
+
+    require 'sys/ioctl.pl';
+
+    ioctl(STDIN,$TIOCGETP,$sgttyb)
+        || die "Can't ioctl TIOCGETP: $!";
+
+    @ary = unpack($sgttyb_t,$sgttyb);
+    if ($on) {
+        $ary[4] |= $CBREAK;
+        $ary[4] &= ~$ECHO;
+    } else {
+        $ary[4] &= ~$CBREAK;
+        $ary[4] |= $ECHO;
+    }
+    $sgttyb = pack($sgttyb_t,@ary);
+    ioctl(STDIN,$TIOCSETP,$sgttyb)
+            || die "Can't ioctl TIOCSETP: $!";
+
+}
+
+1;
index fb7be1a..2d6a276 100644 (file)
@@ -39,6 +39,21 @@ rest.   In particular directory access, redirection (includ-
 ing pipes, but excluding the pipe function),  system,  ioctl
 and sleep have been provided.
 
+[Files currently can be edited in-place provided you are cre-
+ating  a  backup.   However, if the backup coincidentally has 
+the same name as the original, or  if  the  resulting  backup 
+filename  is invalid, then the file will probably be trashed.
+For example, don't do
+
+       perl -i~ script makefile
+       perl -i.bak script file.dat
+
+because  (1)  MS-DOS treats "makefile~" and "makefile" as the
+same filename, and (2) "file.dat.bak" is an invalid filename.
+The  files  "makefile"  and  "file.dat" will probably be lost 
+forever.  Moral of the story:   Don't  use  in-place  editing 
+under MS-DOS. --rjc]
+
 2.1.  Interface to the MS-DOS ioctl system call.
 
      The function code of the  ioctl  function  (the  second
diff --git a/os2/README.OS2 b/os2/README.OS2
new file mode 100644 (file)
index 0000000..f79fab9
--- /dev/null
@@ -0,0 +1,275 @@
+
+                  Notes on the OS/2 Perl port
+
+                       Raymond Chen
+                        (rjc@math.princeton.edu)
+
+-1.  Background.
+
+This port was based on the MS-DOS port by Diomidis Spinellis.
+
+0.  Set-up.
+
+First copy the files in the os2 directory into the parent
+directory.  Also install the file msdos/dir.h in your include
+directory.
+
+1.  Compiling.
+
+Perl has been compiled under MS-DOS using the Microsoft C compiler 
+version 6.0.  Before compiling install dir.h as <sys/dir.h>.  You will 
+need a Unix-like make program and something like yacc (e.g. bison).  I 
+just ran yacc on my UNIX box and downloaded the resulting y.tab.[ch] 
+files.  Compilation takes 45 minutes on a 16MHz 386 machine running
+no jobs other than the compiler, so you will probably need something to 
+do in the meantime.  Like, say, lunch.  (Compilation time does not
+include formatting the manual.)  If you compile with optimization 
+turned off, it takes about half as long.
+
+The executable is 270k (perlsym.exe is 473k; if you compile
+without optimization, the sizes are 329K/531K), and the top level 
+directory needs 800K for sources, 550K for object code, and 800K for the 
+executables, assuming you want to build both perl.exe and perlsym.exe
+with full optimization.
+
+The makefile will compile glob for you which you will need to place 
+somewhere in your path so that perl globbing will work correctly.  All 
+the tests were run, although some modifications were necessary because 
+OS/2 isn't UNIX. The tests that failed failed because of limitations of 
+the operating system and aren't the fault of the compiler.  a2p and s2p 
+were not tested.  
+
+In the eg directory you will find the syscalls.pl header file,
+and a sample program that demonstrates some of the improvements
+of the OS/2 version over the MS-DOS version and some of the
+system calls.
+
+2.  Using OS/2 Perl
+
+The OS/2 version of perl has much of the functionality of the Unix 
+version.  Here are some things that don't work:  sockets, password 
+functions, [gs]et[eug]id, dbm functions, fork.  
+
+One thing that doesn't work is "split" with no arguments.  Somehow,
+yylval.arg is empty ...  [[ Wait, sorry, I fixed that. --rjc ]]
+
+Care has been taken to implement the rest, although the implementation
+might not be the best possible.  Here are short notes on the tricky 
+bits:  
+
+2.1.  In-place editing.
+
+Files currently can be edited in-place provided you are creating a 
+backup.  Considerable effort is made to ensure that a reasonable
+name for the backup is selected, while still remaining within
+the 8.3 contraints of the FAT filesystem.  (HPFS users have nothing
+to worry about, since HPFS doesn't have the stupid 8.3 rule.)
+
+The rules for how OS/2 perl combines your filename with the suffix
+(the thing passed to "-i") are rather complicated, but the basic
+idea is that the "obvious" name is chosen.
+
+Here are the rules:
+
+Style 0:  Append the suffix exactly as UNIX perl would do it.
+          If the filesystem likes it, use it.  (HPFS will always
+          swallow it.  FAT will rarely accept it.)
+
+Style 1:  If the suffix begins with a '.', change the file extension
+         to whatever you supplied.  If the name matches the original 
+         name, use the fallback method.
+
+Style 2:  If the suffix is a single character, not a '.', try to add the 
+          suffix to the following places, using the first one that works.
+              [1] Append to extension.  
+              [2] Append to filename, 
+              [3] Replace end of extension, 
+              [4] Replace end of filename.
+          If the name matches the original name, use the fallback method.
+
+Style 3:  Any other case:  Ignore the suffix completely and use the
+          fallback method.
+
+Fallback method:  Change the extension to ".$$$".  If that matches the
+          original name, then change the extension to ".~~~".
+
+If filename is more than 1000 characters long, we die a horrible
+death.  Sorry.
+
+Examples, assuming style 0 failed.
+
+suffix = ".bak" (style 1)
+               foo.bar => foo.bak
+               foo.bak => foo.$$$      (fallback)
+               foo.$$$ => foo.~~~      (fallback)
+               makefile => makefile.bak
+
+suffix = "~" (style 2)
+               foo.c => foo.c~
+               foo.c~ => foo.c~~
+               foo.c~~ => foo~.c~~
+               foo~.c~~ => foo~~.c~~
+               foo~~~~~.c~~ => foo~~~~~.$$$ (fallback)
+
+               foo.pas => foo~.pas
+               makefile => makefile.~
+               longname.fil => longname.fi~
+               longname.fi~ => longnam~.fi~
+               longnam~.fi~ => longnam~.$$$
+               
+2.2.  Directory access.
+
+Are implemented, but in order to support telldir() and seekdir(),
+they operate by reading in the entire directory at opendir(),
+then handing out pieces of it each time you do a readdir().
+
+2.3.  Pipes and redirection.
+
+Pipes and redirection are supported.  Although OS/2 does not 
+terminate programs which try to write to closed pipes, perl will
+kill them for you if you do it like this:
+
+       open(I, "long-running-program|");
+       ... process a few lines ...
+       close(I);       # discard the rest ...
+
+The killing works like this:  We wait until the child program either
+closes its stdout or tries to write to it.  If it writes to its stdout,
+we kill it.  Otherwise, we cwait for it.  This is pretty much what UNIX
+does by default.
+
+All pipe commands are given to cmd.exe (or your COMSPEC) for execution as
+
+       CMD /c your-command-line
+
+so you can go ahead and load it up with any goofy things you want,
+like 2>1 redirection, more pipes, && || etc.
+
+The pipe() function is also supported, so you can go ahead and
+make your own funky file descriptor connections before piping off
+a process.  However, you have to mark the descriptor you are
+retaining as NOINHERIT before spawning, else you are in deadlock city.
+Unfortunately, there's no way to mark the handle as NOINHERIT yet.
+It's on my wish list.
+
+2.4.  Syscall and Ioctl
+
+IOCtl is not supported because the API is very different from the
+UNIX API.  Instead, IOCtl is supported as a syscall.  Here are
+the syscalls I've written so far:
+
+       $OS2_GetVersion = 0;
+       $OS2_Shutdown = 1;
+       $OS2_Beep = 2;
+       $OS2_PhysicalDisk = 3;
+       $OS2_Config = 4;
+       $OS2_IOCtl = 5;
+       $OS2_QCurDisk = 6;
+       $OS2_SelectDisk = 7;
+       $OS2_SetMaxFH = 8;
+       $OS2_Sleep = 9;
+       $OS2_StartSession = 10;
+       $OS2_StopSession = 11;
+       $OS2_SelectSession = 12;
+
+The arguments you pass are handed off to OS/2 without interpretation,
+and the return value is returned straight to you.  However, you don't
+have to supply arguments for the ones whose descriptions are "must be 
+zero"; perl will supply the mandatory zeros for you.
+
+2.5.  Binary file access
+
+Files are opened in text mode by default.  This means that CR LF pairs 
+are translated to LF. If binary access is needed the `binarymode' 
+function should be used.  There is currently no way to reverse the 
+effect of the binary function.  If that is needed close and reopen the 
+file.  
+
+2.6.  Priority
+
+The getpriority and setpriority functions are implemented, but since 
+OS/2 priorities are different from UNIX priorities, the arguments aren't 
+the same.  Basically, the arguments you pass are handed directly to 
+OS/2. The only exception is the last argument to setpriority.  To make 
+it easier to make delta priorities, if the priority class is 0xff, it 
+is changed to 0.  That way, you can write
+
+       setpriority(0,0,-2)
+
+instead of
+
+       setpriority(0,0,0xfe)
+
+to decrease the delta by 2.
+
+2.7.  Interpreter startup.
+
+The effect of the Unix #!/bin/perl interpreter startup can be obtained 
+under OS/2 by giving the script a .cmd extension and beginning the script 
+with the line
+
+       extproc C:\binp\perl.exe -S
+
+You should provide the appropriate path to your executable, and
+the -S option is necessary so that perl can find your script.
+
+2.8.  The kill function.
+
+UNIX and OS/2 have different ideas about the kill function.  I've
+done a pretty feeble job of taking perl's UNIXish approach and
+trying to jam it into the OS/2 way.  No doubt you'll find that
+your kill()s aren't working.  My apologies in advance.
+
+3.  Bug reports.
+
+I don't normally have access to an OS/2 machine, so if you find
+a bug, you can go ahead and tell me about it, but the odds that
+I'd be able to fix it are slim.
+
+4.  Wish list.
+
+4.1.  OS/2.
+
+Make ENOPIPE a fatal error.
+
+Permit linking of files.  (Allegedly, they're working on this.)
+
+Get a fork.
+
+Make CMD.EXE pass through the return code of its child.
+
+4.2 perl.
+
+Provide a nice way to add new functions to perl without having
+to understand the innards of perl.  Not being fluent in perl
+innards hacking, I added my extra functions via syscall.
+
+4.3. My port.
+
+4.3.1.  In-place editing.
+
+Make more idiot-proof.
+
+Allow in-place editing without backup.  (How?)
+
+4.3.2.  Spawning and piping.
+
+Make popen() cleverer.  Currently, it blindly hands everything
+off to CMD.EXE.  This wastes an exec if the command line didn't
+have any shell metacharacters and if the program being run
+is not a batch file.
+
+Clever spawning is carried out by do_spawn.  We should try
+to make popen() do much of the same sort of preprocessing
+as do_spawn does (which means, of course, that we probably
+should yank out code to be dished off into a subroutine).
+
+In do_spawn(), use DosExecPgm instead of spawnl in order to get more 
+precise reasons why the child terminated (RESULTCODES).
+
+
+                               July 1990
+
+                               Raymond Chen <rjc@math.princeton.edu>
+                               1817 Oxford St. Apt 6
+                               Berkeley, CA 94709-1828 USA
diff --git a/os2/config.h b/os2/config.h
new file mode 100644 (file)
index 0000000..7152503
--- /dev/null
@@ -0,0 +1,568 @@
+/* config.h
+ * This file was hand tailored for compiling under MS-DOS and MSC 5.1.
+ * Diomidis Spinellis, March 1990.
+ *
+ * Then it got mangled again for compiling under OS/2 and MSC 6.0.
+ * Raymond Chen, June 1990.
+ */
+#define OS2            /**/
+
+/* OS/2 supports some additional things MS-DOS doesn't.
+ */
+#ifdef OS2
+#define PIPE
+#define GETPPID
+#define GETPRIORITY
+#define SETPRIORITY
+#define SYSCALL
+#define KILL
+#endif /* OS2 */
+
+/* SUFFIX:
+ *      This symbol, if defined, indicates that the function add_suffix has
+ *      been supplied in a system-dependent .c file.  This function is
+ *      recommended for operating systems whose filenaming conventions
+ *      do not permit arbitrary strings as filenames.
+ */
+#define SUFFIX /**/
+
+/* EUNICE:
+ *     This symbol, if defined, indicates that the program is being compiled
+ *     under the EUNICE package under VMS.  The program will need to handle
+ *     things like files that don't go away the first time you unlink them,
+ *     due to version numbering.  It will also need to compensate for lack
+ *     of a respectable link() command.
+ */
+/* VMS:
+ *     This symbol, if defined, indicates that the program is running under
+ *     VMS.  It is currently only set in conjunction with the EUNICE symbol.
+ */
+/*#undef       EUNICE          /**/
+/*#undef       VMS             /**/
+
+/* BIN:
+ *     This symbol holds the name of the directory in which the user wants
+ *     to put publicly executable images for the package in question.  It
+ *     is most often a local directory such as /usr/local/bin.
+ */
+#define BIN "/usr/local/bin"             /**/
+
+/* BYTEORDER:
+ *     This symbol contains an encoding of the order of bytes in a long.
+ *     Usual values (in octal) are 01234, 04321, 02143, 03412...
+ */
+/* CHECK */
+#define BYTEORDER 0x1234               /**/
+
+/* CPPSTDIN:
+ *     This symbol contains the first part of the string which will invoke
+ *     the C preprocessor on the standard input and produce to standard
+ *     output.  Typical value of "cc -{" or "/lib/cpp".
+ */
+/* CPPMINUS:
+ *     This symbol contains the second part of the string which will invoke
+ *     the C preprocessor on the standard input and produce to standard
+ *     output.  This symbol will have the value "-" if CPPSTDIN needs a minus
+ *     to specify standard input, otherwise the value is "".
+ */
+/* TODO */
+#define CPPSTDIN "cc -{"
+#define CPPMINUS ""
+
+/* BCMP:
+ *     This symbol, if defined, indicates that the bcmp routine is available
+ *     to compare blocks of memory.  If undefined, use memcmp.  If that's
+ *     not available, roll your own.
+ */
+/*#define      BCMP            /**/
+
+/* BCOPY:
+ *     This symbol, if defined, indicates that the bcopy routine is available
+ *     to copy blocks of memory.  Otherwise you should probably use memcpy().
+ */
+/*#define      BCOPY           /**/
+
+/* CHARSPRINTF:
+ *     This symbol is defined if this system declares "char *sprintf()" in
+ *     stdio.h.  The trend seems to be to declare it as "int sprintf()".  It
+ *     is up to the package author to declare sprintf correctly based on the
+ *     symbol.
+ */
+/*#define      CHARSPRINTF     /**/
+
+/* CRYPT:
+ *     This symbol, if defined, indicates that the crypt routine is available
+ *     to encrypt passwords and the like.
+ */
+/* TODO */
+/*#define      CRYPT           /**/
+
+/* DOSUID:
+ *     This symbol, if defined, indicates that the C program should
+ *     check the script that it is executing for setuid/setgid bits, and
+ *     attempt to emulate setuid/setgid on systems that have disabled
+ *     setuid #! scripts because the kernel can't do it securely.
+ *     It is up to the package designer to make sure that this emulation
+ *     is done securely.  Among other things, it should do an fstat on
+ *     the script it just opened to make sure it really is a setuid/setgid
+ *     script, it should make sure the arguments passed correspond exactly
+ *     to the argument on the #! line, and it should not trust any
+ *     subprocesses to which it must pass the filename rather than the
+ *     file descriptor of the script to be executed.
+ */
+/*#define DOSUID               /**/
+
+/* DUP2:
+ *     This symbol, if defined, indicates that the dup2 routine is available
+ *     to dup file descriptors.  Otherwise you should use dup().
+ */
+#define        DUP2            /**/
+
+/* FCHMOD:
+ *     This symbol, if defined, indicates that the fchmod routine is available
+ *     to change mode of opened files.  If unavailable, use chmod().
+ */
+/*#define      FCHMOD          /**/
+
+/* FCHOWN:
+ *     This symbol, if defined, indicates that the fchown routine is available
+ *     to change ownership of opened files.  If unavailable, use chown().
+ */
+/*#define      FCHOWN          /**/
+
+/* FCNTL:
+ *     This symbol, if defined, indicates to the C program that it should
+ *     include fcntl.h.
+ */
+/*#define      FCNTL           /**/
+
+/* FLOCK:
+ *     This symbol, if defined, indicates that the flock() routine is
+ *     available to do file locking.
+ */
+/*#define      FLOCK           /**/
+
+/* GETGROUPS:
+ *     This symbol, if defined, indicates that the getgroups() routine is
+ *     available to get the list of process groups.  If unavailable, multiple
+ *     groups are probably not supported.
+ */
+/*#define      GETGROUPS               /**/
+
+/* GETHOSTENT:
+ *     This symbol, if defined, indicates that the gethostent() routine is
+ *     available to lookup host names in some data base or other.
+ */
+/*#define      GETHOSTENT              /**/
+
+/* GETPGRP:
+ *     This symbol, if defined, indicates that the getpgrp() routine is
+ *     available to get the current process group.
+ */
+/*#define      GETPGRP         /**/
+
+/* GETPRIORITY:
+ *     This symbol, if defined, indicates that the getpriority() routine is
+ *     available to get a process's priority.
+ */
+/*#define      GETPRIORITY             /**/
+
+/* HTONS:
+ *     This symbol, if defined, indicates that the htons routine (and friends)
+ *     are available to do network order byte swapping.
+ */
+/* HTONL:
+ *     This symbol, if defined, indicates that the htonl routine (and friends)
+ *     are available to do network order byte swapping.
+ */
+/* NTOHS:
+ *     This symbol, if defined, indicates that the ntohs routine (and friends)
+ *     are available to do network order byte swapping.
+ */
+/* NTOHL:
+ *     This symbol, if defined, indicates that the ntohl routine (and friends)
+ *     are available to do network order byte swapping.
+ */
+/*#define      HTONS           /**/
+/*#define      HTONL           /**/
+/*#define      NTOHS           /**/
+/*#define      NTOHL           /**/
+
+/* index:
+ *     This preprocessor symbol is defined, along with rindex, if the system
+ *     uses the strchr and strrchr routines instead.
+ */
+/* rindex:
+ *     This preprocessor symbol is defined, along with index, if the system
+ *     uses the strchr and strrchr routines instead.
+ */
+#define        index strchr    /* cultural */
+#define        rindex strrchr  /*  differences? */
+
+/* IOCTL:
+ *     This symbol, if defined, indicates that sys/ioctl.h exists and should
+ *     be included.
+ */
+/*#define      IOCTL           /**/
+
+/* KILLPG:
+ *     This symbol, if defined, indicates that the killpg routine is available
+ *     to kill process groups.  If unavailable, you probably should use kill
+ *     with a negative process number.
+ */
+/*#define      KILLPG          /**/
+
+/* MEMCMP:
+ *     This symbol, if defined, indicates that the memcmp routine is available
+ *     to compare blocks of memory.  If undefined, roll your own.
+ */
+#define        MEMCMP          /**/
+
+/* MEMCPY:
+ *     This symbol, if defined, indicates that the memcpy routine is available
+ *     to copy blocks of memory.  Otherwise you should probably use bcopy().
+ *     If neither is defined, roll your own.
+ */
+#define        MEMCPY          /**/
+
+/* MKDIR:
+ *     This symbol, if defined, indicates that the mkdir routine is available
+ *     to create directories.  Otherwise you should fork off a new process to
+ *     exec /bin/mkdir.
+ */
+#define        MKDIR           /**/
+
+/* NDBM:
+ *     This symbol, if defined, indicates that ndbm.h exists and should
+ *     be included.
+ */
+/*#define      NDBM            /**/
+
+/* ODBM:
+ *     This symbol, if defined, indicates that dbm.h exists and should
+ *     be included.
+ */
+/*#define      ODBM            /**/
+
+/* READDIR:
+ *     This symbol, if defined, indicates that the readdir routine is available
+ *     from the C library to create directories.
+ */
+#define        READDIR         /**/
+
+/* RENAME:
+ *     This symbol, if defined, indicates that the rename routine is available
+ *     to rename files.  Otherwise you should do the unlink(), link(), unlink()
+ *     trick.
+ */
+#define        RENAME          /**/
+
+/* RMDIR:
+ *     This symbol, if defined, indicates that the rmdir routine is available
+ *     to remove directories.  Otherwise you should fork off a new process to
+ *     exec /bin/rmdir.
+ */
+#define        RMDIR           /**/
+
+/* SETEGID:
+ *     This symbol, if defined, indicates that the setegid routine is available
+ *     to change the effective gid of the current program.
+ */
+/*#define      SETEGID         /**/
+
+/* SETEUID:
+ *     This symbol, if defined, indicates that the seteuid routine is available
+ *     to change the effective uid of the current program.
+ */
+/*#define      SETEUID         /**/
+
+/* SETPGRP:
+ *     This symbol, if defined, indicates that the setpgrp() routine is
+ *     available to set the current process group.
+ */
+/*#define      SETPGRP         /**/
+
+/* SETPRIORITY:
+ *     This symbol, if defined, indicates that the setpriority() routine is
+ *     available to set a process's priority.
+ */
+/*#define      SETPRIORITY             /**/
+
+/* SETREGID:
+ *     This symbol, if defined, indicates that the setregid routine is available
+ *     to change the real and effective gid of the current program.
+ */
+/*#define      SETREGID                /**/
+
+/* SETREUID:
+ *     This symbol, if defined, indicates that the setreuid routine is available
+ *     to change the real and effective uid of the current program.
+ */
+/*#define      SETREUID                /**/
+
+/* SETRGID:
+ *     This symbol, if defined, indicates that the setrgid routine is available
+ *     to change the real gid of the current program.
+ */
+/*#define      SETRGID         /**/
+
+/* SETRUID:
+ *     This symbol, if defined, indicates that the setruid routine is available
+ *     to change the real uid of the current program.
+ */
+/*#define      SETRUID         /**/
+
+/* SOCKET:
+ *      This symbol, if defined, indicates that the BSD socket interface is
+ *      supported.
+ */
+/* SOCKETPAIR:
+ *      This symbol, if defined, indicates that the BSD socketpair call is
+ *      supported.
+ */
+/* OLDSOCKET:
+ *      This symbol, if defined, indicates that the 4.1c BSD socket interface
+ *      is supported instead of the 4.2/4.3 BSD socket interface.
+ */
+/*#undef SOCKET          /**/
+
+/*#undef SOCKETPAIR      /**/
+
+/*#undef        OLDSOCKET       /**/
+
+/* STATBLOCKS:
+ *     This symbol is defined if this system has a stat structure declaring
+ *     st_blksize and st_blocks.
+ */
+/*#define      STATBLOCKS      /**/
+
+/* STDSTDIO:
+ *     This symbol is defined if this system has a FILE structure declaring
+ *     _ptr and _cnt in stdio.h.
+ */
+#define        STDSTDIO        /**/
+
+/* STRUCTCOPY:
+ *     This symbol, if defined, indicates that this C compiler knows how
+ *     to copy structures.  If undefined, you'll need to use a block copy
+ *     routine of some sort instead.
+ */
+#define        STRUCTCOPY      /**/
+
+/* SYMLINK:
+ *     This symbol, if defined, indicates that the symlink routine is available
+ *     to create symbolic links.
+ */
+/*#define      SYMLINK         /**/
+
+/* SYSCALL:
+ *     This symbol, if defined, indicates that the syscall routine is available
+ *     to call arbitrary system calls.  If undefined, that's tough.
+ */
+/*#define      SYSCALL         /**/
+
+/* TMINSYS:
+ *     This symbol is defined if this system declares "struct tm" in
+ *     in <sys/time.h> rather than <time.h>.  We can't just say
+ *     -I/usr/include/sys because some systems have both time files, and
+ *     the -I trick gets the wrong one.
+ */
+/* I_SYSTIME:
+ *     This symbol is defined if this system has the file <sys/time.h>.
+ */
+/*
+ * I_TIME:
+ *     This symbol is defined if time this  system has the file <time.h>.
+ */
+/*#undef       TMINSYS         /**/
+/*#define      I_SYSTIME       /**/
+#define I_TIME
+
+/* VARARGS:
+ *     This symbol, if defined, indicates to the C program that it should
+ *     include varargs.h.
+ */
+#define        VARARGS         /**/
+
+/* vfork:
+ *     This symbol, if defined, remaps the vfork routine to fork if the
+ *     vfork() routine isn't supported here.
+ */
+/*#undef       vfork fork      /**/
+
+/* VOIDSIG:
+ *     This symbol is defined if this system declares "void (*signal())()" in
+ *     signal.h.  The old way was to declare it as "int (*signal())()".  It
+ *     is up to the package author to declare things correctly based on the
+ *     symbol.
+ */
+#define        VOIDSIG         /**/
+
+/* VPRINTF:
+ *     This symbol, if defined, indicates that the vprintf routine is available
+ *     to printf with a pointer to an argument list.  If unavailable, you
+ *     may need to write your own, probably in terms of _doprnt().
+ */
+/* CHARVSPRINTF:
+ *     This symbol is defined if this system has vsprintf() returning type
+ *     (char*).  The trend seems to be to declare it as "int vsprintf()".  It
+ *     is up to the package author to declare vsprintf correctly based on the
+ *     symbol.
+ */
+#define        VPRINTF         /**/
+/*#undef       CHARVSPRINTF    /**/
+
+/* GIDTYPE:
+ *     This symbol has a value like gid_t, int, ushort, or whatever type is
+ *     used to declare group ids in the kernel.
+ */
+/* TODO */
+#define GIDTYPE int            /**/
+
+/* I_DIRENT:
+ *     This symbol, if defined, indicates to the C program that it should
+ *     include dirent.h.
+ */
+/* DIRNAMLEN:
+ *     This symbol, if defined, indicates to the C program that the length
+ *     of directory entry names is provided by a d_namlen field.  Otherwise
+ *     you need to do strlen() on the d_name field.
+ */
+/*#undef       I_DIRENT                /**/
+#define        DIRNAMLEN               /**/
+
+/* I_FCNTL:
+ *     This symbol, if defined, indicates to the C program that it should
+ *     include fcntl.h.
+ */
+#define        I_FCNTL         /**/
+
+/* I_GRP:
+ *     This symbol, if defined, indicates to the C program that it should
+ *     include grp.h.
+ */
+/*#define      I_GRP           /**/
+
+/* I_PWD:
+ *     This symbol, if defined, indicates to the C program that it should
+ *     include pwd.h.
+ */
+/* PWQUOTA:
+ *     This symbol, if defined, indicates to the C program that struct passwd
+ *     contains pw_quota.
+ */
+/* PWAGE:
+ *     This symbol, if defined, indicates to the C program that struct passwd
+ *     contains pw_age.
+ */
+/*#define      I_PWD           /**/
+/*#define      PWQUOTA         /**/
+/*#undef       PWAGE           /**/
+
+/* I_SYSDIR:
+ *     This symbol, if defined, indicates to the C program that it should
+ *     include sys/dir.h.
+ */
+#define        I_SYSDIR                /**/
+
+/* I_SYSIOCTL:
+ *     This symbol, if defined, indicates that sys/ioctl.h exists and should
+ *     be included.
+ */
+/*#define      I_SYSIOCTL              /**/
+
+/* I_VARARGS:
+ *     This symbol, if defined, indicates to the C program that it should
+ *     include varargs.h.
+ */
+#define        I_VARARGS               /**/
+
+/* INTSIZE:
+ *     This symbol contains the size of an int, so that the C preprocessor
+ *     can make decisions based on it.
+ */
+#define INTSIZE 2              /**/
+
+/* RANDBITS:
+ *     This symbol contains the number of bits of random number the rand()
+ *     function produces.  Usual values are 15, 16, and 31.
+ */
+#define RANDBITS 31            /**/
+
+/* SIG_NAME:
+ *     This symbol contains an list of signal names in order.
+ */
+#ifdef OS2
+#define SIG_NAME "ZERO","HUP","INT","QUIT","ILL","TRAP","IOT","EMT","FPE",\
+         /*      0      1     2     3      4      5     6     7    8 */\
+   "KILL","BUS","SEGV","SYS","PIPE","ALRM","TERM","USR1","USR2","CLD",\
+  /* 9     10     11    12    13     14     15     16     17    18 */\
+   "PWR","USR3","BREAK","ABRT"
+  /*19     20     21    22   */
+#else
+#define SIG_NAME "ZERO","HUP","INT","QUIT","ILL","TRAP","IOT","EMT","FPE","KILL","BUS","SEGV","SYS","PIPE","ALRM","TERM","URG","STOP","TSTP","CONT","CHLD","TTIN","TTOU","IO","XCPU","XFSZ","VTALRM","PROF","WINCH","USR1","USR2"              /**/
+#endif /* OS2 */
+
+/* STDCHAR:
+ *     This symbol is defined to be the type of char used in stdio.h.
+ *     It has the values "unsigned char" or "char".
+ */
+#define STDCHAR char   /**/
+
+/* UIDTYPE:
+ *     This symbol has a value like uid_t, int, ushort, or whatever type is
+ *     used to declare user ids in the kernel.
+ */
+#define UIDTYPE int            /**/
+
+/* VOIDFLAGS:
+ *     This symbol indicates how much support of the void type is given by this
+ *     compiler.  What various bits mean:
+ *
+ *         1 = supports declaration of void
+ *         2 = supports arrays of pointers to functions returning void
+ *         4 = supports comparisons between pointers to void functions and
+ *                 addresses of void functions
+ *
+ *     The package designer should define VOIDUSED to indicate the requirements
+ *     of the package.  This can be done either by #defining VOIDUSED before
+ *     including config.h, or by defining defvoidused in Myinit.U.  If the
+ *     latter approach is taken, only those flags will be tested.  If the
+ *     level of void support necessary is not present, defines void to int.
+ */
+#ifndef VOIDUSED
+#define VOIDUSED 7
+#endif
+#define VOIDFLAGS 7
+#if (VOIDFLAGS & VOIDUSED) != VOIDUSED
+#define void int               /* is void to be avoided? */
+#define M_VOID         /* Xenix strikes again */
+#endif
+
+/* PRIVLIB:
+ *     This symbol contains the name of the private library for this package.
+ *     The library is private in the sense that it needn't be in anyone's
+ *     execution path, but it should be accessible by the world.  The program
+ *     should be prepared to do ^ expansion.
+ */
+#define PRIVLIB "/usr/local/lib/perl"          /**/
+
+/*
+ * BUGGY_MSC:
+ *     This symbol is defined if you are the unfortunate owner of a buggy
+ *     Microsoft C compiler and want to use intrinsic functions.  Versions
+ *     up to 5.1 are known conform to this definition.
+ */
+/*#define BUGGY_MSC                    /**/
+
+/*
+ * BINARY:
+ *     This symbol is defined if you run under an operating system that
+ *     distinguishes between binary and text files.  If so the function
+ *     setmode will be used to set the file into binary mode.
+ */
+#define BINARY
+
+#define S_ISUID 0
+#define S_ISGID 0
+#define CASTNEGFLOAT
index 111b8fe..37c7e31 100644 (file)
@@ -1 +1 @@
-#define PATCHLEVEL 19
+#define PATCHLEVEL 20
index 16f0dd9..5fb62d5 100644 (file)
@@ -1,6 +1,6 @@
 #!./perl
 
-# $Header: base.lex,v 3.0 89/10/18 15:24:24 lwall Locked $
+# $Header: base.lex,v 3.0.1.1 90/08/09 05:24:43 lwall Locked $
 
 print "1..18\n";
 
@@ -34,7 +34,7 @@ if (!$@) {print "ok 6\n";} else {print "not ok 6\n";}
 eval '$foo = 123+123.4+123e4+123.4E5+123.4e+5+.12;';
 
 $foo = int($foo * 100 + .5);
-if ($foo eq 2591024652) {print "ok 7\n";} else {print "not ok 7\n";}
+if ($foo eq 2591024652) {print "ok 7\n";} else {print "not ok 7 :$foo:\n";}
 
 print <<'EOF';
 ok 8
index 592700d..0464108 100644 (file)
@@ -1,6 +1,6 @@
 #!./perl -P
 
-# $Header: comp.cpp,v 3.0 89/10/18 15:25:19 lwall Locked $
+# $Header: comp.cpp,v 3.0.1.1 90/08/09 05:25:34 lwall Locked $
 
 print "1..3\n";
 
@@ -32,4 +32,4 @@ $pwd=`pwd`;
 $pwd =~ s/\n//;
 $x = `./perl -P -I$pwd Comp.cpp.tmp`;
 print $x;
-`/bin/rm -f Comp.cpp.tmp Comp.cpp.inc`;
+unlink "Comp.cpp.tmp", "Comp.cpp.inc";
index 6a6604d..13c68b8 100644 (file)
--- a/x2p/a2p.y
+++ b/x2p/a2p.y
@@ -1,5 +1,5 @@
 %{
-/* $Header: a2p.y,v 3.0.1.1 90/03/01 10:30:08 lwall Locked $
+/* $Header: a2p.y,v 3.0.1.2 90/08/09 05:47:26 lwall Locked $
  *
  *    Copyright (c) 1989, Larry Wall
  *
@@ -7,6 +7,9 @@
  *    as specified in the README file that comes with the perl 3.0 kit.
  *
  * $Log:       a2p.y,v $
+ * Revision 3.0.1.2  90/08/09  05:47:26  lwall
+ * patch19: a2p didn't handle {foo = (bar == 123)}
+ * 
  * Revision 3.0.1.1  90/03/01  10:30:08  lwall
  * patch9: a2p didn't allow logical expressions everywhere it should
  * 
@@ -137,7 +140,7 @@ expr        : term
                { $$ = $1; }
        | expr term
                { $$ = oper2(OCONCAT,$1,$2); }
-       | variable ASGNOP expr
+       | variable ASGNOP cond
                { $$ = oper3(OASSIGN,$2,$1,$3);
                        if ((ops[$1].ival & 255) == OFLD)
                            lval_field = TRUE;
@@ -167,7 +170,7 @@ term        : variable
        | term IN VAR
                { $$ = oper2(ODEFINED,aryrefarg($3),$1); }
        | term '?' term ':' term
-               { $$ = oper2(OCOND,$1,$3,$5); }
+               { $$ = oper3(OCOND,$1,$3,$5); }
        | variable INCR
                { $$ = oper1(OPOSTINCR,$1); }
        | variable DECR
index e17c542..d53fb16 100644 (file)
@@ -1,4 +1,4 @@
-/* $Header: a2py.c,v 3.0 89/10/18 15:34:35 lwall Locked $
+/* $Header: a2py.c,v 3.0.1.1 90/08/09 05:48:53 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:       a2py.c,v $
+ * Revision 3.0.1.1  90/08/09  05:48:53  lwall
+ * patch19: a2p didn't emit a chop when NF was referenced though split needs it
+ * 
  * Revision 3.0  89/10/18  15:34:35  lwall
  * 3.0 baseline
  * 
@@ -578,7 +581,7 @@ yylex()
     case 'n': case 'N':
        SNARFWORD;
        if (strEQ(d,"NF"))
-           do_split = split_to_array = set_array_base = TRUE;
+           do_chop = do_split = split_to_array = set_array_base = TRUE;
        if (strEQ(d,"next")) {
            saw_line_op = TRUE;
            XTERM(NEXT);