[comp.os.os9] Larry Wall's patch for os9/68k

blarson@skat.usc.edu (Bob Larson) (07/10/88)

Here are the changes I have made to Larry Wall's patch 2.0 patchlevel
12 to get it to work on os9/68k.  I don't know of any reason this
wouldn't work on a 6809 system, but this hasn't been tested.  I have
sent this to Larry for possible inclusion with future versions.

Patch applies diffs (preferably context) to make new versions of
programs.  This is usful in combination with the public domain diff
program I and others posted to comp.sources.misc.

Patch is available from comp.sources.unix archives, and for ftp from
devvax.jpl.nasa.gov.  Patches to bring it up to the current version
are available from the latter and via Larry's automatic mail request
server.  (See any of Larry's patches for any of his programs for how
to use the mail server.)

#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar:    Shell Archiver
#	Run the following text with /bin/sh to create:
#	Makefile.OSK
#	Readme.OSK
#	config.h.OSK
#	common.h.diff
#	inp.c.diff
#	pch.c.diff
#	util.c.diff
# This archive created: Tue Jul  5 15:11:13 1988
# By:	blarson
cat << \SHAR_EOF > Makefile.OSK
# makefile for Larry Wall's patch program, addapted for Os9/68k by Bob Larson

# FLEXFILENAMES isn't really true, but ~ and # arn't leagal os9 file name
# characters and the file name limit is 28 not 14.

CC = cc
CFLAGS = -k2w -dFLEXFILENAMES
LFLAGS = -i

public = patch
private =
util =

c = patch.c pch.c inp.c version.c util.c

obj = patch.r pch.r inp.r util.r version.r

all: $(public) $(private) $(util)
 touch all

patch: $(obj)
 $(CC) $(LFLAGS) $(obj) -f=patch

clean:
 del *.r

patch.r: config.h common.h patch.c inp.h pch.h util.h version.h
pch.r: config.h common.h pch.c pch.h util.h
inp.r: config.h common.h inp.c inp.h util.h
util.r: config.h common.h util.c util.h
version.r: config.h common.h version.c version.h patchlevel.h util.h
SHAR_EOF
cat << \SHAR_EOF > Readme.OSK
This is Larry Wall's patch 2.0 patchlevel 12, adapted to os9/68k
(OSK) by Robert A. Larson.

Rename config.h.OSK to config.h and Makefile.OSK to Makefile .  If you
don't want to use /r0 as your temporary directory, edit common.h to
use something else.

Ed file diffs are not supported.  (Os9 doesn't have unix ed.)

The FLEXNAMES code is used despite the fact OSK doesn't have them.  28
characters are usually enough, and # and ~ are not legal characters in
os9 filenames.

Signals are not disabled like they are in the unix version, so it
probably possible to leave a nasty mess if you ^C at the wrong point.
SHAR_EOF
cat << \SHAR_EOF > config.h.OSK
/* config.h
 * This file was produced by running the Configure script.
 * Feel free to modify any of this as the need arises.
 */


/* #undef	EUNICE		/* no file linking? */
/* #undef	VMS		/*	*/

/* #undef	index strchr	/* cultural */
/* #undef	rindex strrchr	/*  differences? */

#define	void int	/* is void to be avoided? */

/* How many register declarations are paid attention to? */

#define Reg1 register
#define Reg2 register
#define Reg3 register
#define Reg4 register
#define Reg5 register
#define Reg6 register
#define Reg7 register
#define Reg8 register
#define Reg9 register
#define Reg10 
#define Reg11 
#define Reg12 
#define Reg13 
#define Reg14 
#define Reg15 
#define Reg16 

SHAR_EOF
cat << \SHAR_EOF > common.h.diff
*** common.h.orig
--- common.h
**************
*** 34,39
  #define Strcat (void)strcat
  
  #include <stdio.h>
  #include <assert.h>
  #include <sys/types.h>
  #include <sys/stat.h>
--- 34,44 -----
  #define Strcat (void)strcat
  
  #include <stdio.h>
+ #ifdef OSK
+ #define	assert(arg)
+ #include <direct.h>
+ #include <modes.h>
+ #else
  #include <assert.h>
  #include <sys/types.h>
  #include <sys/stat.h>
**************
*** 37,42
  #include <assert.h>
  #include <sys/types.h>
  #include <sys/stat.h>
  #include <ctype.h>
  #include <signal.h>
  
--- 42,48 -----
  #include <assert.h>
  #include <sys/types.h>
  #include <sys/stat.h>
+ #endif
  #include <ctype.h>
  #include <signal.h>
  
**************
*** 89,94
  EXT int Argc_last;			/* for restarting plan_b */
  EXT char **Argv_last;
  
  EXT struct stat filestat;		/* file statistics area */
  EXT int filemode INIT(0644);
  
--- 95,104 -----
  EXT int Argc_last;			/* for restarting plan_b */
  EXT char **Argv_last;
  
+ #ifdef OSK
+ EXT struct fildes filestat;
+ EXT int filemode INIT(S_IREAD | S_IWRITE | S_IOREAD);
+ #else
  EXT struct stat filestat;		/* file statistics area */
  EXT int filemode INIT(0644);
  #endif
**************
*** 91,96
  
  EXT struct stat filestat;		/* file statistics area */
  EXT int filemode INIT(0644);
  
  EXT char buf[MAXLINELEN];		/* general purpose buffer */
  EXT FILE *ofp INIT(Nullfp);		/* output file pointer */
--- 101,107 -----
  #else
  EXT struct stat filestat;		/* file statistics area */
  EXT int filemode INIT(0644);
+ #endif
  
  EXT char buf[MAXLINELEN];		/* general purpose buffer */
  EXT FILE *ofp INIT(Nullfp);		/* output file pointer */
**************
*** 111,116
  EXT char *origext INIT(Nullch);
  EXT char *origprae INIT(Nullch);
  
  EXT char TMPOUTNAME[] INIT("/tmp/patchoXXXXXX");
  EXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX");	/* might want /usr/tmp here */
  EXT char TMPREJNAME[] INIT("/tmp/patchrXXXXXX");
--- 122,133 -----
  EXT char *origext INIT(Nullch);
  EXT char *origprae INIT(Nullch);
  
+ #ifdef OSK
+ EXT char TMPOUTNAME[] INIT("/r0/patchoXXXXXX");
+ EXT char TMPINNAME[] INIT("/r0/patchiXXXXXX");	/* might want /usr/tmp here */
+ EXT char TMPREJNAME[] INIT("/r0/patchrXXXXXX");
+ EXT char TMPPATNAME[] INIT("/r0/patchpXXXXXX");
+ #else
  EXT char TMPOUTNAME[] INIT("/tmp/patchoXXXXXX");
  EXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX");	/* might want /usr/tmp here */
  EXT char TMPREJNAME[] INIT("/tmp/patchrXXXXXX");
**************
*** 115,120
  EXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX");	/* might want /usr/tmp here */
  EXT char TMPREJNAME[] INIT("/tmp/patchrXXXXXX");
  EXT char TMPPATNAME[] INIT("/tmp/patchpXXXXXX");
  EXT bool toutkeep INIT(FALSE);
  EXT bool trejkeep INIT(FALSE);
  
--- 132,138 -----
  EXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX");	/* might want /usr/tmp here */
  EXT char TMPREJNAME[] INIT("/tmp/patchrXXXXXX");
  EXT char TMPPATNAME[] INIT("/tmp/patchpXXXXXX");
+ #endif
  EXT bool toutkeep INIT(FALSE);
  EXT bool trejkeep INIT(FALSE);
  
**************
*** 144,149
  EXT char end_defined[128];		/* #endif xyzzy */
  
  EXT char *revision INIT(Nullch);	/* prerequisite revision, if any */
  
  char *malloc();
  char *realloc();
--- 162,177 -----
  EXT char end_defined[128];		/* #endif xyzzy */
  
  EXT char *revision INIT(Nullch);	/* prerequisite revision, if any */
+ 
+ #ifdef OSK
+ #define	CREATMODE	(S_IREAD | S_IWRITE)
+ #define READMODE	S_IREAD
+ #define	READWRITEMODE	(S_IREAD | S_IWRITE)
+ #else
+ #define	CREATMODE	0666
+ #define READMODE	0
+ #define READWRITEMODE	2
+ #endif
  
  char *malloc();
  char *realloc();
SHAR_EOF
cat << \SHAR_EOF > inp.c.diff
*** inp.c.orig
--- inp.c
**************
*** 80,86
      Reg1 char *s;
      Reg2 LINENUM iline;
  
!     if (ok_to_create_file && stat(filename, &filestat) < 0) {
  	if (verbose)
  	    say2("(Creating file %s...)\n",filename);
  	makedirs(filename, TRUE);
--- 80,89 -----
      Reg1 char *s;
      Reg2 LINENUM iline;
  
! #ifdef OSK
!     Reg3 int f;
! 
!     if (ok_to_create_file && access(filename, 0) < 0) {
  	if (verbose)
  	    say2("(Creating file %s...)\n",filename);
  	makedirs(filename, TRUE);
**************
*** 84,90
  	if (verbose)
  	    say2("(Creating file %s...)\n",filename);
  	makedirs(filename, TRUE);
! 	close(creat(filename, 0666));
      }
      if (stat(filename, &filestat) < 0) {
  	Sprintf(buf, "RCS/%s%s", filename, RCSSUFFIX);
--- 87,93 -----
  	if (verbose)
  	    say2("(Creating file %s...)\n",filename);
  	makedirs(filename, TRUE);
! 	close(creat(filename, CREATMODE));
      }
      if((ifd = open(filename, READMODE)) < 0)
  	fatal2("Can't find (or is directory) %s.\n", filename);
**************
*** 86,91
  	makedirs(filename, TRUE);
  	close(creat(filename, 0666));
      }
      if (stat(filename, &filestat) < 0) {
  	Sprintf(buf, "RCS/%s%s", filename, RCSSUFFIX);
  	if (stat(buf, &filestat) >= 0 || stat(buf+4, &filestat) >= 0) {
--- 89,107 -----
  	makedirs(filename, TRUE);
  	close(creat(filename, CREATMODE));
      }
+     if((ifd = open(filename, READMODE)) < 0)
+ 	fatal2("Can't find (or is directory) %s.\n", filename);
+     if(_gs_gfd(ifd, &filestat, sizeof filestat) < 0)
+     	fatal2("Can't get file descriptor of %s.\n", filename);
+     filemode = filestat.fd_att;
+     i_size = _gs_size(ifd);
+ #else
+     if (ok_to_create_file && stat(filename, &filestat) < 0) {
+ 	if (verbose)
+ 	    say2("(Creating file %s...)\n",filename);
+ 	makedirs(filename, TRUE);
+ 	close(creat(filename, CREATMODE));
+     }
      if (stat(filename, &filestat) < 0) {
  	Sprintf(buf, "RCS/%s%s", filename, RCSSUFFIX);
  	if (stat(buf, &filestat) >= 0 || stat(buf+4, &filestat) >= 0) {
**************
*** 115,120
      if ((filemode & S_IFMT) & ~S_IFREG)
  	fatal2("%s is not a normal file--can't patch.\n", filename);
      i_size = filestat.st_size;
      if (out_of_mem) {
  	set_hunkmax();		/* make sure dynamic arrays are allocated */
  	out_of_mem = FALSE;
--- 131,137 -----
      if ((filemode & S_IFMT) & ~S_IFREG)
  	fatal2("%s is not a normal file--can't patch.\n", filename);
      i_size = filestat.st_size;
+ #endif
      if (out_of_mem) {
  	set_hunkmax();		/* make sure dynamic arrays are allocated */
  	out_of_mem = FALSE;
**************
*** 128,134
  #endif
      if (i_womp == Nullch)
  	return FALSE;
!     if ((ifd = open(filename, 0)) < 0)
  	fatal2("Can't open file %s\n", filename);
  #ifndef lint
      if (read(ifd, i_womp, (int)i_size) != i_size) {
--- 145,152 -----
  #endif
      if (i_womp == Nullch)
  	return FALSE;
! #ifndef OSK				/* opened earlier for OSK */
!     if ((ifd = open(filename, READMODE)) < 0)
  	fatal2("Can't open file %s\n", filename);
  #endif
  #ifndef lint
**************
*** 130,135
  	return FALSE;
      if ((ifd = open(filename, 0)) < 0)
  	fatal2("Can't open file %s\n", filename);
  #ifndef lint
      if (read(ifd, i_womp, (int)i_size) != i_size) {
  	Close(ifd);	/* probably means i_size > 15 or 16 bits worth */
--- 148,154 -----
  #ifndef OSK				/* opened earlier for OSK */
      if ((ifd = open(filename, READMODE)) < 0)
  	fatal2("Can't open file %s\n", filename);
+ #endif
  #ifndef lint
      if (read(ifd, i_womp, (int)i_size) != i_size) {
  	Close(ifd);	/* probably means i_size > 15 or 16 bits worth */
**************
*** 208,214
      using_plan_a = FALSE;
      if ((ifp = fopen(filename, "r")) == Nullfp)
  	fatal2("Can't open file %s\n", filename);
!     if ((tifd = creat(TMPINNAME, 0666)) < 0)
  	fatal2("Can't open file %s\n", TMPINNAME);
      while (fgets(buf, sizeof buf, ifp) != Nullch) {
  	if (revision != Nullch && !found_revision && rev_in_string(buf))
--- 227,233 -----
      using_plan_a = FALSE;
      if ((ifp = fopen(filename, "r")) == Nullfp)
  	fatal2("Can't open file %s\n", filename);
!     if ((tifd = creat(TMPINNAME, CREATMODE)) < 0)
  	fatal2("Can't open file %s\n", TMPINNAME);
      while (fgets(buf, sizeof buf, ifp) != Nullch) {
  	if (revision != Nullch && !found_revision && rev_in_string(buf))
**************
*** 258,264
      }
      Fclose(ifp);
      Close(tifd);
!     if ((tifd = open(TMPINNAME, 0)) < 0) {
  	fatal2("Can't reopen file %s\n", TMPINNAME);
      }
  }
--- 277,283 -----
      }
      Fclose(ifp);
      Close(tifd);
!     if ((tifd = open(TMPINNAME, READMODE)) < 0) {
  	fatal2("Can't reopen file %s\n", TMPINNAME);
      }
  }
SHAR_EOF
cat << \SHAR_EOF > pch.c.diff
*** pch.c.orig
--- pch.c
**************
*** 91,96
      pfp = fopen(filename, "r");
      if (pfp == Nullfp)
  	fatal2("patch file %s not found\n", filename);
      Fstat(fileno(pfp), &filestat);
      p_filesize = filestat.st_size;
      next_intuit_at(0L,1L);			/* start at the beginning */
--- 91,99 -----
      pfp = fopen(filename, "r");
      if (pfp == Nullfp)
  	fatal2("patch file %s not found\n", filename);
+ #ifdef OSK
+     p_filesize = _gs_size(fileno(pfp));
+ #else
      Fstat(fileno(pfp), &filestat);
      p_filesize = filestat.st_size;
  #endif
**************
*** 93,98
  	fatal2("patch file %s not found\n", filename);
      Fstat(fileno(pfp), &filestat);
      p_filesize = filestat.st_size;
      next_intuit_at(0L,1L);			/* start at the beginning */
      set_hunkmax();
  }
--- 96,102 -----
  #else
      Fstat(fileno(pfp), &filestat);
      p_filesize = filestat.st_size;
+ #endif
      next_intuit_at(0L,1L);			/* start at the beginning */
      set_hunkmax();
  }
**************
*** 1063,1068
  void
  do_ed_script()
  {
      Reg1 char *t;
      Reg2 long beginning_of_this_line;
      Reg3 bool this_line_is_command = FALSE;
--- 1067,1075 -----
  void
  do_ed_script()
  {
+ #ifdef OSK
+     fatal1("Os9/68k does not support Unix ed.\n");
+ #else
      Reg1 char *t;
      Reg2 long beginning_of_this_line;
      Reg3 bool this_line_is_command = FALSE;
**************
*** 1120,1123
      else
  	chmod(outname, filemode);
      set_signals(1);
  }
--- 1127,1131 -----
      else
  	chmod(outname, filemode);
      set_signals(1);
+ #endif
  }
SHAR_EOF
cat << \SHAR_EOF > util.c.diff
*** util.c.orig
--- util.c
**************
*** 21,27
  	if (debug & 4)
  	    say2("Moving %s to stdout.\n", from);
  #endif
! 	fromfd = open(from, 0);
  	if (fromfd < 0)
  	    fatal2("patch: internal error, can't reopen %s\n", from);
  	while ((i=read(fromfd, buf, sizeof buf)) > 0)
--- 21,27 -----
  	if (debug & 4)
  	    say2("Moving %s to stdout.\n", from);
  #endif
! 	fromfd = open(from, READMODE);
  	if (fromfd < 0)
  	    fatal2("patch: internal error, can't reopen %s\n", from);
  	while ((i=read(fromfd, buf, sizeof buf)) > 0)
**************
*** 38,43
     		Strcpy(bakname, to);
      	Strcat(bakname, origext?origext:ORIGEXT);
  	}
      if (stat(to, &filestat) >= 0) {	/* output file exists */
  	dev_t to_device = filestat.st_dev;
  	ino_t to_inode  = filestat.st_ino;
--- 38,77 -----
     		Strcpy(bakname, to);
      	Strcat(bakname, origext?origext:ORIGEXT);
  	}
+ #ifdef OSK
+     if (access(to, 0) >= 0 || access(to, S_IFDIR) >= 0) {	/* exists */
+     	char *simplename = bakname;
+ 	char *argv[4];
+ 	int p;
+ 	int st;
+ 	extern char **environ;
+ 	int os9fork();
+ 	
+ 	for(s=bakname; *s; s++) {
+ 	    if (*s == '/')
+ 	    	simplename = s+1;
+ 	}
+ 	unlink(bakname);
+ #ifdef DEBUGGING
+ 	if (debug & 4)
+ 	    say3("Moving %s to %s.\n", to, bakname);
+ #endif
+ 	argv[0] = "rename";
+ 	argv[1] = to;
+ 	argv[2] = bakname;
+ 	argv[3] = (char *)NULL;
+ 	if((p = os9exec(os9fork, argv[0], argv, environ, 0, 0)) < 0) {
+ 	    say3("patch: can't backup %s, output is in %s\n", to, from);
+ 	    return -1;
+ 	}
+ 	while(wait(&st) != p) {}
+ 	if((st & 0xffff) != 0) {
+ 	    say3("patch: can't backup %s, output is in %s\n", to, from);
+ 	    return -1;
+ 	}
+ 	unlink(to);
+     }
+ #else
      if (stat(to, &filestat) >= 0) {	/* output file exists */
  	dev_t to_device = filestat.st_dev;
  	ino_t to_inode  = filestat.st_ino;
**************
*** 68,73
  	}
  	while (unlink(to) >= 0) ;
      }
  #ifdef DEBUGGING
      if (debug & 4)
  	say3("Moving %s to %s.\n", from, to);
--- 102,108 -----
  	}
  	while (unlink(to) >= 0) ;
      }
+ #endif
  #ifdef DEBUGGING
      if (debug & 4)
  	say3("Moving %s to %s.\n", from, to);
**************
*** 72,77
      if (debug & 4)
  	say3("Moving %s to %s.\n", from, to);
  #endif
      if (link(from, to) < 0) {		/* different file system? */
  	Reg4 int tofd;
  	
--- 107,115 -----
      if (debug & 4)
  	say3("Moving %s to %s.\n", from, to);
  #endif
+ #ifdef OSK
+     {
+ #else
      if (link(from, to) < 0) {		/* different file system? */
  #endif
  	Reg4 int tofd;
**************
*** 73,78
  	say3("Moving %s to %s.\n", from, to);
  #endif
      if (link(from, to) < 0) {		/* different file system? */
  	Reg4 int tofd;
  	
  	tofd = creat(to, 0666);
--- 111,117 -----
      {
  #else
      if (link(from, to) < 0) {		/* different file system? */
+ #endif
  	Reg4 int tofd;
  	
  	tofd = creat(to, CREATMODE);
**************
*** 75,81
      if (link(from, to) < 0) {		/* different file system? */
  	Reg4 int tofd;
  	
! 	tofd = creat(to, 0666);
  	if (tofd < 0) {
  	    say3("patch: can't create %s, output is in %s.\n",
  	      to, from);
--- 114,120 -----
  #endif
  	Reg4 int tofd;
  	
! 	tofd = creat(to, CREATMODE);
  	if (tofd < 0) {
  	    say3("patch: can't create %s, output is in %s.\n",
  	      to, from);
**************
*** 81,87
  	      to, from);
  	    return -1;
  	}
! 	fromfd = open(from, 0);
  	if (fromfd < 0)
  	    fatal2("patch: internal error, can't reopen %s\n", from);
  	while ((i=read(fromfd, buf, sizeof buf)) > 0)
--- 120,126 -----
  	      to, from);
  	    return -1;
  	}
! 	fromfd = open(from, READMODE);
  	if (fromfd < 0)
  	    fatal2("patch: internal error, can't reopen %s\n", from);
  	while ((i=read(fromfd, buf, sizeof buf)) > 0)
**************
*** 104,110
      Reg2 int fromfd;
      Reg1 int i;
      
!     tofd = creat(to, 0666);
      if (tofd < 0)
  	fatal2("patch: can't create %s.\n", to);
      fromfd = open(from, 0);
--- 143,149 -----
      Reg2 int fromfd;
      Reg1 int i;
      
!     tofd = creat(to, CREATMODE);
      if (tofd < 0)
  	fatal2("patch: can't create %s.\n", to);
      fromfd = open(from, READMODE);
**************
*** 107,113
      tofd = creat(to, 0666);
      if (tofd < 0)
  	fatal2("patch: can't create %s.\n", to);
!     fromfd = open(from, 0);
      if (fromfd < 0)
  	fatal2("patch: internal error, can't reopen %s\n", from);
      while ((i=read(fromfd, buf, sizeof buf)) > 0)
--- 146,152 -----
      tofd = creat(to, CREATMODE);
      if (tofd < 0)
  	fatal2("patch: can't create %s.\n", to);
!     fromfd = open(from, READMODE);
      if (fromfd < 0)
  	fatal2("patch: internal error, can't reopen %s\n", from);
      while ((i=read(fromfd, buf, sizeof buf)) > 0)
**************
*** 201,207
  	write(1, buf, strlen(buf));
  	r = read(1, buf, sizeof buf);
      }
!     else if ((ttyfd = open("/dev/tty", 2)) >= 0 && isatty(ttyfd)) {
  					/* might be deleted or unwriteable */
  	write(ttyfd, buf, strlen(buf));
  	r = read(ttyfd, buf, sizeof buf);
--- 240,251 -----
  	write(1, buf, strlen(buf));
  	r = read(1, buf, sizeof buf);
      }
! #ifdef OSK
!     else if ((ttyfd = open(getenv("PORT"), READWRITEMODE)) >= 0 
!     		&& isatty(ttyfd)) {
! #else
!     else if ((ttyfd = open("/dev/tty", READWRITEMODE)) >= 0 && isatty(ttyfd)) {
! #endif
  					/* might be deleted or unwriteable */
  	write(ttyfd, buf, strlen(buf));
  	r = read(ttyfd, buf, sizeof buf);
**************
*** 231,236
  set_signals(reset)
  int reset;
  {
      void my_exit();
  #ifndef lint
  #ifdef VOIDSIG
--- 275,281 -----
  set_signals(reset)
  int reset;
  {
+ #ifndef OSK
      void my_exit();
  #ifndef lint
  #ifdef VOIDSIG
**************
*** 258,263
      Signal(SIGHUP, hupval);
      Signal(SIGINT, intval);
  #endif
  }
  
  /* How to handle certain events when in a critical region. */
--- 303,309 -----
      Signal(SIGHUP, hupval);
      Signal(SIGINT, intval);
  #endif
+ #endif
  }
  
  /* How to handle certain events when in a critical region. */
**************
*** 265,270
  void
  ignore_signals()
  {
  #ifndef lint
      Signal(SIGHUP, SIG_IGN);
      Signal(SIGINT, SIG_IGN);
--- 311,317 -----
  void
  ignore_signals()
  {
+ #ifndef OSK
  #ifndef lint
      Signal(SIGHUP, SIG_IGN);
      Signal(SIGINT, SIG_IGN);
**************
*** 269,274
      Signal(SIGHUP, SIG_IGN);
      Signal(SIGINT, SIG_IGN);
  #endif
  }
  
  /* Make sure we'll have the directories to create a file. */
--- 316,322 -----
      Signal(SIGHUP, SIG_IGN);
      Signal(SIGINT, SIG_IGN);
  #endif
+ #endif
  }
  
  /* Make sure we'll have the directories to create a file. */
**************
*** 333,340
      if (debug & 128)
  	say4("fetchname %s %d %d\n",name,strip_leading,assume_exists);
  #endif
!     if (strnEQ(name, "/dev/null", 9))	/* so files can be created by diffing */
! 	return Nullch;			/*   against /dev/null. */
      for (; *t && !isspace(*t); t++)
  	if (*t == '/')
  	    if (--strip_leading >= 0)
--- 381,389 -----
      if (debug & 128)
  	say4("fetchname %s %d %d\n",name,strip_leading,assume_exists);
  #endif
!     if (strnEQ(name, "/dev/null", 9) || strnEQ(name, "/null", 5))
!     			/* so files can be created by diffing	*/
! 	return Nullch;	/* against /dev/null or OSK /null.	*/
      for (; *t && !isspace(*t); t++)
  	if (*t == '/')
  	    if (--strip_leading >= 0)
**************
*** 342,347
      *t = '\0';
      if (name != s && *s != '/') {
  	name[-1] = '\0';
  	if (stat(s, &filestat) && filestat.st_mode & S_IFDIR) {
  	    name[-1] = '/';
  	    name=s;
--- 391,399 -----
      *t = '\0';
      if (name != s && *s != '/') {
  	name[-1] = '\0';
+ #ifdef OSK
+ 	if (access(s, S_IFDIR) >= 0) {
+ #else
  	if (stat(s, &filestat) && filestat.st_mode & S_IFDIR) {
  #endif
  	    name[-1] = '/';
**************
*** 343,348
      if (name != s && *s != '/') {
  	name[-1] = '\0';
  	if (stat(s, &filestat) && filestat.st_mode & S_IFDIR) {
  	    name[-1] = '/';
  	    name=s;
  	}
--- 395,401 -----
  	if (access(s, S_IFDIR) >= 0) {
  #else
  	if (stat(s, &filestat) && filestat.st_mode & S_IFDIR) {
+ #endif
  	    name[-1] = '/';
  	    name=s;
  	}
**************
*** 348,354
  	}
      }
      name = savestr(name);
-     Sprintf(tmpbuf, "RCS/%s", name);
      free(s);
      if (stat(name, &filestat) < 0 && !assume_exists) {
  	Strcat(tmpbuf, RCSSUFFIX);
--- 401,406 -----
  	}
      }
      name = savestr(name);
      free(s);
  #ifndef OSK
      Sprintf(tmpbuf, "RCS/%s", name);
**************
*** 350,355
      name = savestr(name);
      Sprintf(tmpbuf, "RCS/%s", name);
      free(s);
      if (stat(name, &filestat) < 0 && !assume_exists) {
  	Strcat(tmpbuf, RCSSUFFIX);
  	if (stat(tmpbuf, &filestat) < 0 && stat(tmpbuf+4, &filestat) < 0) {
--- 402,409 -----
      }
      name = savestr(name);
      free(s);
+ #ifndef OSK
+     Sprintf(tmpbuf, "RCS/%s", name);
      if (stat(name, &filestat) < 0 && !assume_exists) {
  	Strcat(tmpbuf, RCSSUFFIX);
  	if (stat(tmpbuf, &filestat) < 0 && stat(tmpbuf+4, &filestat) < 0) {
**************
*** 360,364
  	    }
  	}
      }
      return name;
  }
--- 414,420 -----
  	    }
  	}
      }
+ #endif
      return name;
  }
  
**************
*** 362,364
      }
      return name;
  }
--- 417,433 -----
  #endif
      return name;
  }
+ 
+ #ifdef OSK
+ /* assume all SCF (sequential character files) are ttys on OSK */
+ 
+ #include <sgstat.h>
+ 
+ int isatty(fd)
+ int fd;
+ {
+     struct sgbuf sg;
+     
+     return _gs_opt(fd, &sg) >= 0 && sg.sg_class == 0;
+ }
+ #endif
SHAR_EOF
#	End of shell archive
exit 0
Bob Larson	Arpa: Blarson@Ecla.Usc.Edu	blarson@skat.usc.edu
Uucp: {sdcrdcf,cit-vax}!oberon!skat!blarson
Prime mailing list:	info-prime-request%ais1@ecla.usc.edu
			oberon!ais1!info-prime-request