[alt.sources.patches] PD KSH 3.2 alpha - update-2/2

sjg@zen.void.oz.au (Simon J. Gerraty) (04/25/91)

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  src/ChangeLog stdc/ChangeLog sun386i.diffs bugs.diffs
# Wrapped by sjg@zen on Thu Apr 25 18:06:47 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f src/ChangeLog -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"src/ChangeLog\"
else
echo shar: Extracting \"src/ChangeLog\" \(2179 characters\)
sed "s/^X//" >src/ChangeLog <<'END_OF_src/ChangeLog'
XThu Apr 25 14:30:21 1991  Simon J. Gerraty  (sjg at zen.void.oz.au)
X
X	* x_prev_histword(edit.c):
X
X	Now ignores white-space at start and end of line when counting
X	words. 
X
X	* x_fold_case(edit.c):
X
X	This function implements M-[ulc] for upper/lower casing and
X	capitalizing words in place prefix with M-"digit" to handle
X	multiple words.
X
X	* x_delete(edit.c):
X
X	Now does an x_push whenever called to delete more than
X	one char.  This allows delete-word followed by yank.
X
XWed Apr 24 14:29:51 1991  Simon J. Gerraty  (sjg at zen.void.oz.au)
X
X	* x_delete(edit.c):
X
X	Similar problem to x_ins.  Also it made the assumption that the
X	entire edit line would be on-screen.  This is now fixed.  edit.c
X	could probably stand a re-write at this point :-)
X
X	* x_ins(edit.c):
X
X	x_adjust was being called in the middle of x_ins with xcp not set
X	correctly.  Now avoids x_adjust if possible, and ensures xcp is
X	correct.  
X
XSat Apr 20 16:30:16 1991  Simon J. Gerraty  (sjg at zen.void.oz.au)
X
X	* edit.c:
X
X	The "improved" isfs() macro had broken the file/command
X	completeion code.  The original marco is re-instated as ISFS() and
X	all is well!
X
XFri Mar 22 16:50:14 1991  Simon J. Gerraty  (sjg at sun0.melb.bull.oz.au)
X
X	* edit.c:
X
X	Added x_set_arg() and x_prev_histword().
X	x_set_arg() handles 'ESC''0-9' type args which are used by word
X	related commands.
X	x_prev_histword() recovers the last (default) or sepcified arg
X	word from the previous command line.  Bound to ESC. and ESC_ to be
X	compatible with real ksh.
X
XTue Feb 26 14:16:17 1991 Simon J. Gerraty  (sjg at zen.void.oz.au)
X
X	* edit.c:
X
X	Changes to handle editing of command lines longer than $COLUMNS in
X	a manner compatible with real ksh.
X
XMon Feb 25 12:20:36 1991 Simon J. Gerraty  (sjg at sun0.melb.bull.oz.au)
X
X	* var.c,table.h:
X
X	Implemented $RANDOM
X	Some scripts use [ "$RANDOM" != "$RANDOM" ] to check for ksh. 
X
XWed Feb 20 12:20:36 1991 Simon J. Gerraty  (sjg at sun0.melb.bull.oz.au)
X
X	Changes so that shell will compile on sun386i.
X
X	* exec.c,main.c,io.c:
X
X	Handle the case where FD_CLEXEC isn't defined.
X
X	* jobs.c:
X
X	SunOS has its own ideas about job status etc.
X
X	* tree.c:
X
X	Fixed conflict between varargs and stdarg.
X
END_OF_src/ChangeLog
if test 2179 -ne `wc -c <src/ChangeLog`; then
    echo shar: \"src/ChangeLog\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f stdc/ChangeLog -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"stdc/ChangeLog\"
else
echo shar: Extracting \"stdc/ChangeLog\" \(304 characters\)
sed "s/^X//" >stdc/ChangeLog <<'END_OF_stdc/ChangeLog'
XThu Feb 21 13:55:57 1991 Simon J. Gerraty  (sjg at sun0.melb.bull.oz.au)
X
X	* vprintf.c:
X
X	Fixed bug in vfprintf() that casued output to be paded with SPACEs
X	when '0' was requested - caused ksh's temp files to contain
X	spaces!
X
X
X	* stdio.h_std:
X
X	Fixed args for vprintf family so that gcc wouldn't puke.
END_OF_stdc/ChangeLog
if test 304 -ne `wc -c <stdc/ChangeLog`; then
    echo shar: \"stdc/ChangeLog\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f sun386i.diffs -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"sun386i.diffs\"
else
echo shar: Extracting \"sun386i.diffs\" \(11418 characters\)
sed "s/^X//" >sun386i.diffs <<'END_OF_sun386i.diffs'
XPD KSH 3.2 alpha patches [sun386i.diffs]
X
XThe patches contained below were found necessary to build the 
XPD KSH (posted to alt.sources in Dec 90) using gcc-1.39 on a
Xsun386i users of other systems can probably ignore them.
X
XThese patches can be installed using the following command
Xin the top level directory of the pdksh source tree:
X
Xpatch -p0 <this-article
X
X*** /tmp/pdksh/stdc/stddef.h	Thu Apr 25 15:05:45 1991
X--- ./stdc/stddef.h	Wed Feb 20 14:32:45 1991
X***************
X*** 24,35 ****
X  #define	Const
X  #endif
X  
X! typedef unsigned size_t;		/* may need long */
X! typedef int ptrdiff_t;
X  
X  #define	offsetof(type,id) ((size_t)&((type*)NULL)->id)
X  
X  extern	int errno;		/* really belongs in <errno.h> */
X- 
X  #endif
X  
X--- 24,37 ----
X  #define	Const
X  #endif
X  
X! #ifndef _SIZE_T
X! # define _SIZE_T
X! typedef unsigned long size_t;		/* may need long */
X! typedef long ptrdiff_t;
X! #endif /* _SIZE_T */
X  
X  #define	offsetof(type,id) ((size_t)&((type*)NULL)->id)
X  
X  extern	int errno;		/* really belongs in <errno.h> */
X  #endif
X  
X*** /tmp/pdksh/stdc/setvbuf.c	Thu Apr 25 15:05:52 1991
X--- ./stdc/setvbuf.c	Wed Feb 20 13:24:05 1991
X***************
X*** 15,21 ****
X--- 15,25 ----
X  int
X  setvbuf(f, buf, type, size)
X  	register FILE *f;
X+ #ifdef sun
X+   	unsigned char *buf;
X+ #else
X  	char *buf;
X+ #endif
X  	int type;
X  	size_t size;
X  {
X*** /tmp/pdksh/stdc/stdio.h_std	Thu Apr 25 15:05:48 1991
X--- stdc/stdio.h_std	Thu Feb 21 13:35:24 1991
X***************
X*** 54,62 ****
X--- 54,69 ----
X  _EXTERN	int	fprintf ARGS((FILE *f, const char *fmt, ...));
X  _EXTERN	int	sprintf ARGS((char *s, const char *fmt, ...));
X  /* we do not include <stdarg.h> to prevent <varargs.h> conflicts */
X+ #ifdef __STDC__
X+ # include <stdarg.h>
X+ _EXTERN	int	vprintf ARGS((const char *fmt, va_list va));
X+ _EXTERN	int	vfprintf ARGS((FILE *f, const char *fmt, va_list va));
X+ _EXTERN	int	vsprintf ARGS((char *s, const char *fmt, va_list va));
X+ #else
X  _EXTERN	int	vprintf ARGS((const char *fmt, Void *va));
X  _EXTERN	int	vfprintf ARGS((FILE *f, const char *fmt, Void *va));
X  _EXTERN	int	vsprintf ARGS((char *s, const char *fmt, Void *va));
X+ #endif
X  _EXTERN	int	scanf ARGS((const char *fmt, ...));
X  _EXTERN	int	fscanf ARGS((FILE *f, const char *fmt, ...));
X  _EXTERN	int	sscanf ARGS((const char *s, const char *fmt, ...));
X*** /tmp/pdksh/stdc/Makefile	Thu Apr 25 15:05:44 1991
X--- stdc/Makefile	Thu Feb 28 10:04:38 1991
X***************
X*** 4,14 ****
X  # $Header: Makefile,v 1.1 88/03/29 18:28:38 egisin Locked $
X  
X  SYSTEM=BSD
X! CC = gcc -ansi -O -W 
X  LN = ln
X  PRINT = lpr -p -Plp26_3018
X  
X! CFLAGS = -I../h -D_$(SYSTEM)
X  
X  MISC =	Makefile stdio.h_std
X  HDRS =	limits.h stddef.h stdlib.h string.h time.h stdarg.h 
X--- 4,14 ----
X  # $Header: Makefile,v 1.1 88/03/29 18:28:38 egisin Locked $
X  
X  SYSTEM=BSD
X! CC = gcc -ansi -W 
X  LN = ln
X  PRINT = lpr -p -Plp26_3018
X  
X! CFLAGS = -I../h -D_$(SYSTEM) $(DBG)
X  
X  MISC =	Makefile stdio.h_std
X  HDRS =	limits.h stddef.h stdlib.h string.h time.h stdarg.h 
X*** /tmp/pdksh/posix/times.c	Thu Apr 25 15:05:39 1991
X--- ./posix/times.c	Wed Feb 20 14:01:32 1991
X***************
X*** 1,5 ****
X  /* P1003.1 times emulation */
X! 
X  #include <sys/times.h>
X  
X  #if _BSD
X--- 1,5 ----
X  /* P1003.1 times emulation */
X! #include <sys/types.h>
X  #include <sys/times.h>
X  
X  #if _BSD
X*** /tmp/pdksh/posix/Makefile	Thu Apr 25 15:05:34 1991
X--- posix/Makefile	Thu Feb 28 10:05:07 1991
X***************
X*** 4,14 ****
X  # $Header: Makefile,v 1.1 88/03/29 18:28:38 egisin Locked $
X  
X  SYSTEM=BSD
X! CC = gcc -ansi -O -W 
X  LN = ln
X  PRINT = lpr -p -Plp26_3018
X  
X! CFLAGS = -I../h -D_$(SYSTEM) 
X  
X  MISC =	Makefile 
X  HDRS =	wait.h times.h unistd.h fcntl.h dirent.h 
X--- 4,14 ----
X  # $Header: Makefile,v 1.1 88/03/29 18:28:38 egisin Locked $
X  
X  SYSTEM=BSD
X! CC = gcc -ansi -W 
X  LN = ln
X  PRINT = lpr -p -Plp26_3018
X  
X! CFLAGS = -I../h -D_$(SYSTEM) $(DBG)
X  
X  MISC =	Makefile 
X  HDRS =	wait.h times.h unistd.h fcntl.h dirent.h 
X*** /tmp/pdksh/src/main.c	Thu Apr 25 15:05:09 1991
X--- ./src/main.c	Wed Feb 20 14:08:28 1991
X***************
X*** 166,172 ****
X--- 166,174 ----
X  	}
X  	if (s->type == STTY) {
X  		ttyfd = fcntl(0, F_DUPFD, FDBASE);
X+ #ifdef FD_CLEXEC
X  		(void) fcntl(ttyfd, F_SETFD, FD_CLEXEC);
X+ #endif
X  #if EDIT
X  		x_init();
X  #endif
X*** /tmp/pdksh/src/io.c	Thu Apr 25 15:05:12 1991
X--- ./src/io.c	Thu Feb 21 10:33:07 1991
X***************
X*** 135,141 ****
X--- 135,143 ----
X  				return -1;
X  			else
X  				errorf("too many files open in shell\n");
X+ #ifdef FD_CLEXEC
X  		(void) fcntl(nfd, F_SETFD, FD_CLEXEC);
X+ #endif
X  		close(fd);
X  	} else
X  		nfd = fd;
X*** /tmp/pdksh/src/exec.c	Thu Apr 25 15:05:21 1991
X--- ./src/exec.c	Wed Feb 20 14:21:37 1991
X***************
X*** 174,180 ****
X  	  case TEXEC:		/* an eval'd TCOM */
X  		s = t->args[0];
X  		ap = makenv();
X! #if _MINIX				/* no F_SETFD close-on-exec */
X  		for (i = 10; i < 20; i++)
X  			close(i);
X  #endif
X--- 174,181 ----
X  	  case TEXEC:		/* an eval'd TCOM */
X  		s = t->args[0];
X  		ap = makenv();
X! /* #if _MINIX	*/			/* no F_SETFD close-on-exec */
X! #ifndef FD_CLEXEC
X  		for (i = 10; i < 20; i++)
X  			close(i);
X  #endif
X***************
X*** 324,330 ****
X  	struct op *t;
X  {
X  	register struct block *l;
X! 	register struct tbl *tp;
X  
X  	for (l = e.loc; l != NULL; l = l->next) {
X  		lastarea = &l->area;
X--- 325,331 ----
X  	struct op *t;
X  {
X  	register struct block *l;
X! 	register struct tbl *tp = NULL;
X  
X  	for (l = e.loc; l != NULL; l = l->next) {
X  		lastarea = &l->area;
X***************
X*** 337,353 ****
X  			tp->type = CFUNC;
X  		}
X  	}
X! 
X! 	if ((tp->flag&ALLOC))
X  		tfree(tp->val.t, lastarea);
X! 	tp->flag &= ~(ISSET|ALLOC);
X  
X! 	if (t == NULL)		/* undefine */
X  		return 0;
X  
X! 	tp->val.t = tcopy(t, lastarea);
X! 	tp->flag |= (ISSET|ALLOC);
X! 
X  	return 0;
X  }
X  
X--- 338,355 ----
X  			tp->type = CFUNC;
X  		}
X  	}
X! 	if (tp)
X! 	{
X! 	  if ((tp->flag&ALLOC))
X  		tfree(tp->val.t, lastarea);
X! 	  tp->flag &= ~(ISSET|ALLOC);
X  
X! 	  if (t == NULL)		/* undefine */
X  		return 0;
X  
X! 	  tp->val.t = tcopy(t, lastarea);
X! 	  tp->flag |= (ISSET|ALLOC);
X! 	}
X  	return 0;
X  }
X  
X*** /tmp/pdksh/src/jobs.c	Thu Apr 25 15:05:23 1991
X--- ./src/jobs.c	Thu Feb 21 10:53:10 1991
X***************
X*** 38,45 ****
X  #include "sh.h"
X  #include "tree.h"
X  
X  #ifndef WIFCORED
X! #define	WIFCORED(x)	(!!((x)&0x80)) /* non-standard */
X  #endif
X  
X  /* as of P1003.1 Draft 12.3:
X--- 38,54 ----
X  #include "sh.h"
X  #include "tree.h"
X  
X+ #ifdef sun
X+ # define WTERMSIG(x)	(x.w_termsig)
X+ # define WIFCORED(x)	(x.w_coredump)
X+ # define WEXITSTATUS(x)	(x.w_retcode)
X+ # define WSTOPVAL(x)	(x.w_stopval)
X+ # define WSTOPSIG(x)	(x.w_stopsig)
X+ # define waitpid(pid, sp, opts) wait3((sp), (opts), (Void*)NULL)
X+ #endif
X+ 
X  #ifndef WIFCORED
X! # define	WIFCORED(x)	(!!((x)&0x80)) /* non-standard */
X  #endif
X  
X  /* as of P1003.1 Draft 12.3:
X***************
X*** 62,82 ****
X  #ifndef	SIGCHLD
X  #define	SIGCHLD	SIGCLD
X  #endif
X! 
X! typedef struct Proc Proc;
X! struct Proc {
X! 	Proc   *next;		/* `procs' list link */
X  	int	job;		/* job number: %n */
X  	short	Volatile state;	/* proc state */
X  	short	Volatile notify; /* proc state has changed */
X! 	Proc   *prev;		/* prev member of pipeline */
X  	pid_t	proc;		/* process id */
X  	pid_t	pgrp;		/* process group if flag[FMONITOR] */
X  	short	flags;		/* execute flags */
X  	int	status;		/* wait status */
X  	clock_t	utime, stime;	/* user/system time when JDONE */
X  	char	com [48];	/* command */
X! };
X  
X  /* proc states */
X  #define	JFREE	0		/* unused proc */
X--- 71,97 ----
X  #ifndef	SIGCHLD
X  #define	SIGCHLD	SIGCLD
X  #endif
X! #ifdef sun
X! typedef int pid_t;
X! #endif
X! /* typedef struct Proc Proc; */
X! typedef struct Proc {
X! 	struct Proc   *next;		/* `procs' list link */
X  	int	job;		/* job number: %n */
X  	short	Volatile state;	/* proc state */
X  	short	Volatile notify; /* proc state has changed */
X! 	struct Proc   *prev;		/* prev member of pipeline */
X  	pid_t	proc;		/* process id */
X  	pid_t	pgrp;		/* process group if flag[FMONITOR] */
X  	short	flags;		/* execute flags */
X+ #ifdef sun
X+ 	union wait status;
X+ #else
X  	int	status;		/* wait status */
X+ #endif
X  	clock_t	utime, stime;	/* user/system time when JDONE */
X  	char	com [48];	/* command */
X! } Proc;
X  
X  /* proc states */
X  #define	JFREE	0		/* unused proc */
X***************
X*** 386,392 ****
X--- 401,412 ----
X  	(void) times(&t0);
X  	do {
X  		register Proc *j;
X+ #ifdef sun
X+ 		union wait status;
X+ 		int pid;
X+ #else
X  		int pid, status;
X+ #endif /* sun */
X  #if JOBS
X  		if (flag[FMONITOR])
X  			pid = waitpid(-1, &status, (WNOHANG|WUNTRACED));
X*** /tmp/pdksh/src/c_sh.c	Thu Apr 25 15:05:24 1991
X--- ./src/c_sh.c	Mon Feb 25 22:44:14 1991
X***************
X*** 10,15 ****
X--- 10,16 ----
X  #include <errno.h>
X  #include <signal.h>
X  #include <setjmp.h>
X+ #include <sys/types.h>
X  #include <sys/times.h>
X  #include <unistd.h>		/* getcwd */
X  #include "sh.h"
X***************
X*** 31,36 ****
X--- 32,38 ----
X  c_cd(wp)
X  	register char **wp;
X  {
X+   extern char *getcwd ARGS((char *buf, size_t size));
X  	char path [PATH];
X  	register char *cp;
X  	register struct tbl *vp;
X***************
X*** 291,300 ****
X  {
X  	register char *cp;
X  
X  	e.oenv = NULL;
X  	if ((cp = wp[1]) != NULL)
X  		exstat = getn(cp);
X! #if JOBS
X  	if (flag[FMONITOR] && j_stopped()) /* todo: only once */
X  		errorf("There are stopped jobs\n");
X  #endif
X--- 293,313 ----
X  {
X  	register char *cp;
X  
X+ #if defined(JOBS) && defined(sun)
X+ 	static int extry = 0;
X+ 	
X+ 	if (extry == 0 && flag[FMONITOR] && j_stopped()) /* todo: only once */
X+ 	{
X+ 	  errorf("There are stopped jobs\n");
X+ 	  extry++;
X+ 	  return 1;
X+ 	}
X+ #endif
X  	e.oenv = NULL;
X  	if ((cp = wp[1]) != NULL)
X  		exstat = getn(cp);
X! 
X! #if defined(JOBS) && !defined(sun)
X  	if (flag[FMONITOR] && j_stopped()) /* todo: only once */
X  		errorf("There are stopped jobs\n");
X  #endif
X*** /tmp/pdksh/src/c_test.c	Thu Apr 25 15:05:26 1991
X--- ./src/c_test.c	Thu Feb 21 10:31:34 1991
X***************
X*** 247,252 ****
X--- 247,253 ----
X  		}
X  	}
X  	syntax();
X+ 	return 0;
X  }
X  
X  filstat(nm, mode)
X*** /tmp/pdksh/src/Makefile	Thu Apr 25 15:04:58 1991
X--- src/Makefile	Thu Feb 28 10:06:00 1991
X***************
X*** 2,13 ****
X  
X  # $Header: /tmp/egisin/src/RCS/Makefile,v 3.2 88/11/06 11:34:12 egisin Exp $
X  
X! BIN = /u/egisin/bin
X! STD = ../std
X! PRINT = lpr -p -Plp26_3018
X  
X! # CC = cc
X! CC = gcc 
X  
X  # Must define one of _V7, _SYSV, _BSD, _POSIX
X  # may define any of JOBS (have BSD or POSIX job control),
X--- 2,13 ----
X  
X  # $Header: /tmp/egisin/src/RCS/Makefile,v 3.2 88/11/06 11:34:12 egisin Exp $
X  
X! BIN = /local/bin
X! STD = ../stdc
X! PRINT = lpr #-p -Plp26_3018
X  
X! #CC = cc
X! CC = gcc -Di386 -Dsun -Dsun386
X  
X  # Must define one of _V7, _SYSV, _BSD, _POSIX
X  # may define any of JOBS (have BSD or POSIX job control),
X***************
X*** 15,23 ****
X  
X  OPTIONS = -D_BSD -DJOBS -DEDIT 
X  
X! CFWARN = -ansi -O -W -Wcomment # -Wreturn-type
X! CFLAGS = $(CFWARN) -I$(STD)/h $(OPTIONS) $(JUNK) 
X! LDFLAGS = -L$(STD) $(JUNK) 
X  LDLIBS = -lstdc -lposix			# compatability libraries
X  
X  HDRS =	sh.h table.h expand.h lex.h tree.h tty.h
X--- 15,25 ----
X  
X  OPTIONS = -D_BSD -DJOBS -DEDIT 
X  
X! CFWARN = -ansi -W -Wcomment # -Wreturn-type
X! #CFWARN=
X! #CFLAGS = $(CFWARN) $(OPTIONS) $(DBG) 
X! CFLAGS = $(CFWARN) -I../h $(OPTIONS) $(DBG) 
X! LDFLAGS = -L$(STD) -L../posix $(DBG) 
X  LDLIBS = -lstdc -lposix			# compatability libraries
X  
X  HDRS =	sh.h table.h expand.h lex.h tree.h tty.h
END_OF_sun386i.diffs
if test 11418 -ne `wc -c <sun386i.diffs`; then
    echo shar: \"sun386i.diffs\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f bugs.diffs -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"bugs.diffs\"
else
echo shar: Extracting \"bugs.diffs\" \(3004 characters\)
sed "s/^X//" >bugs.diffs <<'END_OF_bugs.diffs'
XPD KSH 3.2 alpha patches [bugs.diffs]
X
XThe patches below fix a bug in vprintf.c as well as implementing
X$RANDOM.  
X
XThese patches can be installed using the following command
Xin the top level directory of the pdksh source tree:
X
Xpatch -p0 <this-article
X
X*** /tmp/pdksh/stdc/vprintf.c	Thu Apr 25 15:05:45 1991
X--- ./stdc/vprintf.c	Thu Feb 21 13:55:57 1991
X***************
X*** 166,175 ****
X  			while (--prec >= 0)
X  				*--p = '0';
X  			if (flags&FF_NEG)
X! 				*--p = '-';
X  			else
X! 				if (sign != '-')
X! 					*--p = (sign == '+') ? '+' : ' ';
X  			flags |= FF_PUTS;
X  			break;
X  
X--- 166,175 ----
X  			while (--prec >= 0)
X  				*--p = '0';
X  			if (flags&FF_NEG)
X! 			  *--p = '-';
X  			else
X! 			  if (sign != '-')
X! 			    *--p = (sign == '+') ? '+' : ' ';
X  			flags |= FF_PUTS;
X  			break;
X  
X***************
X*** 218,224 ****
X  			int pad = width - len;
X  			if (!(flags&FF_LEFT))
X  				while (--pad >= 0)
X! 					putc(' ', f);
X  			while (*p)
X  				putc(*p++, f);
X  			if ((flags&FF_LEFT))
X--- 218,224 ----
X  			int pad = width - len;
X  			if (!(flags&FF_LEFT))
X  				while (--pad >= 0)
X! 					putc((flags&FF_ZERO) ? '0' : ' ', f);
X  			while (*p)
X  				putc(*p++, f);
X  			if ((flags&FF_LEFT))
X*** /tmp/pdksh/src/table.h	Thu Apr 25 15:05:00 1991
X--- ./src/table.h	Mon Feb 25 22:44:14 1991
X***************
X*** 87,92 ****
X--- 87,93 ----
X  #define	V_IFS	2
X  #define	V_SECONDS 3
X  #define	V_OPTIND 4
X+ #define	V_RANDOM 5
X  
X  Extern	Area   *lastarea;	/* area of last variable/function looked up */
X  Extern	char   *path;		/* PATH value */
X*** /tmp/pdksh/src/var.c	Thu Apr 25 15:05:29 1991
X--- ./src/var.c	Mon Feb 25 22:44:14 1991
X***************
X*** 490,495 ****
X--- 490,497 ----
X  		return V_SECONDS;
X  	if (strcmp("OPTIND", name) == 0)
X  		return V_OPTIND;
X+ 	if (strcmp("RANDOM", name) == 0)
X+ 		return V_RANDOM;
X  	return V_NONE;
X  }
X  
X***************
X*** 500,505 ****
X--- 502,509 ----
X  getspec(vp)
X  	register struct tbl *vp;
X  {
X+   static int seed = 0;
X+   
X  	switch (special(vp->name)) {
X  	case V_SECONDS:
X  		vp->flag &= ~ SPECIAL;
X***************
X*** 506,511 ****
X--- 510,525 ----
X  		setint(vp, time((time_t *)0) - seconds);
X  		vp->flag |= SPECIAL;
X  		break;
X+ 	case V_RANDOM:
X+ 		if (seed == 0)
X+ 		{
X+ 		  seed = (int) time((time_t *)0);
X+ 		  srand(seed);
X+ 		}
X+ 		vp->flag &= ~ SPECIAL;
X+ 		setint(vp, (rand() & 0x7fff));
X+ 		vp->flag |= SPECIAL;
X+ 		break;
X  	}
X  }
X  
X***************
X*** 523,528 ****
X--- 537,545 ----
X  		break;
X  	  case V_SECONDS:
X  		seconds = time((time_t *)0);
X+ 		break;
X+ 	  case V_RANDOM:
X+ 		srand((int) time((time_t *)0));
X  		break;
X  	  case V_OPTIND:
X  		if (intval(vp) == 1)
X*** /tmp/pdksh/src/tree.c	Thu Apr 25 15:05:20 1991
X--- ./src/tree.c	Thu Feb 21 10:16:56 1991
X***************
X*** 9,14 ****
X--- 9,19 ----
X  #include <stdio.h>
X  #include <errno.h>
X  #include <setjmp.h>
X+ #if defined(__STDC__) && defined(va_start)
X+ # undef va_start
X+ # undef va_end
X+ # undef va_arg
X+ #endif
X  #include <varargs.h>
X  #include "sh.h"
X  #include "tree.h"
END_OF_bugs.diffs
if test 3004 -ne `wc -c <bugs.diffs`; then
    echo shar: \"bugs.diffs\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0
-- 
Simon J. Gerraty        <sjg@zen.void.oz.au>

#include <disclaimer>   /* imagine something _very_ witty here */