[alt.sources] perl 3.0 beta to gamma upgrade kit 2/4

lwall@jato.Jpl.Nasa.Gov (Larry Wall) (09/16/89)

Apply these to a virgin perl 3.0 beta directory to produce a perl 3.0 gamma
directory.  Recommended patch switches are -p1 -N.

Larry Wall
lwall@jpl-devvax.jpl.nasa.gov

diff -c -r beta/arg.h gamma/arg.h
*** beta/arg.h	Fri Sep 15 16:06:19 1989
--- gamma/arg.h	Fri Sep 15 16:11:16 1989
***************
*** 226,232 ****
  #define O_ENETENT 215
  #define O_VEC 216
  #define O_GREP 217
! #define MAXO 218
  
  #ifndef DOINIT
  extern char *opname[];
--- 226,255 ----
  #define O_ENETENT 215
  #define O_VEC 216
  #define O_GREP 217
! #define O_GPWNAM 218
! #define O_GPWUID 219
! #define O_GPWENT 220
! #define O_SPWENT 221
! #define O_EPWENT 222
! #define O_GGRNAM 223
! #define O_GGRGID 224
! #define O_GGRENT 225
! #define O_SGRENT 226
! #define O_EGRENT 227
! #define O_SHUTDOWN 228
! #define O_OPENDIR 229
! #define O_READDIR 230
! #define O_TELLDIR 231
! #define O_SEEKDIR 232
! #define O_REWINDDIR 233
! #define O_CLOSEDIR 234
! #define O_GETLOGIN 235
! #define O_SYSCALL 236
! #define O_GSOCKOPT 237
! #define O_SSOCKOPT 238
! #define O_GETSOCKNAME 239
! #define O_GETPEERNAME 240
! #define MAXO 241
  
  #ifndef DOINIT
  extern char *opname[];
***************
*** 450,456 ****
      "ENETENT",
      "VEC",
      "GREP",
!     "218"
  };
  #endif
  
--- 473,502 ----
      "ENETENT",
      "VEC",
      "GREP",
!     "GPWNAM",
!     "GPWUID",
!     "GPWENT",
!     "SPWENT",
!     "EPWENT",
!     "GGRNAM",
!     "GGRGID",
!     "GGRENT",
!     "SGRENT",
!     "EGRENT",
!     "SHUTDOWN",
!     "OPENDIR",
!     "READDIR",
!     "TELLDIR",
!     "SEEKDIR",
!     "REWINDDIR",
!     "CLOSEDIR",
!     "GETLOGIN",
!     "SYSCALL",
!     "GSOCKOPT",
!     "SSOCKOPT",
!     "GETSOCKNAME",
!     "GETPEERNAME",
!     "241"
  };
  #endif
  
***************
*** 795,800 ****
--- 841,869 ----
  	A(0,0,0),	/* ENETENT */
  	A(1,1,1),	/* VEC */
  	A(0,3,0),	/* GREP */
+ 	A(1,0,0),	/* GPWNAM */
+ 	A(1,0,0),	/* GPWUID */
+ 	A(0,0,0),	/* GPWENT */
+ 	A(0,0,0),	/* SPWENT */
+ 	A(0,0,0),	/* EPWENT */
+ 	A(1,0,0),	/* GGRNAM */
+ 	A(1,0,0),	/* GGRGID */
+ 	A(0,0,0),	/* GGRENT */
+ 	A(0,0,0),	/* SGRENT */
+ 	A(0,0,0),	/* EGRENT */
+ 	A(1,1,0),	/* SHUTDOWN */
+ 	A(1,1,0),	/* OPENDIR */
+ 	A(1,0,0),	/* READDIR */
+ 	A(1,0,0),	/* TELLDIR */
+ 	A(1,1,0),	/* SEEKDIR */
+ 	A(1,0,0),	/* REWINDDIR */
+ 	A(1,0,0),	/* CLOSEDIR */
+ 	A(0,0,0),	/* GETLOGIN */
+ 	A(1,3,0),	/* SYSCALL */
+ 	A(1,1,1),	/* GSOCKOPT */
+ 	A(1,1,1),	/* SSOCKOPT */
+ 	A(1,0,0),	/* GETSOCKNAME */
+ 	A(1,0,0),	/* GETPEERNAME */
  	0
  };
  #undef A
diff -c -r beta/array.c gamma/array.c
*** beta/array.c	Fri Sep 15 16:05:56 1989
--- gamma/array.c	Fri Sep 15 16:12:19 1989
***************
*** 21,27 ****
  
      if (key < 0 || key > ar->ary_fill) {
  	if (lval && key >= 0) {
! 	    str = str_new(0);
  	    (void)astore(ar,key,str);
  	    return str;
  	}
--- 21,30 ----
  
      if (key < 0 || key > ar->ary_fill) {
  	if (lval && key >= 0) {
! 	    if (ar->ary_flags & ARF_REAL)
! 		str = Str_new(5,0);
! 	    else
! 		str = str_static(&str_undef);
  	    (void)astore(ar,key,str);
  	    return str;
  	}
***************
*** 29,35 ****
  	    return Nullstr;
      }
      if (lval && !ar->ary_array[key]) {
! 	str = str_new(0);
  	(void)astore(ar,key,str);
  	return str;
      }
--- 32,38 ----
  	    return Nullstr;
      }
      if (lval && !ar->ary_array[key]) {
! 	str = Str_new(6,0);
  	(void)astore(ar,key,str);
  	return str;
      }
***************
*** 93,99 ****
      New(1,ar,1,ARRAY);
      Newz(2,ar->ary_alloc,5,STR*);
      ar->ary_array = ar->ary_alloc;
!     ar->ary_magic = str_new(0);
      str_magic(ar->ary_magic, stab, '#', Nullch, 0);
      ar->ary_fill = -1;
      ar->ary_index = -1;
--- 96,102 ----
      New(1,ar,1,ARRAY);
      Newz(2,ar->ary_alloc,5,STR*);
      ar->ary_array = ar->ary_alloc;
!     ar->ary_magic = Str_new(7,0);
      str_magic(ar->ary_magic, stab, '#', Nullch, 0);
      ar->ary_fill = -1;
      ar->ary_index = -1;
***************
*** 114,120 ****
      New(4,ar->ary_alloc,5,STR*);
      Copy(strp,ar->ary_alloc,size,STR*);
      ar->ary_array = ar->ary_alloc;
!     ar->ary_magic = str_new(0);
      str_magic(ar->ary_magic, stab, '#', Nullch, 0);
      ar->ary_fill = size - 1;
      ar->ary_index = -1;
--- 117,123 ----
      New(4,ar->ary_alloc,5,STR*);
      Copy(strp,ar->ary_alloc,size,STR*);
      ar->ary_array = ar->ary_alloc;
!     ar->ary_magic = Str_new(8,0);
      str_magic(ar->ary_magic, stab, '#', Nullch, 0);
      ar->ary_fill = size - 1;
      ar->ary_index = -1;
***************
*** 147,160 ****
  {
      register int key;
  
!     if (!ar || !(ar->ary_flags & ARF_REAL))
  	return;
      if (key = ar->ary_array - ar->ary_alloc) {
  	ar->ary_max += key;
  	ar->ary_array -= key;
      }
!     for (key = 0; key <= ar->ary_max; key++)
! 	str_free(ar->ary_array[key]);
      str_free(ar->ary_magic);
      Safefree(ar->ary_alloc);
      Safefree(ar);
--- 150,165 ----
  {
      register int key;
  
!     if (!ar)
  	return;
      if (key = ar->ary_array - ar->ary_alloc) {
  	ar->ary_max += key;
  	ar->ary_array -= key;
      }
!     if (ar->ary_flags & ARF_REAL) {
! 	for (key = 0; key <= ar->ary_max; key++)
! 	    str_free(ar->ary_array[key]);
!     }
      str_free(ar->ary_magic);
      Safefree(ar->ary_alloc);
      Safefree(ar);
diff -c -r beta/cmd.c gamma/cmd.c
*** beta/cmd.c	Fri Sep 15 16:06:51 1989
--- gamma/cmd.c	Fri Sep 15 16:11:23 1989
***************
*** 11,17 ****
  #include "EXTERN.h"
  #include "perl.h"
  
! #ifdef VARARGS
  #  include <varargs.h>
  #endif
  
--- 11,17 ----
  #include "EXTERN.h"
  #include "perl.h"
  
! #ifdef I_VARARGS
  #  include <varargs.h>
  #endif
  
***************
*** 824,830 ****
  {
      register STR *str;
  
!     str = str_new(0);
      str->str_state = SS_SARY;
      str->str_u.str_stab = stab;
      if (str->str_ptr) {
--- 824,830 ----
  {
      register STR *str;
  
!     str = Str_new(10,0);
      str->str_state = SS_SARY;
      str->str_u.str_stab = stab;
      if (str->str_ptr) {
***************
*** 843,849 ****
  {
      register STR *str;
  
!     str = str_new(0);
      str->str_state = SS_SHASH;
      str->str_u.str_stab = stab;
      if (str->str_ptr) {
--- 843,849 ----
  {
      register STR *str;
  
!     str = Str_new(11,0);
      str->str_state = SS_SHASH;
      str->str_u.str_stab = stab;
      if (str->str_ptr) {
***************
*** 863,869 ****
      register STR *str;
  
      (void)apush(savestack,item);		/* remember the pointer */
!     str = str_new(0);
      str_sset(str,item);
      (void)apush(savestack,str);			/* remember the value */
  }
--- 863,869 ----
      register STR *str;
  
      (void)apush(savestack,item);		/* remember the pointer */
!     str = Str_new(12,0);
      str_sset(str,item);
      (void)apush(savestack,str);			/* remember the value */
  }
***************
*** 874,880 ****
  {
      register STR *str;
  
!     str = str_new(0);
      str->str_state = SS_SINT;
      str->str_u.str_useful = (long)*intp;	/* remember value */
      if (str->str_ptr) {
--- 874,880 ----
  {
      register STR *str;
  
!     str = Str_new(13,0);
      str->str_state = SS_SINT;
      str->str_u.str_useful = (long)*intp;	/* remember value */
      if (str->str_ptr) {
***************
*** 891,897 ****
  {
      register STR *str;
  
!     str = str_new(0);
      str->str_state = SS_SLONG;
      str->str_u.str_useful = *longp;		/* remember value */
      if (str->str_ptr) {
--- 891,897 ----
  {
      register STR *str;
  
!     str = Str_new(14,0);
      str->str_state = SS_SLONG;
      str->str_u.str_useful = *longp;		/* remember value */
      if (str->str_ptr) {
***************
*** 908,914 ****
  {
      register STR *str;
  
!     str = str_new(0);
      str->str_state = SS_SSTRP;
      str->str_magic = *sptr;		/* remember value */
      if (str->str_ptr) {
--- 908,914 ----
  {
      register STR *str;
  
!     str = Str_new(15,0);
      str->str_state = SS_SSTRP;
      str->str_magic = *sptr;		/* remember value */
      if (str->str_ptr) {
***************
*** 925,931 ****
  {
      register STR *str;
  
!     str = str_new(0);
      str->str_state = SS_SNSTAB;
      str->str_magic = (STR*)stab;	/* remember which stab to free */
      (void)apush(savestack,str);
--- 925,931 ----
  {
      register STR *str;
  
!     str = Str_new(16,0);
      str->str_state = SS_SNSTAB;
      str->str_magic = (STR*)stab;	/* remember which stab to free */
      (void)apush(savestack,str);
***************
*** 937,943 ****
  {
      register STR *str;
  
!     str = str_new(0);
      str->str_state = SS_SHPTR;
      str->str_u.str_hash = *hptr;	/* remember value */
      if (str->str_ptr) {
--- 937,943 ----
  {
      register STR *str;
  
!     str = Str_new(17,0);
      str->str_state = SS_SHPTR;
      str->str_u.str_hash = *hptr;	/* remember value */
      if (str->str_ptr) {
***************
*** 958,964 ****
  
      for (i = 1; i <= maxsarg; i++) {
  	(void)apush(savestack,sarg[i]);		/* remember the pointer */
! 	str = str_new(0);
  	str_sset(str,sarg[i]);
  	(void)apush(savestack,str);			/* remember the value */
      }
--- 958,964 ----
  
      for (i = 1; i <= maxsarg; i++) {
  	(void)apush(savestack,sarg[i]);		/* remember the pointer */
! 	str = Str_new(18,0);
  	str_sset(str,sarg[i]);
  	(void)apush(savestack,str);			/* remember the value */
      }
diff -c -r beta/config.h.SH gamma/config.h.SH
*** beta/config.h.SH	Fri Sep 15 16:06:11 1989
--- gamma/config.h.SH	Fri Sep 15 16:10:51 1989
***************
*** 64,69 ****
--- 64,76 ----
  #define CPPSTDIN "$cppstdin"
  #define CPPMINUS "$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.
+  */
+ #$d_bcmp	BCMP		/**/
+ 
  /* BCOPY:
   *	This symbol, if defined, indicates that the bcopy routine is available
   *	to copy blocks of memory.  Otherwise you should probably use memcpy().
***************
*** 99,104 ****
--- 106,117 ----
   */
  #$d_dosuid DOSUID		/**/
  
+ /* DUP2:
+  *	This symbol, if defined, indicates that the dup2 routine is available
+  *	to dup file descriptors.  Otherwise you should use dup().
+  */
+ #$d_dup2	DUP2		/**/
+ 
  /* FCHMOD:
   *	This symbol, if defined, indicates that the fchmod routine is available
   *	to change mode of opened files.  If unavailable, use chmod().
***************
*** 130,135 ****
--- 143,154 ----
   */
  #$d_getgrps	GETGROUPS		/**/
  
+ /* GETHOSTENT:
+  *	This symbol, if defined, indicates that the gethostent() routine is
+  *	available to lookup host names in some data base or other.
+  */
+ #$d_gethent	GETHOSTENT		/**/
+ 
  /* GETPGRP:
   *	This symbol, if defined, indicates that the getpgrp() routine is
   *	available to get the current process group.
***************
*** 187,192 ****
--- 206,217 ----
   */
  #$d_killpg	KILLPG		/**/
  
+ /* MEMCMP:
+  *	This symbol, if defined, indicates that the memcmp routine is available
+  *	to compare blocks of memory.  If undefined, roll your own.
+  */
+ #$d_memcmp	MEMCMP		/**/
+ 
  /* MEMCPY:
   *	This symbol, if defined, indicates that the memcpy routine is available
   *	to copy blocks of memory.  Otherwise you should probably use bcopy().
***************
*** 213,218 ****
--- 238,249 ----
   */
  #$d_odbm	ODBM		/**/
  
+ /* READDIR:
+  *	This symbol, if defined, indicates that the readdir routine is available
+  *	from the C library to create directories.
+  */
+ #$d_readdir	READDIR		/**/
+ 
  /* RENAME:
   *	This symbol, if defined, indicates that the rename routine is available
   *	to rename files.  Otherwise you should do the unlink(), link(), unlink()
***************
*** 279,284 ****
--- 310,319 ----
   *	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.
***************
*** 285,290 ****
--- 320,327 ----
   */
  #$d_socket	SOCKET		/**/
  
+ #$d_sockpair	SOCKETPAIR	/**/
+ 
  #$d_oldsock	OLDSOCKET	/**/
  
  /* STATBLOCKS:
***************
*** 312,317 ****
--- 349,360 ----
   */
  #$d_symlink	SYMLINK		/**/
  
+ /* SYSCALL:
+  *	This symbol, if defined, indicates that the syscall routine is available
+  *	to call arbitrary system calls.  If undefined, that's tough.
+  */
+ #$d_syscall	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
***************
*** 349,355 ****
--- 392,405 ----
   *	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.
+  */
  #$d_vprintf	VPRINTF		/**/
+ #$d_charvspr	CHARVSPRINTF 	/**/
  
  /* GIDTYPE:
   *	This symbol has a value like gid_t, int, ushort, or whatever type is
***************
*** 356,361 ****
--- 406,469 ----
   *	used to declare group ids in the kernel.
   */
  #define GIDTYPE $gidtype		/**/
+ 
+ /* 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.
+  */
+ #$i_dirent	I_DIRENT		/**/
+ #$d_dirnamlen	DIRNAMLEN		/**/
+ 
+ /* I_FCNTL:
+  *	This symbol, if defined, indicates to the C program that it should
+  *	include fcntl.h.
+  */
+ #$i_fcntl	I_FCNTL		/**/
+ 
+ /* I_GRP:
+  *	This symbol, if defined, indicates to the C program that it should
+  *	include grp.h.
+  */
+ #$i_grp	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.
+  */
+ #$i_pwd	I_PWD		/**/
+ #$d_pwquota	PWQUOTA		/**/
+ #$d_pwage	PWAGE		/**/
+ 
+ /* I_SYSDIR:
+  *	This symbol, if defined, indicates to the C program that it should
+  *	include sys/dir.h.
+  */
+ #$i_sysdir	I_SYSDIR		/**/
+ 
+ /* I_SYSIOCTL:
+  *	This symbol, if defined, indicates that sys/ioctl.h exists and should
+  *	be included.
+  */
+ #$i_sysioctl	I_SYSIOCTL		/**/
+ 
+ /* I_VARARGS:
+  *	This symbol, if defined, indicates to the C program that it should
+  *	include varargs.h.
+  */
+ #$i_varargs	I_VARARGS		/**/
  
  /* INTSIZE:
   *	This symbol contains the size of an int, so that the C preprocessor
diff -c -r beta/cons.c gamma/cons.c
*** beta/cons.c	Fri Sep 15 16:06:17 1989
--- gamma/cons.c	Fri Sep 15 16:10:50 1989
***************
*** 67,75 ****
  	str_cat(str,buf);
  	name = str_get(subname);
  	hstore(stab_xhash(DBsub),name,strlen(name),str,0);
- 	subline = 0;
  	str_set(subname,"main");
      }
  }
  
  CMD *
--- 67,76 ----
  	str_cat(str,buf);
  	name = str_get(subname);
  	hstore(stab_xhash(DBsub),name,strlen(name),str,0);
  	str_set(subname,"main");
      }
+     subline = 0;
+     return sub;
  }
  
  CMD *
***************
*** 81,87 ****
      register int last_opt = 0;
      register STAB *last_stab = Nullstab;
      register int count = 0;
!     register CMD *switchbeg;
  
      if (tail == Nullcmd) {
  	return tail;
--- 82,88 ----
      register int last_opt = 0;
      register STAB *last_stab = Nullstab;
      register int count = 0;
!     register CMD *switchbeg = Nullcmd;
  
      if (tail == Nullcmd) {
  	return tail;
***************
*** 173,179 ****
      Newz(103,loc,258,CMD*);
      loc++;				/* lie a little */
      while (count--) {
! 	if ((cur->c_flags && CF_OPTIMIZE) == CFT_CCLASS) {
  	    for (i = 0; i <= 255; i++) {
  		if (!loc[i] && cur->c_short->str_ptr[i>>3] & (1 << (i&7))) {
  		    loc[i] = cur;
--- 174,180 ----
      Newz(103,loc,258,CMD*);
      loc++;				/* lie a little */
      while (count--) {
! 	if ((cur->c_flags & CF_OPTIMIZE) == CFT_CCLASS) {
  	    for (i = 0; i <= 255; i++) {
  		if (!loc[i] && cur->c_short->str_ptr[i>>3] & (1 << (i&7))) {
  		    loc[i] = cur;
***************
*** 346,358 ****
      cmd->c_type = C_EXPR;
      cmd->ucmd.acmd.ac_stab = Nullstab;
      cmd->ucmd.acmd.ac_expr = Nullarg;
!     arg = make_op(O_ITEM,1,Nullarg,Nullarg,Nullarg,0);
      arg[1].arg_type = A_SINGLE;
      arg[1].arg_ptr.arg_str = str_nmake((double)head->c_line);
      cmd->c_expr = make_op(O_SUBR, 2,
  	stab2arg(A_WORD,DBstab),
  	make_list(arg),
! 	Nullarg,1);
      opt_arg(cmd,1,1);
      cmd->c_flags |= CF_COND;
      cmd->c_line = head->c_line;
--- 347,359 ----
      cmd->c_type = C_EXPR;
      cmd->ucmd.acmd.ac_stab = Nullstab;
      cmd->ucmd.acmd.ac_expr = Nullarg;
!     arg = make_op(O_ITEM,1,Nullarg,Nullarg,Nullarg);
      arg[1].arg_type = A_SINGLE;
      arg[1].arg_ptr.arg_str = str_nmake((double)head->c_line);
      cmd->c_expr = make_op(O_SUBR, 2,
  	stab2arg(A_WORD,DBstab),
  	make_list(arg),
! 	Nullarg);
      opt_arg(cmd,1,1);
      cmd->c_flags |= CF_COND;
      cmd->c_line = head->c_line;
***************
*** 843,849 ****
  	cmd->c_stab = arg[1].arg_ptr.arg_stab;
  	if (stab_io(arg[1].arg_ptr.arg_stab)->flags & IOF_ARGV) {
  	    cmd->c_expr = l(make_op(O_ASSIGN, 2,	/* fake up "$_ =" */
! 	       stab2arg(A_LVAL,defstab), arg, Nullarg,1 ));
  	}
  	else {
  	    free_arg(arg);
--- 844,850 ----
  	cmd->c_stab = arg[1].arg_ptr.arg_stab;
  	if (stab_io(arg[1].arg_ptr.arg_stab)->flags & IOF_ARGV) {
  	    cmd->c_expr = l(make_op(O_ASSIGN, 2,	/* fake up "$_ =" */
! 	       stab2arg(A_LVAL,defstab), arg, Nullarg));
  	}
  	else {
  	    free_arg(arg);
***************
*** 863,869 ****
  	else
  	    asgnstab = defstab;
  	cmd->c_expr = l(make_op(O_ASSIGN, 2,	/* fake up "$foo =" */
! 	   stab2arg(A_LVAL,asgnstab), arg, Nullarg,1 ));
  	cmd->c_flags &= ~CF_OPTIMIZE;	/* clear optimization type */
      }
  }
--- 864,870 ----
  	else
  	    asgnstab = defstab;
  	cmd->c_expr = l(make_op(O_ASSIGN, 2,	/* fake up "$foo =" */
! 	   stab2arg(A_LVAL,asgnstab), arg, Nullarg));
  	cmd->c_flags &= ~CF_OPTIMIZE;	/* clear optimization type */
      }
  }
***************
*** 979,985 ****
      tail->c_type = C_EXPR;
      tail->c_flags ^= CF_INVERT;		/* turn into "last unless" */
      tail->c_next = tail->ucmd.ccmd.cc_true;	/* loop directly back to top */
!     tail->ucmd.acmd.ac_expr = make_op(O_LAST,0,Nullarg,Nullarg,Nullarg,0);
      tail->ucmd.acmd.ac_stab = Nullstab;
      return cmd;
  }
--- 980,986 ----
      tail->c_type = C_EXPR;
      tail->c_flags ^= CF_INVERT;		/* turn into "last unless" */
      tail->c_next = tail->ucmd.ccmd.cc_true;	/* loop directly back to top */
!     tail->ucmd.acmd.ac_expr = make_op(O_LAST,0,Nullarg,Nullarg,Nullarg);
      tail->ucmd.acmd.ac_stab = Nullstab;
      return cmd;
  }
***************
*** 1046,1051 ****
--- 1047,1061 ----
  	case A_NULL:
  	    break;
  	case A_LEXPR:
+ 	    if (arg->arg_type == O_AASSIGN &&
+ 	      arg[i].arg_ptr.arg_arg->arg_type == O_LARRAY) {
+ 		char *name = 
+ 		  stab_name(arg[i].arg_ptr.arg_arg[1].arg_ptr.arg_stab);
+ 
+ 		if (strnEQ("_GEN_",name, 5))	/* array for foreach */
+ 		    hdelete(defstash,name,strlen(name));
+ 	    }
+ 	    /* FALL THROUGH */
  	case A_EXPR:
  	    arg_free(arg[i].arg_ptr.arg_arg);
  	    break;
diff -c -r beta/consarg.c gamma/consarg.c
*** beta/consarg.c	Fri Sep 15 16:06:44 1989
--- gamma/consarg.c	Fri Sep 15 16:11:13 1989
***************
*** 30,36 ****
  	spat->spat_runtime = arg;
  	arg = make_match(O_MATCH,stab2arg(A_STAB,defstab),spat);
      }
!     Renew(arg,3,ARG);
      arg->arg_len = 3;
      if (limarg) {
  	if (limarg->arg_type == O_ITEM) {
--- 30,36 ----
  	spat->spat_runtime = arg;
  	arg = make_match(O_MATCH,stab2arg(A_STAB,defstab),spat);
      }
!     Renew(arg,4,ARG);
      arg->arg_len = 3;
      if (limarg) {
  	if (limarg->arg_type == O_ITEM) {
***************
*** 77,98 ****
  	case O_MATCH:
  	    newarg = make_op(type == O_MATCH ? O_MATCH : O_NMATCH,
  		pat->arg_len,
! 		left,Nullarg,Nullarg,0);
  	    break;
  	case O_SUBST:
  	    newarg = l(make_op(type == O_MATCH ? O_SUBST : O_NSUBST,
  		pat->arg_len,
! 		left,Nullarg,Nullarg,0));
  	    break;
  	case O_TRANS:
  	    newarg = l(make_op(type == O_MATCH ? O_TRANS : O_NTRANS,
  		pat->arg_len,
! 		left,Nullarg,Nullarg,0));
  	    break;
  	case O_SPLIT:
  	    newarg = make_op(type == O_MATCH ? O_SPLIT : O_SPLIT,
  		pat->arg_len,
! 		left,Nullarg,Nullarg,0);
  	    break;
  	}
  	if (pat->arg_len >= 2) {
--- 77,98 ----
  	case O_MATCH:
  	    newarg = make_op(type == O_MATCH ? O_MATCH : O_NMATCH,
  		pat->arg_len,
! 		left,Nullarg,Nullarg);
  	    break;
  	case O_SUBST:
  	    newarg = l(make_op(type == O_MATCH ? O_SUBST : O_NSUBST,
  		pat->arg_len,
! 		left,Nullarg,Nullarg));
  	    break;
  	case O_TRANS:
  	    newarg = l(make_op(type == O_MATCH ? O_TRANS : O_NTRANS,
  		pat->arg_len,
! 		left,Nullarg,Nullarg));
  	    break;
  	case O_SPLIT:
  	    newarg = make_op(type == O_MATCH ? O_SPLIT : O_SPLIT,
  		pat->arg_len,
! 		left,Nullarg,Nullarg);
  	    break;
  	}
  	if (pat->arg_len >= 2) {
***************
*** 113,119 ****
  	curstash->tbl_spatroot = spat;
  
  	spat->spat_runtime = pat;
! 	newarg = make_op(type,2,left,Nullarg,Nullarg,0);
  	newarg[2].arg_type = A_SPAT | A_DONT;
  	newarg[2].arg_ptr.arg_spat = spat;
      }
--- 113,119 ----
  	curstash->tbl_spatroot = spat;
  
  	spat->spat_runtime = pat;
! 	newarg = make_op(type,2,left,Nullarg,Nullarg);
  	newarg[2].arg_type = A_SPAT | A_DONT;
  	newarg[2].arg_ptr.arg_spat = spat;
      }
***************
*** 273,279 ****
  
      if ((arg[1].arg_type == A_SINGLE || arg->arg_type == O_AELEM) &&
          (arg->arg_len == 1 || arg[2].arg_type == A_SINGLE) ) {
! 	str = str_new(0);
  	s1 = arg[1].arg_ptr.arg_str;
  	if (arg->arg_len > 1)
  	    s2 = arg[2].arg_ptr.arg_str;
--- 273,279 ----
  
      if ((arg[1].arg_type == A_SINGLE || arg->arg_type == O_AELEM) &&
          (arg->arg_len == 1 || arg[2].arg_type == A_SINGLE) ) {
! 	str = Str_new(20,0);
  	s1 = arg[1].arg_ptr.arg_str;
  	if (arg->arg_len > 1)
  	    s2 = arg[2].arg_ptr.arg_str;
***************
*** 687,693 ****
  	    Renewc(arg1->arg_ptr.arg_str, 1, struct lstring, STR);
  			/* grow string struct to hold an lstring struct */
  	}
! 	else if (arg1->arg_type != O_ASSIGN) {
  	    (void)sprintf(tokenbuf,
  	      "Illegal expression (%s) as lvalue",opname[arg1->arg_type]);
  	    yyerror(tokenbuf);
--- 687,697 ----
  	    Renewc(arg1->arg_ptr.arg_str, 1, struct lstring, STR);
  			/* grow string struct to hold an lstring struct */
  	}
! 	else if (arg1->arg_type == O_ASSIGN) {
! 	    if (arg->arg_type == O_CHOP)
! 		arg[1].arg_flags &= ~AF_ARYOK;	/* grandfather chop idiom */
! 	}
! 	else {
  	    (void)sprintf(tokenbuf,
  	      "Illegal expression (%s) as lvalue",opname[arg1->arg_type]);
  	    yyerror(tokenbuf);
***************
*** 747,753 ****
      ARG *tmparg;
  
      if (arg[i].arg_type != A_EXPR) {	/* dehoist */
! 	tmparg = make_op(O_ITEM,1,Nullarg,Nullarg,Nullarg,0);
  	tmparg[1] = arg[i];
  	arg[i].arg_ptr.arg_arg = tmparg;
  	arg[i].arg_type = A_EXPR;
--- 751,757 ----
      ARG *tmparg;
  
      if (arg[i].arg_type != A_EXPR) {	/* dehoist */
! 	tmparg = make_op(O_ITEM,1,Nullarg,Nullarg,Nullarg);
  	tmparg[1] = arg[i];
  	arg[i].arg_ptr.arg_arg = tmparg;
  	arg[i].arg_type = A_EXPR;
***************
*** 767,773 ****
  ARG *arg;
  {
      if (arg->arg_type == O_ARRAY || arg->arg_type == O_HASH)
! 	return make_op(O_ITEM,1,arg,Nullarg,Nullarg,0);
      return arg;
  }
  
--- 771,777 ----
  ARG *arg;
  {
      if (arg->arg_type == O_ARRAY || arg->arg_type == O_HASH)
! 	return make_op(O_ITEM,1,arg,Nullarg,Nullarg);
      return arg;
  }
  
***************
*** 782,788 ****
  	arg = make_op(O_JOIN, 2,
  	    stab2arg(A_STAB,stabent(";",TRUE)),
  	    make_list(arg),
! 	    Nullarg, 0);
      }
      return arg;
  }
--- 786,792 ----
  	arg = make_op(O_JOIN, 2,
  	    stab2arg(A_STAB,stabent(";",TRUE)),
  	    make_list(arg),
! 	    Nullarg);
      }
      return arg;
  }
***************
*** 861,867 ****
  ARG *arg;
  {
      if (arg->arg_flags & AF_LISTISH)
! 	arg = make_op(O_LIST,1,arg,Nullarg,Nullarg,0);
      return arg;
  }
  
--- 865,871 ----
  ARG *arg;
  {
      if (arg->arg_flags & AF_LISTISH)
! 	arg = make_op(O_LIST,1,arg,Nullarg,Nullarg);
      return arg;
  }
  
***************
*** 946,952 ****
      register ARG *arg;
  
      Newz(203,arg, numargs + 1, ARG);
!     arg->arg_ptr.arg_str = str_new(0);
      arg->arg_len = numargs;
      return arg;
  }
--- 950,956 ----
      register ARG *arg;
  
      Newz(203,arg, numargs + 1, ARG);
!     arg->arg_ptr.arg_str = Str_new(21,0);
      arg->arg_len = numargs;
      return arg;
  }
***************
*** 967,973 ****
  {
      register ARG *arg;
  
!     arg = make_op(type,2,expr,Nullarg,Nullarg,0);
  
      arg[2].arg_type = A_SPAT|A_DONT;
      arg[2].arg_ptr.arg_spat = spat;
--- 971,977 ----
  {
      register ARG *arg;
  
!     arg = make_op(type,2,expr,Nullarg,Nullarg);
  
      arg[2].arg_type = A_SPAT|A_DONT;
      arg[2].arg_ptr.arg_spat = spat;
diff -c -r beta/doarg.c gamma/doarg.c
*** beta/doarg.c	Fri Sep 15 16:06:31 1989
--- gamma/doarg.c	Fri Sep 15 16:10:55 1989
***************
*** 214,220 ****
      if (regexec(spat->spat_regexp, s, strend, orig, 1,
        str->str_pok & SP_STUDIED ? str : Nullstr, safebase)) {
      long_way:
! 	dstr = str_new(str_len(str));
  	str_nset(dstr,m,s-m);
  	if (spat->spat_regexp->subbase)
  	    curspat = spat;
--- 214,220 ----
      if (regexec(spat->spat_regexp, s, strend, orig, 1,
        str->str_pok & SP_STUDIED ? str : Nullstr, safebase)) {
      long_way:
! 	dstr = Str_new(25,str_len(str));
  	str_nset(dstr,m,s-m);
  	if (spat->spat_regexp->subbase)
  	    curspat = spat;
***************
*** 392,398 ****
  	case 'c':
  	    while (len-- > 0) {
  		fromstr = NEXTFROM;
! 		achar = (char)str_gnum(fromstr);
  		str_ncat(str,&achar,sizeof(char));
  	    }
  	    break;
--- 392,399 ----
  	case 'c':
  	    while (len-- > 0) {
  		fromstr = NEXTFROM;
! 		aint = (int)str_gnum(fromstr);
! 		achar = aint;
  		str_ncat(str,&achar,sizeof(char));
  	    }
  	    break;
***************
*** 563,569 ****
      register STR *str = &str_undef;
  
      for (st += ++sp; items > 0; items--,st++) {
! 	str = str_new(0);
  	if (*st)
  	    str_sset(str,*st);
  	(void)apush(ary,str);
--- 564,570 ----
      register STR *str = &str_undef;
  
      for (st += ++sp; items > 0; items--,st++) {
! 	str = Str_new(26,0);
  	if (*st)
  	    str_sset(str,*st);
  	(void)apush(ary,str);
***************
*** 585,591 ****
      aunshift(ary,items);
      i = 0;
      for (st += ++sp; i < items; i++,st++) {
! 	str = str_new(0);
  	str_sset(str,*st);
  	(void)astore(ary,i,str);
      }
--- 586,592 ----
      aunshift(ary,items);
      i = 0;
      for (st += ++sp; i < items; i++,st++) {
! 	str = Str_new(27,0);
  	str_sset(str,*st);
  	(void)astore(ary,i,str);
      }
***************
*** 645,651 ****
      st = stack->ary_array;
  
      if ((arg[2].arg_type & A_MASK) != A_NULL) {
! 	Safefree(stab_xarray(defstab));  /* put back old $_[] */
  	stab_xarray(defstab) = savearray;
      }
      filename = oldfile;
--- 646,652 ----
      st = stack->ary_array;
  
      if ((arg[2].arg_type & A_MASK) != A_NULL) {
! 	afree(stab_xarray(defstab));  /* put back old $_[] */
  	stab_xarray(defstab) = savearray;
      }
      filename = oldfile;
***************
*** 726,732 ****
      st = stack->ary_array;
  
      if ((arg[2].arg_type & A_MASK) != A_NULL) {
! 	Safefree(stab_xarray(defstab));  /* put back old $_[] */
  	stab_xarray(defstab) = savearray;
      }
      filename = oldfile;
--- 727,733 ----
      st = stack->ary_array;
  
      if ((arg[2].arg_type & A_MASK) != A_NULL) {
! 	afree(stab_xarray(defstab));  /* put back old $_[] */
  	stab_xarray(defstab) = savearray;
      }
      filename = oldfile;
***************
*** 791,797 ****
  		}
  		i = 0;
  		while (relem <= lastrelem) {	/* gobble up all the rest */
! 		    str = str_new(0);
  		    if (*relem)
  			str_sset(str,*(relem++));
  		    else
--- 792,798 ----
  		}
  		i = 0;
  		while (relem <= lastrelem) {	/* gobble up all the rest */
! 		    str = Str_new(28,0);
  		    if (*relem)
  			str_sset(str,*(relem++));
  		    else
***************
*** 815,821 ****
  		    else
  			str = &str_no, relem++;
  		    tmps = str_get(str);
! 		    tmpstr = str_new(0);
  		    if (*relem)
  			str_sset(tmpstr,*(relem++));	/* value */
  		    else
--- 816,822 ----
  		    else
  			str = &str_no, relem++;
  		    tmps = str_get(str);
! 		    tmpstr = Str_new(29,0);
  		    if (*relem)
  			str_sset(tmpstr,*(relem++));	/* value */
  		    else
***************
*** 1072,1078 ****
  	size = offset & 7;
  	lval &= mask;
  	offset >>= 3;
! 	s[offset] &= mask << size;
  	s[offset] |= lval << size;
      }
      else {
--- 1073,1079 ----
  	size = offset & 7;
  	lval &= mask;
  	offset >>= 3;
! 	s[offset] &= ~(mask << size);
  	s[offset] |= lval << size;
      }
      else {
***************
*** 1168,1171 ****
--- 1169,1246 ----
  	break;
      }
  }
+ 
+ int
+ do_syscall(arglast)
+ int *arglast;
+ {
+     register STR **st = stack->ary_array;
+     register int sp = arglast[1];
+     register int items = arglast[2] - sp;
+     long arg[8];
+     register int i = 0;
+     int retval = -1;
+ 
+ #ifdef SYSCALL
+ #ifdef TAINT
+     for (st += ++sp; items--; st++)
+ 	tainted |= (*st)->str_tainted;
+     st = stack->ary_array;
+     sp = arglast[1];
+     items = arglast[2] - sp;
+ #endif
+ #ifdef TAINT
+     taintproper("Insecure dependency in syscall");
+ #endif
+     /* This probably won't work on machines where sizeof(long) != sizeof(int)
+      * or where sizeof(long) != sizeof(char*).  But such machines will
+      * not likely have syscall implemented either, so who cares?
+      */
+     while (items--) {
+ 	if (st[++sp]->str_nok || !i)
+ 	    arg[i++] = (long)str_gnum(st[sp]);
+ #ifndef lint
+ 	else
+ 	    arg[i++] = (long)st[sp]->str_ptr;
+ #endif /* lint */
+     }
+     sp = arglast[1];
+     items = arglast[2] - sp;
+     switch (items) {
+     case 0:
+ 	fatal("Too few args to syscall");
+     case 1:
+ 	retval = syscall(arg[0]);
+ 	break;
+     case 2:
+ 	retval = syscall(arg[0],arg[1]);
+ 	break;
+     case 3:
+ 	retval = syscall(arg[0],arg[1],arg[2]);
+ 	break;
+     case 4:
+ 	retval = syscall(arg[0],arg[1],arg[2],arg[3]);
+ 	break;
+     case 5:
+ 	retval = syscall(arg[0],arg[1],arg[2],arg[3],arg[4]);
+ 	break;
+     case 6:
+ 	retval = syscall(arg[0],arg[1],arg[2],arg[3],arg[4],arg[5]);
+ 	break;
+     case 7:
+ 	retval = syscall(arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6]);
+ 	break;
+     case 8:
+ 	retval = syscall(arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6],
+ 	  arg[7]);
+ 	break;
+     }
+     st[sp] = str_static(&str_undef);
+     str_numset(st[sp], (double)retval);
+     return sp;
+ #else
+     fatal("syscall() unimplemented");
+ #endif
+ }
+ 
  
diff -c -r beta/doio.c gamma/doio.c
*** beta/doio.c	Fri Sep 15 16:06:09 1989
--- gamma/doio.c	Fri Sep 15 16:10:26 1989
***************
*** 17,22 ****
--- 17,28 ----
  #endif
  
  #include <errno.h>
+ #ifdef I_PWD
+ #include <pwd.h>
+ #endif
+ #ifdef I_GRP
+ #include <grp.h>
+ #endif
  
  extern int errno;
  
***************
*** 414,420 ****
      if (optype == O_IOCTL)
  	retval = ioctl(fileno(stio->ifp), func, s);
      else
! #ifdef FCNTL
  	retval = fcntl(fileno(stio->ifp), func, s);
  #else
  	fatal("fcntl is not implemented");
--- 420,426 ----
      if (optype == O_IOCTL)
  	retval = ioctl(fileno(stio->ifp), func, s);
      else
! #ifdef I_FCNTL
  	retval = fcntl(fileno(stio->ifp), func, s);
  #else
  	fatal("fcntl is not implemented");
***************
*** 457,465 ****
--- 463,473 ----
      else {
  	str_sset(statname,ary->ary_array[sp]);
  	statstab = Nullstab;
+ #ifdef SYMLINK
  	if (arg->arg_type == O_LSTAT)
  	    i = lstat(str_get(statname),&statcache);
  	else
+ #endif
  	    i = stat(str_get(statname),&statcache);
  	if (i < 0)
  	    max = 0;
***************
*** 477,499 ****
      sp--;
      if (max) {
  #ifndef lint
! 	(void)astore(ary,++sp,str_nmake((double)statcache.st_dev));
! 	(void)astore(ary,++sp,str_nmake((double)statcache.st_ino));
! 	(void)astore(ary,++sp,str_nmake((double)statcache.st_mode));
! 	(void)astore(ary,++sp,str_nmake((double)statcache.st_nlink));
! 	(void)astore(ary,++sp,str_nmake((double)statcache.st_uid));
! 	(void)astore(ary,++sp,str_nmake((double)statcache.st_gid));
! 	(void)astore(ary,++sp,str_nmake((double)statcache.st_rdev));
! 	(void)astore(ary,++sp,str_nmake((double)statcache.st_size));
! 	(void)astore(ary,++sp,str_nmake((double)statcache.st_atime));
! 	(void)astore(ary,++sp,str_nmake((double)statcache.st_mtime));
! 	(void)astore(ary,++sp,str_nmake((double)statcache.st_ctime));
  #ifdef STATBLOCKS
! 	(void)astore(ary,++sp,str_nmake((double)statcache.st_blksize));
! 	(void)astore(ary,++sp,str_nmake((double)statcache.st_blocks));
  #else
! 	(void)astore(ary,++sp,str_make("",0));
! 	(void)astore(ary,++sp,str_make("",0));
  #endif
  #else /* lint */
  	(void)astore(ary,++sp,str_nmake(0.0));
--- 485,522 ----
      sp--;
      if (max) {
  #ifndef lint
! 	(void)astore(ary,++sp,
! 	  str_2static(str_nmake((double)statcache.st_dev)));
! 	(void)astore(ary,++sp,
! 	  str_2static(str_nmake((double)statcache.st_ino)));
! 	(void)astore(ary,++sp,
! 	  str_2static(str_nmake((double)statcache.st_mode)));
! 	(void)astore(ary,++sp,
! 	  str_2static(str_nmake((double)statcache.st_nlink)));
! 	(void)astore(ary,++sp,
! 	  str_2static(str_nmake((double)statcache.st_uid)));
! 	(void)astore(ary,++sp,
! 	  str_2static(str_nmake((double)statcache.st_gid)));
! 	(void)astore(ary,++sp,
! 	  str_2static(str_nmake((double)statcache.st_rdev)));
! 	(void)astore(ary,++sp,
! 	  str_2static(str_nmake((double)statcache.st_size)));
! 	(void)astore(ary,++sp,
! 	  str_2static(str_nmake((double)statcache.st_atime)));
! 	(void)astore(ary,++sp,
! 	  str_2static(str_nmake((double)statcache.st_mtime)));
! 	(void)astore(ary,++sp,
! 	  str_2static(str_nmake((double)statcache.st_ctime)));
  #ifdef STATBLOCKS
! 	(void)astore(ary,++sp,
! 	  str_2static(str_nmake((double)statcache.st_blksize)));
! 	(void)astore(ary,++sp,
! 	  str_2static(str_nmake((double)statcache.st_blocks)));
  #else
! 	(void)astore(ary,++sp,
! 	  str_2static(str_make("",0)));
! 	(void)astore(ary,++sp,
! 	  str_2static(str_make("",0)));
  #endif
  #else /* lint */
  	(void)astore(ary,++sp,str_nmake(0.0));
***************
*** 1001,1006 ****
--- 1024,1146 ----
  }
  
  int
+ do_shutdown(stab, arglast)
+ STAB *stab;
+ int *arglast;
+ {
+     register STR **st = stack->ary_array;
+     register int sp = arglast[1];
+     register STIO *stio;
+     int how;
+ 
+     if (!stab)
+ 	goto nuts;
+ 
+     stio = stab_io(stab);
+     if (!stio || !stio->ifp)
+ 	goto nuts;
+ 
+     how = (int)str_gnum(st[++sp]);
+     return shutdown(fileno(stio->ifp), how) >= 0;
+ 
+ nuts:
+     if (dowarn)
+ 	warn("shutdown() on closed fd");
+     return FALSE;
+ 
+ }
+ 
+ int
+ do_sopt(optype, stab, arglast)
+ int optype;
+ STAB *stab;
+ int *arglast;
+ {
+     register STR **st = stack->ary_array;
+     register int sp = arglast[1];
+     register STIO *stio;
+     int fd;
+     int lvl;
+     int optname;
+ 
+     if (!stab)
+ 	goto nuts;
+ 
+     stio = stab_io(stab);
+     if (!stio || !stio->ifp)
+ 	goto nuts;
+ 
+     fd = fileno(stio->ifp);
+     lvl = (int)str_gnum(st[sp+1]);
+     optname = (int)str_gnum(st[sp+2]);
+     switch (optype) {
+     case O_GSOCKOPT:
+ 	st[sp] = str_2static(str_new(257));
+ 	st[sp]->str_cur = 256;
+ 	if (getsockopt(fd, lvl, optname, st[sp]->str_ptr, &st[sp]->str_cur) < 0)
+ 	    goto nuts;
+ 	break;
+     case O_SSOCKOPT:
+ 	st[sp] = st[sp+3];
+ 	if (setsockopt(fd, lvl, optname, st[sp]->str_ptr, st[sp]->str_cur) < 0)
+ 	    goto nuts;
+ 	st[sp] = &str_yes;
+ 	break;
+     }
+     
+     return sp;
+ 
+ nuts:
+     if (dowarn)
+ 	warn("shutdown() on closed fd");
+     st[sp] = &str_undef;
+     return sp;
+ 
+ }
+ 
+ int
+ do_getsockname(optype, stab, arglast)
+ int optype;
+ STAB *stab;
+ int *arglast;
+ {
+     register STR **st = stack->ary_array;
+     register int sp = arglast[1];
+     register STIO *stio;
+     int fd;
+ 
+     if (!stab)
+ 	goto nuts;
+ 
+     stio = stab_io(stab);
+     if (!stio || !stio->ifp)
+ 	goto nuts;
+ 
+     st[sp] = str_2static(str_new(257));
+     st[sp]->str_cur = 256;
+     fd = fileno(stio->ifp);
+     switch (optype) {
+     case O_GETSOCKNAME:
+ 	if (getsockname(fd, st[sp]->str_ptr, &st[sp]->str_cur) < 0)
+ 	    goto nuts;
+ 	break;
+     case O_GETPEERNAME:
+ 	if (getpeername(fd, st[sp]->str_ptr, &st[sp]->str_cur) < 0)
+ 	    goto nuts;
+ 	break;
+     }
+     
+     return sp;
+ 
+ nuts:
+     if (dowarn)
+ 	warn("shutdown() on closed fd");
+     st[sp] = &str_undef;
+     return sp;
+ 
+ }
+ 
+ int
  do_ghent(which,gimme,arglast)
  int which;
  int gimme;
***************
*** 1010,1016 ****
      register int sp = arglast[0];
      register char **elem;
      register STR *str;
!     struct hostent *gethostbynumber();
      struct hostent *hent;
      unsigned long len;
  
--- 1150,1160 ----
      register int sp = arglast[0];
      register char **elem;
      register STR *str;
!     struct hostent *gethostbynam();
!     struct hostent *gethostbyaddr();
! #ifdef GETHOSTENT
!     struct hostent *gethostent();
! #endif
      struct hostent *hent;
      unsigned long len;
  
***************
*** 1032,1038 ****
--- 1176,1186 ----
  	hent = gethostbyaddr(addr,addrstr->str_cur,addrtype);
      }
      else
+ #ifdef GETHOSTENT
  	hent = gethostent();
+ #else
+ 	fatal("gethostent not implemented");
+ #endif
      if (hent) {
  #ifndef lint
  	(void)astore(ary, ++sp, str = str_static(&str_no));
***************
*** 1229,1235 ****
--- 1377,1387 ----
  		str_ncat(str," ",1);
  	}
  	(void)astore(ary, ++sp, str = str_static(&str_no));
+ #ifdef NTOHS
  	str_numset(str, (double)ntohs(sent->s_port));
+ #else
+ 	str_numset(str, (double)(sent->s_port));
+ #endif
  	(void)astore(ary, ++sp, str = str_static(&str_no));
  	str_set(str, sent->s_proto);
  #else /* lint */
***************
*** 1242,1250 ****
      return sp;
  }
  
- 
- #ifdef SOCKET
- 
  int
  do_select(gimme,arglast)
  int gimme;
--- 1394,1399 ----
***************
*** 1313,1319 ****
      }
      return sp;
  }
- #endif
  
  int
  do_spair(stab1, stab2, arglast)
--- 1462,1467 ----
***************
*** 1347,1354 ****
--- 1495,1506 ----
  #ifdef TAINT
      taintproper("Insecure dependency in socketpair");
  #endif
+ #ifdef SOCKETPAIR
      if (socketpair(domain,type,protocol,fd) < 0)
  	return FALSE;
+ #else
+     fatal("Socketpair unimplemented");
+ #endif
      stio1->ifp = fdopen(fd[0], "r");
      stio1->ofp = fdopen(fd[0], "w");
      stio1->type = 's';
***************
*** 1361,1366 ****
--- 1513,1724 ----
  
  #endif /* SOCKET */
  
+ int
+ do_gpwent(which,gimme,arglast)
+ int which;
+ int gimme;
+ int *arglast;
+ {
+ #ifdef I_PWD
+     register ARRAY *ary = stack;
+     register int sp = arglast[0];
+     register char **elem;
+     register STR *str;
+     struct passwd *getpwnam();
+     struct passwd *getpwuid();
+     struct passwd *getpwent();
+     struct passwd *pwent;
+     unsigned long len;
+ 
+     if (gimme != G_ARRAY) {
+ 	astore(ary, ++sp, str_static(&str_undef));
+ 	return sp;
+     }
+ 
+     if (which == O_GPWNAM) {
+ 	char *name = str_get(ary->ary_array[sp+1]);
+ 
+ 	pwent = getpwnam(name);
+     }
+     else if (which == O_GPWUID) {
+ 	int uid = (int)str_gnum(ary->ary_array[sp+1]);
+ 
+ 	pwent = getpwuid(uid);
+     }
+     else
+ 	pwent = getpwent();
+ 
+     if (pwent) {
+ 	(void)astore(ary, ++sp, str = str_static(&str_no));
+ 	str_set(str, pwent->pw_name);
+ 	(void)astore(ary, ++sp, str = str_static(&str_no));
+ 	str_set(str, pwent->pw_passwd);
+ 	(void)astore(ary, ++sp, str = str_static(&str_no));
+ 	str_numset(str, (double)pwent->pw_uid);
+ 	(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 PWQUOTA
+ 	str_numset(str, (double)pwent->pw_quota);
+ #else
+ #ifdef PWAGE
+ 	str_numset(str, (double)pwent->pw_age);
+ #endif
+ #endif
+ 	(void)astore(ary, ++sp, str = str_static(&str_no));
+ 	str_set(str, pwent->pw_comment);
+ 	(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);
+     }
+ 
+     return sp;
+ #else
+     fatal("password routines not implemented");
+ #endif
+ }
+ 
+ int
+ do_ggrent(which,gimme,arglast)
+ int which;
+ int gimme;
+ int *arglast;
+ {
+ #ifdef I_GRP
+     register ARRAY *ary = stack;
+     register int sp = arglast[0];
+     register char **elem;
+     register STR *str;
+     struct group *getgrnam();
+     struct group *getgrgid();
+     struct group *getgrent();
+     struct group *grent;
+     unsigned long len;
+ 
+     if (gimme != G_ARRAY) {
+ 	astore(ary, ++sp, str_static(&str_undef));
+ 	return sp;
+     }
+ 
+     if (which == O_GGRNAM) {
+ 	char *name = str_get(ary->ary_array[sp+1]);
+ 
+ 	grent = getgrnam(name);
+     }
+     else if (which == O_GGRGID) {
+ 	int gid = (int)str_gnum(ary->ary_array[sp+1]);
+ 
+ 	grent = getgrgid(gid);
+     }
+     else
+ 	grent = getgrent();
+ 
+     if (grent) {
+ 	(void)astore(ary, ++sp, str = str_static(&str_no));
+ 	str_set(str, grent->gr_name);
+ 	(void)astore(ary, ++sp, str = str_static(&str_no));
+ 	str_set(str, grent->gr_passwd);
+ 	(void)astore(ary, ++sp, str = str_static(&str_no));
+ 	str_numset(str, (double)grent->gr_gid);
+ 	(void)astore(ary, ++sp, str = str_static(&str_no));
+ 	for (elem = grent->gr_mem; *elem; elem++) {
+ 	    str_cat(str, *elem);
+ 	    if (elem[1])
+ 		str_ncat(str," ",1);
+ 	}
+     }
+ 
+     return sp;
+ #else
+     fatal("group routines not implemented");
+ #endif
+ }
+ 
+ int
+ do_dirop(optype,stab,gimme,arglast)
+ int optype;
+ STAB *stab;
+ int gimme;
+ int *arglast;
+ {
+ #ifdef DIRENT
+     register STR **st = stack->ary_array;
+     register int sp = arglast[1];
+     register STIO *stio;
+     long along;
+     long telldir();
+     struct DIRENT *readdir();
+     register struct DIRENT *dp;
+ 
+     if (!stab)
+ 	goto nope;
+     if (!(stio = stab_io(stab)))
+ 	stio = stab_io(stab) = stio_new();
+     if (!stio->dirp && optype != O_OPENDIR)
+ 	goto nope;
+     st[sp] = &str_yes;
+     switch (optype) {
+     case O_OPENDIR:
+ 	if (stio->dirp)
+ 	    closedir(stio->dirp);
+ 	if (!(stio->dirp = opendir(str_get(st[sp+1]))))
+ 	    goto nope;
+ 	break;
+     case O_READDIR:
+ 	if (gimme == G_ARRAY) {
+ 	    --sp;
+ 	    while (dp = readdir(stio->dirp)) {
+ 		st[++sp] = str_static(&str_undef);
+ #ifdef DIRNAMLEN
+ 		str_nset(st[sp], dp->d_name, dp->d_namlen);
+ #else
+ 		str_set(st[sp], dp->d_name);
+ #endif
+ 	    }
+ 	}
+ 	else {
+ 	    if (!(dp = readdir(stio->dirp)))
+ 		goto nope;
+ 	    st[sp] = str_static(&str_undef);
+ #ifdef DIRNAMLEN
+ 	    str_nset(st[sp], dp->d_name, dp->d_namlen);
+ #else
+ 	    str_set(st[sp], dp->d_name);
+ #endif
+ 	}
+ 	break;
+     case O_TELLDIR:
+ 	st[sp] = str_static(&str_undef);
+ 	str_numset(st[sp], (double)telldir(stio->dirp));
+ 	break;
+     case O_SEEKDIR:
+ 	st[sp] = str_static(&str_undef);
+ 	along = (long)str_gnum(st[sp+1]);
+ 	(void)seekdir(stio->dirp,along);
+ 	break;
+     case O_REWINDDIR:
+ 	st[sp] = str_static(&str_undef);
+ 	(void)rewinddir(stio->dirp);
+ 	break;
+     case O_CLOSEDIR:
+ 	st[sp] = str_static(&str_undef);
+ 	(void)closedir(stio->dirp);
+ 	break;
+     }
+     return sp;
+ 
+ nope:
+     st[sp] = &str_undef;
+     return sp;
+ 
+ #else
+     fatal("Unimplemented directory operation");
+ #endif
+ }
+ 
  apply(type,arglast)
  int type;
  int *arglast;
***************
*** 1421,1430 ****
  	    if (val < 0) {
  		val = -val;
  		while (items--) {
  #ifdef KILLPG
! 		    if (killpg((int)(str_gnum(st[++sp])),val))	/* BSD */
  #else
! 		    if (kill(-(int)(str_gnum(st[++sp])),val))	/* SYSV */
  #endif
  			tot--;
  		}
--- 1779,1789 ----
  	    if (val < 0) {
  		val = -val;
  		while (items--) {
+ 		    int proc = (int)str_gnum(st[++sp]);
  #ifdef KILLPG
! 		    if (killpg(proc,val))	/* BSD */
  #else
! 		    if (kill(-proc,val))	/* SYSV */
  #endif
  			tot--;
  		}