[comp.emacs] Large patch for uEmacs 3.10 2/2

jbayer@ispi.UUCP (Jonathan Bayer) (06/10/89)

#! /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 archive 2 (of 2)."
# Contents:  diffs
# Wrapped by editor@ispi on Fri Jun  9 22:28:41 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'diffs' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'diffs'\"
else
echo shar: Extracting \"'diffs'\" \(50388 characters\)
sed "s/^X//" >'diffs' <<'END_OF_FILE'
X*** orig.src/tcap.c	Fri Jun  9 22:00:25 1989
X--- tcap.c	Fri Jun  9 11:12:22 1989
X***************
X*** 1,4 ****
X! /*	tcap:	Unix V5, SUN OS, SCO XENIX, V7 and BS4.2 Termcap video driver
X  		for MicroEMACS 3.10
X  
X           12-10-88 - Modifications made by Guy Turcotte to accomodate
X--- 1,4 ----
X! 	/*	tcap:	Unix V5, SUN OS, SCO XENIX, V7 and BS4.2 Termcap video driver
X  		for MicroEMACS 3.10
X  
X           12-10-88 - Modifications made by Guy Turcotte to accomodate
X***************
X*** 70,75 ****
X--- 70,174 ----
X                      
X  */
X  
X+ /*
X+  * a non-portable but generally usable USG option for get1key() is suggested;
X+  * it allows use of the function keys needed to handle menus, specifically
X+  * those of .emacsrc and the *.cmd files; 
X+  *
X+  * it assumes typeahead() is enabled;
X+  *
X+  * the ttable[] bindings include shifted function and keypad keys;
X+  *
X+  * following is a sample ansi terminfo file, which has strings for the 
X+  * normal and shifted keys, and which adheres more-or-less to the 
X+  * ansi standard;
X+  *
X+  * a user without write permission on the system terminfo files likely
X+  * will have to set up a local TERMINFO environment by use of .profile,
X+  * and perhaps reprogram the function and keypad strings of the terminal;
X+  *
X+  * j.a. rupley, tucson, az  - rupley!local@megaron.arizona.edu
X+  */
X+ 
X+ /*-
X+ ansi|modified terminfo description 
X+ # DELETE #...# COMMENTS #...# BEFORE #...# TIC'ING #
X+ # standard stuff #
X+ 	am, xon, cols#80, lines#24, bel=^G, cr=\r, clear=\E[H\E[J, 
X+ 	el=\E[K, ed=\E[J, cup=\E[%i%p1%d;%p2%dH, cud1=\n, home=\E[H, 
X+ 	cub1=\b, cuf1=\E[C, cuu1=\E[A, dch1=\E[P, dl1=\E[M, blink=\E[5m, 
X+ 	bold=\E[1m, smir=\E[4h, invis=\E[8m, rev=\E[7m, smso=\E[7m, 
X+ 	smul=\E[4m, sgr0=\E[m, rmir=\E[4l, rmso=\E[0m, rmul=\E[0m, 
X+ 	is2=\E[=h, ich1=\E[@, il1=\E[L, 
X+ 	dl=\E[%p1%dM, cud=\E[%p1%dB, 
X+ 	ich=\E[%p1%d@, il=\E[%p1%dL, cub=\E[%p1%dD, cuf=\E[%p1%dC, 
X+ 	cuu=\E[%p1%dA, ind=\n, ht=\t, 
X+ # function keys - kf0=kf10 #
X+ 	kf1=\EOc, kf2=\EOd, kf3=\EOe, kf4=\EOf, 
X+ 	kf5=\EOg, kf6=\EOh, kf7=\EOi, kf8=\EOj, kf9=\EOk, 
X+ 	kf0=\EOl, kf10=\EOl, 
X+ # shifted function keys - lf0=lf10 #
X+ # tricky - store and recover strings as labels #
X+ 	lf1=\EOC, lf2=\EOD, lf3=\EOE, lf4=\EOF, 
X+ 	lf5=\EOG, lf6=\EOH, lf7=\EOI, lf8=\EOJ, lf9=\EOK, 
X+ 	lf0=\EOL, lf10=\EOL, 
X+ # keypad keys #
X+ 	khome=\E[H,	kcuu1=\E[A,	kpp=\E[U, 
X+ 	kcub1=\E[D, 			kcuf1=\E[C, 
X+ 	kll=\E[E, 	kcud1=\E[B, 	knp=\E[V, 
X+ # ins #
X+ 	kich1=\E[@, 
X+ # shifted keypad keys #
X+ 	ka1=\E[!H,	kri=\E[S,	ka3=\E[!U, 
X+ 	kclr=\E[!@,			kel=\E[!A, 
X+ 	kc1=\E[!E,	kind=\E[T,	kc3=\E[!V,
X+ # shifted ins and shifted del #
X+ 	kil1=\E[L,			kdch1=\E[P,
X+ # miscellaneous #
X+ 	kdl1=\E[M, 
X+ 	cbt=\E[Z, 
X+ 	kbs=\b, 
X+ */
X+ 
X+ /*
X+  * The following is a fleshed-out ansi terminfo file as needed by
X+  * the SCO Xenix console.
X+  * Jonathan Bayer, Roselle Park, NJ.  ...!uunet!ispi!jbayer or
X+  *					jbayer@ispi.uucp
X+  *
X+  
X+ # ========================================================
X+ ansi|Ansi standard crt,
X+ 	cr=^M, cud1=^J, ind=^J, bel=^G,
X+ 	kich1=\E[L, am, cub1=^H, ed=\E[J, el=\E[K,
X+ 	clear=\E[2J\E[H, cup=\E[%i%p1%d;%p2%dH, cols#80,
X+ 	dch1=\E[P, dl1=\E[M, cud1=\E[B, cbt=\E[Z, rmir=,
X+ 	khome=\E[H, ich1=\E[@, smir=, lines#25,
X+ 	cuf1=\E[C, ht=^I, smso=\E[7m, rmso=\E[m, smul=\E[4m,
X+ 	rmul=\E[m, cuu1=\E[A,
X+ 	kbs=^h, kcuu1=\E[A, kcud1=\E[B, kcub1=\E[D, 
X+ 	kcuf1=\E[C, eo, ind=\E[S, ri=\E[T,
X+ # added keys here
X+ # function keys
X+ 	kf1=\E[M, kf2=\E[N, kf3=\E[O, kf4=\E[P, kf5=\E[Q,
X+ 	kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U, kf0=\E[V,
X+ 	knp=\E[G, kpp=\E[I, kll=\E[F, 
X+ # shifted function keys - lf0=lf10 #
X+ # tricky - store and recover strings as labels #
X+ 	lf1=\E[Y,
X+ 	lf2=\E[Z, lf3=\E[a, lf4=\E[b, lf5=\E[c, 
X+ 	lf6=\E[d, lf7=\E[e, lf8=\E[f, lf9=\E[g, lf0=\E[h, 
X+ # keypad keys #
X+ 	ka1=\E[H,	ka3=\E[I, 
X+ 	kc1=\E[F,	kc3=\E[G,
X+ # ins 
X+ 	kil1=\E[L,
X+ # miscellaneous #, delete line
X+ 	kdl1=\E[M, 
X+ 
X+ *
X+ */ 
X+ 
X  #define termdef 1			/* don't define "term" external */
X  
X  #include <stdio.h>
X***************
X*** 78,83 ****
X--- 177,184 ----
X  #include	"edef.h"
X  #include	"elang.h"
X  
X+ char	*mgetstr ();
X+ 
X  #if TERMCAP
X  
X  #if	USG | HPUX
X***************
X*** 102,108 ****
X  	char p_seq[10];	/* terminal escape sequence */
X  } TBIND;
X  
X! TBIND ttable[] = {
X  	"bt",	SHFT | CTRL | 'i',	"",	/* backtab */
X  	"k1",	SPEC | '1',		"",	/* function key 1 */
X  	"k2",	SPEC | '2',		"",	/* function key 2 */
X--- 203,209 ----
X  	char p_seq[10];	/* terminal escape sequence */
X  } TBIND;
X  
X!   TBIND ttable[] = {
X  	"bt",	SHFT | CTRL | 'i',	"",	/* backtab */
X  	"k1",	SPEC | '1',		"",	/* function key 1 */
X  	"k2",	SPEC | '2',		"",	/* function key 2 */
X***************
X*** 130,140 ****
X  	"kP",	SPEC | 'Z',		"",	/* previous page */
X  	"kR",	CTRL | 'Z',		"",	/* scroll down */
X  	"kr",	SPEC | 'F',		"",	/* right cursor */
X! 	"ku",	SPEC | 'P',		"",	/* up cursor */
X! };
X  
X! #define	NTBINDS	sizeof(ttable)/sizeof(TBIND)
X  
X  extern int	ttopen();
X  extern int	ttgetc();
X  extern int	ttputc();
X--- 231,276 ----
X  	"kP",	SPEC | 'Z',		"",	/* previous page */
X  	"kR",	CTRL | 'Z',		"",	/* scroll down */
X  	"kr",	SPEC | 'F',		"",	/* right cursor */
X! 	"ku",	SPEC | 'P',		"",	/* up */
X  
X! /* the following are additions to the standard table */
X  
X+ 	"l1",	SHFT | SPEC | '1',	"",	/* shift-function key 1 */
X+ 	"l2",	SHFT | SPEC | '2',	"",	/* shift-function key 2 */
X+ 	"l3",	SHFT | SPEC | '3',	"",	/* shift-function key 3 */
X+ 	"l4",	SHFT | SPEC | '4',	"",	/* shift-function key 4 */
X+ 	"l5",	SHFT | SPEC | '5',	"",	/* shift-function key 5 */
X+ 	"l6",	SHFT | SPEC | '6',	"",	/* shift-function key 6 */
X+ 	"l7",	SHFT | SPEC | '7',	"",	/* shift-function key 7 */
X+ 	"l8",	SHFT | SPEC | '8',	"",	/* shift-function key 8 */
X+ 	"l9",	SHFT | SPEC | '9',	"",	/* shift-function key 9 */
X+ 	"l0",	SHFT | SPEC | '0',	"",	/* shift-function key 10 */
X+ 
X+ /* the following are less obvious */
X+ 
X+ /* shift left	# kC kclr  clear screen */	/* bound to backword */
X+ /*	"kC",	META | 'B',		"",	/* kclr /* clear screen */
X+ 	"kC",	SPEC | CTRL | 'B',	"",	/* kclr /* clear screen */
X+ /* shift right	# kE kel  clear to eol */	/* bound to forwword */
X+ /*	"kE",	META | 'F',		"",	/* kel /* clear to eol */
X+ 	"kE",	SPEC | CTRL | 'F',	"",	/* kel /* clear to eol */
X+ /* shift pgup	# K3 ka3  pad upper right */	/* bound to gotobop */
X+ /*	"K3",	META | 'P',		"",	/* ka3 /* pad upper right */
X+ 	"K3",	SPEC | CTRL | 'Z',	"",	/* ka3 /* pad upper right */
X+ /* shift pgdn	# K5 kc3  pad lower right */	/* bound to gotoeop */
X+ /*	"K5",	META | 'N',		"",	/* kc3 /* pad lower right */
X+ 	"K5",	SPEC | CTRL | 'V',	"",	/* kc3 /* pad lower right */
X+ /* shift home	# K1 ka1  pad upper left */	/* unbound key */
X+ 	"K1",	SPEC | CTRL | '<',	"",	/* ka1 /* pad upper left */
X+ /* shift end	# K4 kc1  pad lower left */	/* unbound key */
X+ 	"K4",	SPEC | CTRL | '>',	"",	/* kc1 /* pad lower left */
X+ 
X+   };
X+ 
X+   #define	NTBINDS	sizeof(ttable)/sizeof(TBIND)
X+ 
X+ 
X+ 
X  extern int	ttopen();
X  extern int	ttgetc();
X  extern int	ttputc();
X***************
X*** 308,313 ****
X--- 444,467 ----
X  			fixnull(tgetstr(ttable[index].p_name, &p)));
X  	}
X  
X+ 	
X+ #ifndef	M_TERMINFO
X+ 
X+ 		/* read definitions of local function keys into ttable */
X+ 		/* this is used for those terminals which support more */
X+ 		/* than 10 function keys.			       */
X+ 
X+ 	if (mgetent(tcbuf,tv_stype)) {
X+ 		for (index = 0; index < NTBINDS; index++) {
X+ 			if (mgetstr(ttable[index].p_name,&p, tcbuf))
X+ 				strcpy(ttable[index].p_seq,
X+ 					fixnull(mgetstr(ttable[index].p_name, &p, tcbuf)));
X+ 		}
X+ 	}
X+ 
X+ #endif
X+ 
X+ 	
X  	/* tell unix we are goint to use the terminal */
X  	ttopen();
X  
X***************
X*** 440,446 ****
X  
X  #if XENIX | SUNOS
X  	if ((kbdmode != PLAY) && (rdchk(0) <= 0)) {
X! 		nap(35000L);
X  		if (rdchk(0) <= 0)
X  			return(CTRL | '[');
X  	}
X--- 594,600 ----
X  
X  #if XENIX | SUNOS
X  	if ((kbdmode != PLAY) && (rdchk(0) <= 0)) {
X! 		nap(33L);
X  		if (rdchk(0) <= 0)
X  			return(CTRL | '[');
X  	}
X***************
X*** 450,462 ****
X  	/* we don't know how to do this check for a pending char within
X  	   1/30th of a second machine independantly in the general System V
X  	   case.... so we don't */
X! 	if (kbdmode != PLAY)
X! 		return(CTRL | '[');
X  #endif
X  
X  	/* a key is pending within 1/30 of a sec... its an escape sequence */
X  	cseq[0] = 27;
X  	sp = &cseq[1];
X  	while (sp < &cseq[6]) {
X  		c = ttgetc();
X  		*sp++ = c;
X--- 604,650 ----
X  	/* we don't know how to do this check for a pending char within
X  	   1/30th of a second machine independantly in the general System V
X  	   case.... so we don't */
X! 	/*
X! 	 * or... maybe we try it;
X! 	 * very non-portable solution;
X! 	 * hardware-dependent timing loop;
X! 	 * set upper-limit on loop by testing hardware, to get 30 ms;
X! 	 * use typahead() to check for waiting input on exit from loop;
X! 	 */
X! 	{	int i;
X! 		if (kbdmode != PLAY && typahead() <= 0) {
X! 			/* loop limit set by hardware test */
X! 			/* for 30 ms or a bit less */
X! 			for (i = 0; i < 1500; i++)
X! 				;
X! 			if (typahead() <= 0)
X! 				return(CTRL | '[');
X! 		}
X! 	}
X! 	/*-
X! 	 * another way -- using blocking read;
X! 	 * problem... when <esc> used as terminator, as in setup for
X! 	 * searches, need to give it twice, or whatever;
X! 	 * non-portable... assumes ansi standard for function keys and
X! 	 * keypad;
X! 	 */
X! 	/*
X! 	{
X! 		extern char kbdq;
X! 		extern int kbdqp;
X! 
X! 		kbdq = ttgetc();
X! 		kbdqp = 1;
X! 		if ((kbdq & 255) != '[' && (kbdq & 255) != 'O')
X! 			return(CTRL | '[');
X! 	}
X! 	*/
X  #endif
X  
X  	/* a key is pending within 1/30 of a sec... its an escape sequence */
X  	cseq[0] = 27;
X  	sp = &cseq[1];
X+ 	*sp = 0;
X  	while (sp < &cseq[6]) {
X  		c = ttgetc();
X  		*sp++ = c;
X***************
X*** 554,559 ****
X--- 742,945 ----
X  
X  hello()
X  {
X+ }
X+ 
X+ #endif
X+ 
X+ 
X+ 
X+ #ifndef	M_TERMINFO
X+ 
X+ char	*TERMEXP = "/etc/termcap.exp";
X+ 
X+ static	isent (ent, name)
X+ char	*ent;
X+ char	*name;
X+ {
X+ 	char	buf[16];
X+ 	register int	i;
X+ 
X+ 	while (*ent != ':' && *ent != 0) {
X+ 		for (i = 0;*ent != ':' && *ent != '|' && *ent != 0 && i < 15;i++)
X+ 			buf[i] = *ent++;
X+ 
X+ 		if (*ent == '|')
X+ 			ent++;
X+ 
X+ 		buf[i] = 0;
X+ 		if (strcmp (buf, name) == 0)
X+ 			return (1);
X+ 	}
X+ 	return (0);
X+ }
X+ 
X+ /*
X+ **	reads the termcap.exp file or the environment and returns the 
X+ **	record
X+ */
X+ 
X+ mgetent (bp, name)
X+ char	*bp;
X+ char	*name;
X+ {
X+ 	char	*buf = bp;
X+ 	register char	*cp;
X+ 	register FILE	*f;
X+ 	register int	i;
X+ 	char	*getenv ();
X+ 
X+ 
X+ 	if ((cp = getenv ("TERMEXP")) != NULL) {
X+ 		if (*cp != '/') {
X+ 			if (isent (cp, name)) {
X+ 				strcpy (buf, cp);
X+ 				return (1);
X+ 			}
X+ 		}
X+ 		TERMEXP = cp;
X+ 	}
X+ 	if ((f = fopen (TERMEXP, "r")) == (FILE *)0)
X+ 		return (-1);
X+ 
X+ 	while (fgets (buf, 512, f) != NULL) {
X+ 		if (buf[0] == '#')				/* skip all comment lines		*/
X+ 			continue;
X+ 
X+ 		i = strlen (buf) - 1;				/* find last character in line		*/
X+ 		buf[i] = 0;					/* remove trailing newline		*/
X+ 		if (i == 0)					/* ignore blank lines			*/
X+ 			continue;
X+ 
X+ 		while (buf[(i = strlen (buf) - 1)] == '\\') {	/* is last character a \\, still more	*/
X+ 			cp = &buf[i];				/* find last character			*/
X+ 			cp[0] = 0;				/* nullify, end of this part		*/
X+ 			if (fgets (cp, 512, f) == NULL)	/* end of file?	...			*/
X+ 				break;				/* ... end of entry			*/
X+ 
X+ 			cp[strlen (cp) - 1] = 0;		/* remove trailing newline		*/
X+ 			if (cp[0] == '#') {			/* comment line? ...			*/
X+ 				cp[0] = 0;			/* remove that line			*/
X+ 				continue;			/* go get another line			*/
X+ 			}
X+ 		}
X+ 		if (isent (buf, name)) {
X+ 			strcpy (bp, buf);
X+ 			fclose (f);
X+ 			return (1);
X+ 		}
X+ 	}
X+ 	fclose (f);
X+ 	return (0);
X+ }
X+ 
X+ /*
X+ **	searches the buffer looking for a string flag
X+ */
X+ 
X+ char	*mgetstr (id, area, bfr)
X+ register char	*id;
X+ register char	**area;
X+ char		*bfr;
X+ {
X+ 	register char	*str = *area;		/* start of current string		*/
X+ 	register char	*cp = bfr;
X+ 
X+ 	if (bfr == (char *) 0)			/* has a valid buffer been passed?	*/
X+ 		return ((char *) 0);		/* ... no, can't find string	*/
X+ 
X+ 	while (*cp != ':' && *cp != 0)		/* find first entry in cap		*/
X+ 		cp++;
X+ 
X+ 	if (*cp == 0)				/* empty entry???			*/
X+ 		return ((char *) 0);			/* ... yes, bad acucap entry		*/
X+ 	else
X+ 		cp++;				/* point to first character in next	*/
X+ 
X+ 	while (*cp != 0) {			/* until entry found or end of entry	*/
X+ 		if (strncmp(cp,id, strlen(id)) == 0) {
X+ 			if (cp[strlen(id)] != '=')	/* is it a string value???		*/
X+ 				return ((char *) 0);	/* no, something else			*/
X+ 			else
X+ 				break;		/* yes, entry was found			*/
X+ 		} else {			/* not entry, skip this entire entry	*/
X+ 			while (*cp != ':' && *cp != 0)
X+ 				cp++;		/* search for end of current entry	*/
X+ 
X+ 			if (*cp != 0)
X+ 				cp++;		/* skip terminating character		*/
X+ 		}
X+ 	}
X+ 	if (*cp == 0)				/* end of buffer	*/
X+ 		return ((char *) 0);
X+ 
X+ 	cp += strlen(id) + 1;			/* point to actual string		*/
X+ 	while (*cp != ':' && *cp != 0) {	/* for every character in string ...	*/
X+ 		if (*cp == '\\') {		/* translate escaped character		*/
X+ 			cp++;
X+ 			switch (*cp) {
X+ 				case 'n':	/* newline			*/
X+ 					**area = '\n';
X+ 					(*area)++;
X+ 					cp++;
X+ 					break;
X+ 				case 'r':	/* carriage return		*/
X+ 					**area = '\r';
X+ 					(*area)++;
X+ 					cp++;
X+ 					break;
X+ 				case 'b':	/* backspace			*/
X+ 					**area = '\b';
X+ 					(*area)++;
X+ 					cp++;
X+ 					break;
X+ 				case 'f':	/* form feed			*/
X+ 					**area = '\f';
X+ 					(*area)++;
X+ 					cp++;
X+ 					break;
X+ 				case 't':	/* tab				*/
X+ 					**area = '\t';
X+ 					(*area)++;
X+ 					cp++;
X+ 					break;
X+ 				case 'E':	/* Escape character		*/
X+ 					**area = 033;
X+ 					(*area)++;
X+ 					cp++;
X+ 					break;
X+ 				case '0':
X+ 				case '1':
X+ 				case '2':
X+ 				case '3':
X+ 				case '4':
X+ 				case '5':
X+ 				case '6':
X+ 				case '7':
X+ 					**area = ((cp[0] - '0') << 6) +
X+ 						 ((cp[1] - '0') << 3) +
X+ 						  (cp[2] - '0');
X+ 					(*area)++;
X+ 					cp += 3;
X+ 					break;
X+ 				default:
X+ 					**area = *cp++;
X+ 					(*area)++;
X+ 					break;
X+ 			}
X+ 		} else if (*cp == '^') {	/* some control character		*/
X+ 			cp++;
X+ 			if (*cp >= '@' && *cp <= '_') {
X+ 				**area = *cp - '@';
X+ 				(*area)++;
X+ 			}
X+ 			cp++;
X+ 		} else {			/* some normal character		*/
X+ 			**area = *cp++;		/* put character in area		*/
X+ 			(*area)++;
X+ 		}
X+ 	}
X+ 	*((*area)++) = 0;			/* null terminate area and string	*/
X+ 	return (str);				/* return pointer to start of string	*/
X  }
X  
X  #endif
X*** orig.src/file.c	Fri Jun  9 22:00:12 1989
X--- file.c	Thu Jun  1 12:21:37 1989
X***************
X*** 12,17 ****
X--- 12,23 ----
X  #include	"edef.h"
X  #include	"elang.h"
X  
X+ /* jbayer, added for stat function below */
X+ #if	V7 | USG | HPUX | BSD | SUN | XENIX
X+ #include	<sys/types.h>
X+ #include	<sys/stat.h>
X+ #endif
X+ 
X  /*
X   * Read a file into the current
X   * buffer. This is really easy; all you do is
X***************
X*** 231,236 ****
X--- 237,245 ----
X  	if ((s=bclear(bp)) != TRUE)		/* Might be old.	*/
X  		return(s);
X  	bp->b_flag &= ~(BFINVS|BFCHG);
X+ #if	BACKUP
X+ 	curbp->b_bupflg = FALSE;		/* no backup file yet	*/
X+ #endif
X  	strcpy(bp->b_fname, fname);
X  
X  	/* let a user macro get hold of things...if he wants */
X***************
X*** 427,432 ****
X--- 436,444 ----
X  	if ((s=writeout(fname)) == TRUE) {
X  		strcpy(curbp->b_fname, fname);
X  		curbp->b_flag &= ~BFCHG;
X+ #if	BACKUP
X+ 		curbp->b_bupflg = TRUE;
X+ #endif
X  		/* Update mode lines.	*/
X  		upmode();
X  	}
X***************
X*** 477,482 ****
X--- 489,497 ----
X  
X  	if ((s=writeout(curbp->b_fname)) == TRUE) {
X  		curbp->b_flag &= ~BFCHG;
X+ #if	BACKUP
X+ 		curbp->b_bupflg = TRUE;
X+ #endif
X  		/* Update mode lines.	*/
X  		upmode();
X  	}
X***************
X*** 487,493 ****
X   * This function performs the details of file writing. It uses
X   * the file management routines in the "fileio.c" package. The
X   * number of lines written is displayed. Several errors are
X!  * posible, and cause writeout to return a FALSE result. When
X   * $ssave is TRUE,  the buffer is written out to a temporary
X   * file, and then the old file is unlinked and the temporary
X   * renamed to the original name.  Before the file is written,
X--- 502,508 ----
X   * This function performs the details of file writing. It uses
X   * the file management routines in the "fileio.c" package. The
X   * number of lines written is displayed. Several errors are
X!  * possible, and cause writeout to return a FALSE result. When
X   * $ssave is TRUE,  the buffer is written out to a temporary
X   * file, and then the old file is unlinked and the temporary
X   * renamed to the original name.  Before the file is written,
X***************
X*** 507,512 ****
X--- 522,530 ----
X  	char tname[NSTRING];	/* temporary file name */
X  	char buf[NSTRING];	/* message buffer */
X  
X+ 	int fstatus;		/* jbayer, added to stat the old file */
X+ 	struct stat statbuf;	/* jbayer, added to stat the old file */
X+ 
X  	/* let a user macro get hold of things...if he wants */
X  	execkey(&writehook, FALSE, 1);
X  
X***************
X*** 581,591 ****
X  /*                          " line" */
X  		if (nline > 1)
X  			strcat(buf, "s");
X- 
X  		if (sflag) {
X  			/* erase original file */
X  			/* rename temporary file to original name */
X  			if (unlink(fn) == 0 && rename(tname, fn) == 0)
X  				;
X  			else {
X  				strcat(buf, TEXT150);
X--- 599,617 ----
X  /*                          " line" */
X  		if (nline > 1)
X  			strcat(buf, "s");
X  		if (sflag) {
X  			/* erase original file */
X  			/* rename temporary file to original name */
X+ 
X+ 			/* J. Bayer */
X+ 			fstatus = stat(fn,&statbuf);
X+ #if	!BACKUP
X+ 								   /* -- ZU */
X  			if (unlink(fn) == 0 && rename(tname, fn) == 0)
X+ #else
X+ 			if (makebackup(fn) == TRUE && rename(tname, fn) == 0)
X+ 								   /* -- UZ */
X+ #endif
X  				;
X  			else {
X  				strcat(buf, TEXT150);
X***************
X*** 593,598 ****
X--- 619,631 ----
X  				strcat(buf, tname);
X  				status = FIODEL;	    /* failed */
X  			}
X+ 				/* following added by j.bayer */
X+ 			if (status == FIOSUC && fstatus == 0) {
X+ 				chmod(fn, statbuf.st_mode);
X+ #if	V7 | USG | HPUX | BSD | SUN | XENIX
X+ 				chown(fn, statbuf.st_uid, statbuf.st_gid);
X+ #endif
X+ 			}
X  		}
X  		strcat(buf, "]");
X  		mlwrite(buf);
X***************
X*** 742,744 ****
X--- 775,886 ----
X  		return(FALSE);
X  	return(TRUE);
X  }
X+ 
X+ 								   /* -- ZU */
X+ /* Make a backup file.
X+  * This is done by renaming the original file to a new name.
X+  * The name of the backup file is defined as follows:
X+  *
X+  * MSDOS: The base file name remains untouched, the extension has a tilde (~)
X+  *	  as its first character and the other characters moved one place
X+  *	  to the right.
X+  * UNIX:  The first character is a '#'. The rest of the name is moved one
X+  *	  place to the right. The length of the filename may not exceed 14
X+  *	  characters (for BSD the limit is 255).
X+  *
X+  * No other operating system supported by now.
X+  */
X+ #if	BACKUP
X+ 
X+ PASCAL NEAR makebackup( filename )
X+ char	*filename;
X+ {
X+ 	char	backupname[NFILEN];
X+ #if	MSDOS | V7 | USG | HPUX | BSD | SUN | XENIX
X+ 	if ( curbp->b_bupflg ||			/* already backed up  */
X+ 	     !bakfile				/* no backup file wanted */
X+ 				) {
X+ 		if( unlink( filename ) == 0 )
X+ 			return( TRUE );
X+ 		else
X+ 			return( FALSE );
X+ 	}
X+ 
X+ 	getbackupname( backupname, filename );
X+ 
X+ 	if( !fexist( filename ))		/* no original file - */
X+ 		return( TRUE );			/* nothing to backup  */
X+ 
X+ 	if( fexist( backupname ))
X+ 		if( unlink( backupname ))	/* file is readonly */
X+ 			return( FALSE );
X+ 
X+ 	if( rename( filename, backupname ) != 0 )
X+ 		return( FALSE );
X+ 
X+ 	return( TRUE );
X+ #else			/* for all other operating systems return fail */
X+ 	return( FALSE );
X+ #endif	/* MSDOS | V7 | USG | HPUX | BSD | SUN | XENIX */
X+ }
X+ 
X+ /* Make the name of the backup file according to the original file name
X+  * This routines knows about the filename possibilities of the different
X+  * operating systems.
X+  */
X+ PASCAL NEAR getbackupname( backup, file )
X+ char	*backup;
X+ char	*file;
X+ {
X+ 	char	temp[NFILEN];
X+ 	int	index;
X+ 	char	*dotpos;
X+ 
X+ 	strcpy( backup, file );
X+ #if	MSDOS
X+ 	for( index = strlen( backup ) -1; index >= 0 && backup[index] != '.';
X+ 								index-- )
X+ 		;
X+ 	if( index < 0 )
X+ 		strcat( backup, ".~" );
X+ 	else {
X+ 		strcpy( temp, &backup[index +1] );
X+ 		backup[index +1] = '~';	/* first char of new extension	*/
X+ 		temp[2] = '\0';		/* extension is at most 3 chars	*/
X+ 		strcpy( &backup[index +2], temp );
X+ 	}
X+ #endif	/* MSDOS */
X+ 
X+ #if	V7 | USG | HPUX | BSD | SUN | XENIX
X+ /*	strcpy( temp, "#" ); */
X+ 	*temp = 0;
X+ 	for( index = strlen( backup ) -1; index >= 0 && backup[index] != '/';
X+ 								index-- )
X+ 		;
X+ 	if( index >= 0 )
X+ 	    	strcat( temp, &backup[index +1] );
X+ 	else
X+ 		strncat( temp, backup, NFILEN -1 );
X+ 
X+ #if	BSD	/* BSD allows filenames	up to 255 characters	*/
X+ #if	NFILEN < 255
X+ 	if( strlen( temp ) > NFILEN )
X+ 		temp[NFILEN] = '\0';
X+ #else
X+ 	if( strlen( temp ) > 254 )
X+ 		temp[255] = '\0';
X+ #endif
X+ #else		/* other Unixes allow only 14 characters	*/
X+ 	if( strlen( temp ) > 12 )
X+ 		temp[ 13] = '\0';
X+ #endif
X+ 	strcat(temp,"-");
X+ 	if( index >= 0 )
X+ 		strncpy( &backup[index +1], temp, NFILEN - strlen( backup ) -1 );
X+ 	else
X+ 		strncpy( backup, temp, NFILEN - strlen( backup ) -1 );
X+ #endif	/* V7 | USG | HPUX | BSD | SUN | XENIX */
X+ }
X+ 
X+ #endif	/* BACKUP */
X+ 								   /* -- UZ */
X*** orig.src/fileio.c	Fri Jun  9 22:00:12 1989
X--- fileio.c	Thu Jun  1 11:58:17 1989
X***************
X*** 24,29 ****
X--- 24,30 ----
X  PASCAL NEAR ffropen(fn)
X  char    *fn;
X  {
X+ 
X          if ((ffp=fopen(fn, "r")) == NULL)
X                  return(FIOFNF);
X  	eofflag = FALSE;
X***************
X*** 38,43 ****
X--- 39,45 ----
X  PASCAL NEAR ffwopen(fn)
X  char    *fn;
X  {
X+ 
X          if ((ffp=fopen(fn, "w")) == NULL) {
X                  mlwrite(TEXT155);
X  /*                      "Cannot open file for writing" */
X***************
X*** 68,73 ****
X--- 70,76 ----
X  /*                      "Error closing file" */
X                  return(FIOERR);
X          }
X+ 
X          return(FIOSUC);
X  #else
X          fclose(ffp);
X*** orig.src/estruct.h	Fri Jun  9 22:00:34 1989
X--- estruct.h	Fri May 26 12:45:36 1989
X***************
X*** 44,50 ****
X  #define V7	0			/* V7 UNIX or Coherent or BSD4.2*/ 
X  #define BSD	0			/* UNIX BSD 4.2 and ULTRIX	*/
X  #define USG	0			/* UNIX system V		*/
X! #define	XENIX	0			/* IBM-PC SCO XENIX		*/
X  #define	SUN	0			/* SUN v4.0			*/
X  #define	HPUX	0			/* HPUX HP 9000 minicomputer	*/
X  #define VMS	0			/* VAX/VMS			*/
X--- 44,50 ----
X  #define V7	0			/* V7 UNIX or Coherent or BSD4.2*/ 
X  #define BSD	0			/* UNIX BSD 4.2 and ULTRIX	*/
X  #define USG	0			/* UNIX system V		*/
X! #define	XENIX	1			/* IBM-PC SCO XENIX		*/
X  #define	SUN	0			/* SUN v4.0			*/
X  #define	HPUX	0			/* HPUX HP 9000 minicomputer	*/
X  #define VMS	0			/* VAX/VMS			*/
X***************
X*** 54,60 ****
X  
X  /*	Compiler definitions			*/
X  /*	[Set one of these!!]			*/
X! #define UNIX	0	/* a random UNIX compiler */
X  #define MWC	0	/* Mark Williams C */
X  #define	ALCYON	0	/* ALCYON Atari ST compiler */ 
X  #define LATTICE 0	/* Lattice 2.14 through 3.0 compilers */
X--- 54,60 ----
X  
X  /*	Compiler definitions			*/
X  /*	[Set one of these!!]			*/
X! #define UNIX	1	/* a random UNIX compiler */
X  #define MWC	0	/* Mark Williams C */
X  #define	ALCYON	0	/* ALCYON Atari ST compiler */ 
X  #define LATTICE 0	/* Lattice 2.14 through 3.0 compilers */
X***************
X*** 92,98 ****
X  #define	VMSVT	0			/* various VMS terminal entries	*/
X  #define VT52	0			/* VT52 terminal (Zenith).	*/
X  #define RAINBOW 0			/* Use Rainbow fast video.	*/
X! #define TERMCAP 0			/* Use TERMCAP			*/
X  #define	IBMPC	0			/* IBM-PC CGA/MONO/EGA/VGA drvr	*/
X  #define OS2NPM	0			/* OS/2 non-Presentation Mgr.	*/
X  #define	DG10	0			/* Data General system/10	*/
X--- 92,98 ----
X  #define	VMSVT	0			/* various VMS terminal entries	*/
X  #define VT52	0			/* VT52 terminal (Zenith).	*/
X  #define RAINBOW 0			/* Use Rainbow fast video.	*/
X! #define TERMCAP 1			/* Use TERMCAP			*/
X  #define	IBMPC	0			/* IBM-PC CGA/MONO/EGA/VGA drvr	*/
X  #define OS2NPM	0			/* OS/2 non-Presentation Mgr.	*/
X  #define	DG10	0			/* Data General system/10	*/
X***************
X*** 130,147 ****
X  #define	BINARY	1	/* using new binary searches?			*/
X  
X  #define REVSTA	1	/* Status line appears in reverse video 	*/
X! #define	COLOR	1	/* color commands and windows			*/
X  
X  #define FILOCK	0	/* file locking under unix BSD 4.2		*/
X  #define	ISRCH	1	/* Incremental searches like ITS EMACS		*/
X  #define	WORDPRO	1	/* Advanced word processing features		*/
X  #define	FLABEL	0	/* function key label code [HP150]		*/
X  #define	APROP	1	/* Add code for Apropos command			*/
X  #define	CRYPT	1	/* file encryption enabled?			*/
X  #define MAGIC	1	/* include regular expression matching?		*/
X  #define	AEDIT	1	/* advanced editing options: en/detabbing	*/
X  #define	PROC	1	/* named procedures				*/
X! #define MOUSE	1	/* Include routines for mouse actions		*/
X  #define	NOISY	1	/* Use a fancy BELL if it exists		*/
X  #define	DIACRIT	1	/* diacritical marks processed?			*/
X  #define	SPEECH	0	/* spoken EMACS, for the sight impared [not ready] */
X--- 130,154 ----
X  #define	BINARY	1	/* using new binary searches?			*/
X  
X  #define REVSTA	1	/* Status line appears in reverse video 	*/
X! #define	COLOR	0	/* color commands and windows			*/
X  
X  #define FILOCK	0	/* file locking under unix BSD 4.2		*/
X+ 								   /* -- ZU */
X+ #define BACKUP	1	/* retain original file as backup (MSDOS, UNIX) */
X+ 								   /* -- UZ */
X  #define	ISRCH	1	/* Incremental searches like ITS EMACS		*/
X  #define	WORDPRO	1	/* Advanced word processing features		*/
X  #define	FLABEL	0	/* function key label code [HP150]		*/
X  #define	APROP	1	/* Add code for Apropos command			*/
X  #define	CRYPT	1	/* file encryption enabled?			*/
X+ 
X+ #define	SOFTAB	1	/* in OVER mode, are tabs and returns soft?	*/
X+ #define	KEEPPOS	1	/* Maintain cursor position when paging		*/
X+ 
X  #define MAGIC	1	/* include regular expression matching?		*/
X  #define	AEDIT	1	/* advanced editing options: en/detabbing	*/
X  #define	PROC	1	/* named procedures				*/
X! #define MOUSE	0	/* Include routines for mouse actions		*/
X  #define	NOISY	1	/* Use a fancy BELL if it exists		*/
X  #define	DIACRIT	1	/* diacritical marks processed?			*/
X  #define	SPEECH	0	/* spoken EMACS, for the sight impared [not ready] */
X***************
X*** 186,192 ****
X  #define	ETYPE	struct
X  #endif
X  
X! #if MSDOS & (TURBO | MSC)
X  #define	NEAR
X  #define	DNEAR
X  #define	PASCAL pascal
X--- 193,199 ----
X  #define	ETYPE	struct
X  #endif
X  
X! #if (MSDOS & (TURBO | MSC))
X  #define	NEAR
X  #define	DNEAR
X  #define	PASCAL pascal
X***************
X*** 306,312 ****
X  #define MEMMAP	0
X  #endif
X  
X! #if	MSDOS | OS2 | V7 | USG | HPUX | BSD | (ST520 & MWC) | WMCS
X  #define	ENVFUNC	1
X  #else
X  #define ENVFUNC 0
X--- 313,319 ----
X  #define MEMMAP	0
X  #endif
X  
X! #if	MSDOS | OS2 | V7 | USG | HPUX | BSD | (ST520 & MWC) | WMCS | XENIX
X  #define	ENVFUNC	1
X  #else
X  #define ENVFUNC 0
X***************
X*** 417,423 ****
X  #define BELL	0x07			/* a bell character		*/
X  #define	TAB	0x09			/* a tab character		*/
X  
X! #if	V7 | USG | HPUX | BSD
X  #define	PATHCHR	':'
X  #else
X  #if	WMCS
X--- 424,430 ----
X  #define BELL	0x07			/* a bell character		*/
X  #define	TAB	0x09			/* a tab character		*/
X  
X! #if	V7 | BSD | USG | HPUX | XENIX
X  #define	PATHCHR	':'
X  #else
X  #if	WMCS
X***************
X*** 554,559 ****
X--- 561,569 ----
X  #if	CRYPT
X  	char   b_key[NPAT];	       /* current encrypted key        */
X  #endif
X+ #if	BACKUP							   /* -- ZU */
X+ 	short	b_bupflg;		/* true if file was backed up	*/
X+ #endif
X  }	BUFFER;
X  
X  #define BFINVS	0x01			/* Internal invisable buffer	*/
X***************
X*** 578,584 ****
X   * The starting position of a region, and the size of the region in
X   * characters, is kept in a region structure.  Used by the region commands.
X   */
X! typedef struct	{
X  	struct	LINE *r_linep;		/* Origin LINE address. 	*/
X  	short	r_offset;		/* Origin LINE offset.		*/
X  	long	r_size; 		/* Length in characters.	*/
X--- 588,594 ----
X   * The starting position of a region, and the size of the region in
X   * characters, is kept in a region structure.  Used by the region commands.
X   */
X! typedef struct	REGION {
X  	struct	LINE *r_linep;		/* Origin LINE address. 	*/
X  	short	r_offset;		/* Origin LINE offset.		*/
X  	long	r_size; 		/* Length in characters.	*/
X***************
X*** 669,675 ****
X  	BUFFER *buf;			/* buffer to execute */
X  };
X  
X! typedef struct	{
X  	short k_code;	 	/* Key code			*/
X  	short k_type;		/* binding type (C function or EMACS buffer) */
X  	ETYPE EPOINTER k_ptr;	/* ptr to thing to execute */
X--- 679,685 ----
X  	BUFFER *buf;			/* buffer to execute */
X  };
X  
X! typedef struct	KEYTAB {
X  	short k_code;	 	/* Key code			*/
X  	short k_type;		/* binding type (C function or EMACS buffer) */
X  	ETYPE EPOINTER k_ptr;	/* ptr to thing to execute */
X***************
X*** 785,791 ****
X   */
X  typedef char	*BITMAP;
X  
X! typedef struct {
X  	short int      mc_type;
X  	union {
X  	       int     lchar;
X--- 795,801 ----
X   */
X  typedef char	*BITMAP;
X  
X! typedef struct MC {
X  	short int      mc_type;
X  	union {
X  	       int     lchar;
X*** orig.src/bind.c	Fri Jun  9 22:00:07 1989
X--- bind.c	Thu May 25 13:14:41 1989
X***************
X*** 11,17 ****
X  #include	"elang.h"
X  #include	"epath.h"
X  
X! PASCAL NEAR help(f, n)	/* give me some help!!!!
X  		   bring up a fake buffer and read the help file
X  		   into it with view mode			*/
X  {
X--- 11,20 ----
X  #include	"elang.h"
X  #include	"epath.h"
X  
X! PASCAL NEAR help(f, n)
X! int f,n;
X! 
X! /* give me some help!!!!
X  		   bring up a fake buffer and read the help file
X  		   into it with view mode			*/
X  {
X***************
X*** 593,599 ****
X  
X  {
X  	char *fname;	/* resulting file name to execute */
X- 
X  	/* look up the startup file */
X  	if (*sfname != 0)
X  		fname = flook(sfname, TRUE);
X--- 596,601 ----
X***************
X*** 632,638 ****
X  	register int i;		/* index */
X  	static char fspec[NFILEN];	/* full path spec to search */
X  	char *getenv();
X- 
X  	/* if we have an absolute path.. check only there! */
X  	sp = fname;
X  	while (*sp) {
X--- 634,639 ----
X*** orig.src/msdos.c	Fri Jun  9 22:00:19 1989
X--- msdos.c	Thu May 25 13:01:19 1989
X***************
X*** 11,16 ****
X--- 11,17 ----
X  #ifdef	MSDOS
X  #include        "edef.h"
X  #include	"elang.h"
X+ #include	<direct.h>
X  
X  /* The Mouse driver only works with typeahead defined */
X  #if	MOUSE
X***************
X*** 26,31 ****
X--- 27,38 ----
X  struct ffblk fileblock;	/* structure for directory searches */
X  #endif
X  
X+ #if  MSC
X+ #include <dos.h>
X+ 
X+ struct find_t fileblock;
X+ #endif
X+ 
X  #if     LATTICE | MSC | DTL | TURBO | AZTEC | MWC
X  union REGS rg;		/* cpu register for use of DOS calls */
X  struct SREGS segreg;	/* cpu segment registers	     */
X***************
X*** 358,371 ****
X--- 365,389 ----
X  PASCAL NEAR spawncli(f, n)
X  
X  {
X+ 	char	OldScreenResolution[NBUFN];			   /* -- ZU */
X+ 
X  	/* don't allow this command if restricted */
X  	if (restflag)
X  		return(resterr());
X  
X+ 	strcpy( OldScreenResolution, sres );			   /* -- ZU */
X+ 
X          movecursor(term.t_nrow, 0);             /* Seek to last line.   */
X          TTflush();
X  	TTkclose();
X+ 
X+ 	TTclose();						   /* -- ZU */
X  	shellprog("");
X+ 
X+ 	TTopen();						   /* -- ZU */
X+ 	strcpy( sres, OldScreenResolution );			   /*     . */
X+ 	TTrez( sres );						   /* -- UZ */
X+ 
X  	TTkopen();
X          sgarbf = TRUE;
X          return(TRUE);
X***************
X*** 412,427 ****
X--- 430,454 ----
X  {
X          register int s;
X          char line[NLINE];
X+ 	char OldScreenResolution[NBUFN];			   /* -- ZU */
X  
X+ 
X  	/* don't allow this command if restricted */
X  	if (restflag)
X  		return(resterr());
X  
X          if ((s=mlreply("$", line, NLINE)) != TRUE)
X                  return(s);
X+ 
X+ 	strcpy( OldScreenResolution, sres );			   /* -- ZU */
X+ 
X  	movecursor(term.t_nrow - 1, 0);
X  	TTkclose();
X+ 	TTclose();						   /* -- ZU */
X          execprog(line);
X+ 	TTopen();						   /* -- ZU */
X+ 	strcpy( sres, OldScreenResolution );			   /*     . */
X+ 	TTrez( sres );						   /* -- UZ */
X  	TTkopen();
X  	/* if we are interactive, pause here */
X  	if (clexec == FALSE) {
X***************
X*** 661,666 ****
X--- 688,694 ----
X  	char f2[38];		/* FCB2 area (not initialized */
X  	char prog[NSTRING];	/* program filespec */
X  	char tail[NSTRING];	/* command tail with length byte */
X+ 	char curdir[NFILEN];	/* current directory save space */
X  	union REGS regs;	/* parameters for dos call  */
X  #if	MWC == 0
X  	struct SREGS segreg;	/* segment registers for dis call */
X***************
X*** 694,699 ****
X--- 722,729 ----
X  		}
X  	strcpy(prog, sp);
X  
X+ 	getcwd( curdir, 66 );		/* save current directory */
X+ 
X  #if	MWC == 0
X  	/* get a pointer to this PSPs environment segment number */
X  	segread(&segreg);
X***************
X*** 760,765 ****
X--- 790,797 ----
X  	} else
X  		rval = -_doserrno;	/* failed child call */
X  #endif
X+ 	chdir( curdir );		/* restore current directory */
X+ 
X  	return((rval < 0) ? FALSE : TRUE);
X  }
X  
X***************
X*** 879,885 ****
X  	return(ALTD | c);
X  }
X  
X! #if	COMPLET & (TURBO)
X  /*	FILE Directory routines		*/
X  
X  char path[NFILEN];	/* path of file to find */
X--- 911,917 ----
X  	return(ALTD | c);
X  }
X  
X! #if	COMPLET & (TURBO | MSC)
X  /*	FILE Directory routines		*/
X  
X  char path[NFILEN];	/* path of file to find */
X***************
X*** 924,935 ****
X--- 956,979 ----
X  		strcat(fname, ".*");
X  
X  	/* and call for the first file */
X+ #if	TURBO
X  	if (findfirst(fname, &fileblock, 0) == -1)
X  		return(NULL);
X+ #endif
X+ #if	MSC
X+ 	if (_dos_findfirst(fname, _A_NORMAL, &fileblock) != 0)
X+ 		return(NULL);
X+ #endif
X  
X+ 
X  	/* return the first file name! */
X  	strcpy(rbuf, path);
X+ #if	TURBO
X  	strcat(rbuf, fileblock.ff_name);
X+ #endif
X+ #if	MSC
X+ 	strcat(rbuf, fileblock.name);
X+ #endif
X  	mklower(rbuf);
X  	return(rbuf);
X  }
X***************
X*** 943,954 ****
X--- 987,1009 ----
X  	char fname[NFILEN];		/* file/path for DOS call */
X  
X  	/* and call for the first file */
X+ #if	TURBO
X  	if (findnext(&fileblock) == -1)
X  		return(NULL);
X+ #endif
X+ #if	MSC
X+ 	if (_dos_findnext(&fileblock) != 0)
X+ 		return(NULL);
X+ #endif
X  
X  	/* return the first file name! */
X  	strcpy(rbuf, path);
X+ #if	TURBO
X  	strcat(rbuf, fileblock.ff_name);
X+ #endif
X+ #if	MSC
X+ 	strcat(rbuf, fileblock.name);
X+ #endif
X  	mklower(rbuf);
X  	return(rbuf);
X  }
X*** orig.src/ibmpc.c	Fri Jun  9 22:00:15 1989
X--- ibmpc.c	Thu May 25 11:56:02 1989
X***************
X*** 195,201 ****
X--- 195,203 ----
X  			/* we must scroll the screen */
X  			rg.h.ah = 6;	/* scroll up */
X  			rg.h.al = 1;	/* # of lines to scroll by */
X+ #if	COLOR
X  			rg.h.bh = cfcolor; /* attribute for blank line */
X+ #endif
X  			rg.x.cx = 0;	/* upper left corner of scroll */
X  			rg.x.dx = 0x184f;/* lower right */
X  			int86(0x10, &rg, &rg);
X***************
X*** 298,306 ****
X--- 300,313 ----
X  	ttclose();
X  }
X  
X+ static CtrlC_State;						   /* -- ZU */
X+ 
X  PASCAL NEAR ibmkopen()	/* open the keyboard */
X  
X  {
X+ 	rg.x.ax = 0x3300;					   /* -- ZU */
X+ 	intdos( &rg, &rg );					   /*     . */
X+ 	CtrlC_State = rg.h.dl;					   /* -- UZ */
X  	rg.x.ax = 0x3301;
X  	rg.h.dl = 0x00;
X  	intdos(&rg, &rg);
X***************
X*** 309,314 ****
X--- 316,324 ----
X  PASCAL NEAR ibmkclose() /* close the keyboard */
X  
X  {
X+ 	rg.x.ax = 0x3301;					   /* -- ZU */
X+ 	rg.h.dl = CtrlC_State;					   /*     . */
X+ 	intdos(&rg, &rg);					   /* -- UZ */
X  }
X  
X  PASCAL NEAR scinit(type) /* initialize the screen head pointers */
X*** orig.src/main.c	Fri Jun  9 22:00:18 1989
X--- main.c	Thu May 25 09:31:23 1989
X***************
X*** 209,218 ****
X  #if WMCS
X  		if (argv[carg][0] == ':') {
X  #else
X! 		if (argv[carg][0] == '-') {
X  #endif
X  			switch (argv[carg][1]) {
X  				/* Process Startup macroes */
X  				case 'c':	/* -c for changable file */
X  				case 'C':
X  					viewflag = FALSE;
X--- 209,236 ----
X  #if WMCS
X  		if (argv[carg][0] == ':') {
X  #else
X! 		if (argv[carg][0] == '-' || argv[carg][0] == '+') {
X! 			/*		 ^^^^^^^^^^^^^^^^^^^^^^^   */
X! 			/*		 added by J.Bayer to allow */
X! 			/*		compatability with vi	   */
X  #endif
X+ /* J.Bayer, 9/22/88 */
X+ 			if  (argv[carg][0] == '+') {	/* + to emulate vi */
X+ 					gotoflag = TRUE;
X+ 					gline = asc_int(&argv[carg][1]);
X+ 			} else
X+ 
X  			switch (argv[carg][1]) {
X  				/* Process Startup macroes */
X+ #ifdef	BACKUP
X+ 						/* J. Bayer	9/22/88 */
X+ 				case 'b':	/* -b for no bakfile creation */
X+ 				case 'B':
X+ 					bakfile = FALSE;
X+ 					break;
X+ #endif
X+ 
X+ 
X  				case 'c':	/* -c for changable file */
X  				case 'C':
X  					viewflag = FALSE;
X***************
X*** 812,817 ****
X--- 830,837 ----
X  	prefix |= META;
X  	prenum = n;
X  	predef = f;
X+ 
X+ 	thisflag = lastflag; /* jbayer */
X  	return(TRUE);
X  }
X  
X***************
X*** 821,826 ****
X--- 841,848 ----
X  	prefix |= CTLX;
X  	prenum = n;
X  	predef = f;
X+ 
X+ 	thisflag = lastflag; /* jbayer */
X  	return(TRUE);
X  }
X  
X*** orig.src/edef.h	Fri Jun  9 22:00:33 1989
X--- edef.h	Thu May 25 09:31:22 1989
X***************
X*** 77,82 ****
X--- 77,87 ----
X  NOSHARE int DNEAR kbdmode = STOP;	/* current keyboard macro mode	*/
X  NOSHARE int DNEAR kbdrep = 0;		/* number of repetitions	*/
X  NOSHARE int DNEAR restflag = FALSE;	/* restricted use?		*/
X+ 
X+ #ifdef	BACKUP
X+ NOSHARE	int DNEAR bakfile = TRUE;	/* save the bakfile		*/
X+ #endif
X+ 
X  NOSHARE int DNEAR lastkey = 0;		/* last keystoke		*/
X  NOSHARE int DNEAR seed = 0;		/* random number seed		*/
X  NOSHARE long envram = 0l;		/* # of bytes current in use by malloc */
X***************
X*** 243,248 ****
X--- 248,258 ----
X  NOSHARE extern int kbdmode;		/* current keyboard macro mode	*/
X  NOSHARE extern int kbdrep;		/* number of repetitions	*/
X  NOSHARE extern int restflag;		/* restricted use?		*/
X+ 
X+ #ifdef	BACKUP
X+ NOSHARE	extern	int bakfile;		/* save the bakfile		*/
X+ #endif
X+ 
X  NOSHARE extern int lastkey;		/* last keystoke		*/
X  NOSHARE extern int seed;		/* random number seed		*/
X  NOSHARE extern long envram;		/* # of bytes current in use by malloc */
X*** orig.src/etype.h	Fri Jun  9 22:00:34 1989
X--- etype.h	Thu May 25 08:29:16 1989
X***************
X*** 205,210 ****
X--- 205,211 ----
X  PASCAL NEAR forwsearch();
X  PASCAL NEAR forwword();
X  PASCAL NEAR freewhile();
X+ PASCAL NEAR getbackupname();					   /* -- ZU */
X  PASCAL NEAR getccol();
X  PASCAL NEAR getcline();
X  PASCAL NEAR getcmd();
X***************
X*** 254,259 ****
X--- 255,261 ----
X  PASCAL NEAR lowrite();
X  PASCAL NEAR macarg();
X  PASCAL NEAR macrotokey();
X+ PASCAL NEAR makebackup();					   /* -- ZU */
X  PASCAL NEAR makelist();
X  PASCAL NEAR makelit();
X  PASCAL NEAR mcclear();
X***************
X*** 393,398 ****
X--- 395,408 ----
X  KEYTAB *getbind();
X  WINDOW *PASCAL NEAR mousewindow();
X  WINDOW *PASCAL NEAR wpopup();
X+ 
X+ PASCAL	NEAR	toggleovermode();
X+ PASCAL	NEAR	delline();
X+ 
X+ #if	KEEPPOS
X+ PASCAL NEAR	gotobos();		/* goto beginning of screen */
X+ PASCAL NEAR	gotoeos();		/* goto end of screen */
X+ #endif
X  
X  #if	MSDOS & TURBO
X  PASCAL NEAR binary(char *, char *(PASCAL NEAR *)(), int);
X*** orig.src/dg10.c	Fri Jun  9 22:00:08 1989
X--- dg10.c	Wed May 24 23:55:51 1989
X*** orig.src/efunc.h	Fri Jun  9 22:00:33 1989
X--- efunc.h	Wed May 24 23:32:05 1989
X***************
X*** 25,30 ****
X--- 25,33 ----
X  	{"begin-macro",			ctlxlp},
X  	{"beginning-of-file",		gotobob},
X  	{"beginning-of-line",		gotobol},
X+ #if	KEEPPOS
X+ 	{"beginning-of-screen",		gotobos},
X+ #endif
X  	{"bind-to-key",			bindtokey},
X  	{"buffer-position",		showcpos},
X  	{"case-region-lower",		lowerregion},
X***************
X*** 45,50 ****
X--- 48,54 ----
X  	{"delete-blank-lines",		deblank},
X  	{"delete-buffer",		killbuffer},
X  	{"delete-global-mode",		delgmode},
X+ 	{"delete-line",			delline},
X  	{"delete-mode",			delmode},
X  	{"delete-next-character",	forwdel},
X  	{"delete-next-word",		delfword},
X***************
X*** 70,75 ****
X--- 74,82 ----
X  	{"end-macro",			ctlxrp},
X  	{"end-of-file",			gotoeob},
X  	{"end-of-line",			gotoeol},
X+ #ifdef	KEEPPOS
X+ 	{"end-of-screen",		gotoeos},
X+ #endif
X  	{"end-of-word",			endword},
X  #if	AEDIT
X  	{"entab-line",			entab},
X***************
X*** 232,237 ****
X--- 239,245 ----
X  #if	BSD
X  	{"suspend-emacs",		bktoshell},
X  #endif
X+ 	{"toggle-over-mode",		toggleovermode},
X  	{"transpose-characters",	twiddle},
X  #if	AEDIT
X  	{"trim-line",			trim},
X*** orig.src/basic.c	Fri Jun  9 22:00:07 1989
X--- basic.c	Wed May 24 23:32:05 1989
X***************
X*** 135,141 ****
X--- 135,177 ----
X          return(TRUE);
X  }
X  
X+ #if	KEEPPOS
X+ 
X  /*
X+  * Move to the top of the screen.  The standsrd screen code does most of the
X+  * hard parts of update.
X+  *
X+  */
X+ PASCAL NEAR gotobos(f, n)
X+ {
X+         curwp->w_dotp  = curwp->w_linep;
X+         curwp->w_doto  = 0;
X+         curwp->w_flag |= WFHARD;
X+         return(TRUE);
X+ } /* gotobos */
X+ 
X+ 
X+ /*
X+  * Goto the end of the screen.
X+  */
X+ PASCAL NEAR gotoeos(f, n)
X+ {
X+ register LINE   *lp;
X+ int	currow;
X+ 
X+ 	lp = curwp->w_linep;
X+ 	currow = curwp->w_ntrows - 1;
X+         while (currow-- && lp!=curbp->b_linep) lp = lforw(lp);
X+         curwp->w_dotp  = lp;
X+         curwp->w_doto  = 0;
X+         curwp->w_flag |= WFHARD;
X+         return(TRUE);
X+ } /* gotoeos */
X+ 
X+ #endif
X+ 
X+ 
X+ /*
X   * Move forward by full lines. If the number of lines to move is less than
X   * zero, call the backward line function to actually do it. The last command
X   * controls how the goal column is set. Bound to "C-N". No errors are
X***************
X*** 337,342 ****
X--- 373,383 ----
X  {
X          register LINE   *lp;
X  
X+ #if	KEEPPOS
X+ 	int	currow;
X+         register LINE   *lp1;
X+ #endif
X+ 
X          if (f == FALSE) {
X                  n = curwp->w_ntrows - 2;        /* Default scroll.      */
X                  if (n <= 0)                     /* Forget the overlap   */
X***************
X*** 348,358 ****
X                  n *= curwp->w_ntrows;           /* to lines.            */
X  #endif
X          lp = curwp->w_linep;
X          while (n-- && lp!=curbp->b_linep)
X                  lp = lforw(lp);
X          curwp->w_linep = lp;
X!         curwp->w_dotp  = lp;
X          curwp->w_doto  = 0;
X          curwp->w_flag |= WFHARD;
X          return(TRUE);
X  }
X--- 389,420 ----
X                  n *= curwp->w_ntrows;           /* to lines.            */
X  #endif
X          lp = curwp->w_linep;
X+         
X+ #if	KEEPPOS
X+         if ((lastflag&CFCPCN) == 0)
X+                 curgoal = getccol(FALSE);
X+ 	/* flag this command as a line move */
X+         thisflag |= CFCPCN;
X+         lp1 = lp;
X+         currow = 0;
X+         while (lp1 != curwp->w_dotp ) {
X+         	currow++;
X+         	lp1 = lforw(lp1);
X+         }
X+ #endif
X+ 
X          while (n-- && lp!=curbp->b_linep)
X                  lp = lforw(lp);
X          curwp->w_linep = lp;
X! 
X! #if	KEEPPOS
X! 	while (currow-- && lp!=curbp->b_linep) lp = lforw(lp);
X! 	curwp->w_doto = getgoal(lp);
X! #else  
X          curwp->w_doto  = 0;
X+ #endif
X+ 
X+         curwp->w_dotp  = lp;
X          curwp->w_flag |= WFHARD;
X          return(TRUE);
X  }
X***************
X*** 370,375 ****
X--- 432,442 ----
X  
X  {
X          register LINE   *lp;
X+         
X+ #if	KEEPPOS
X+ 	int	currow;
X+         register LINE   *lp1;
X+ #endif
X  
X          if (f == FALSE) {
X                  n = curwp->w_ntrows - 2;        /* Default scroll.      */
X***************
X*** 382,392 ****
X                  n *= curwp->w_ntrows;           /* to lines.            */
X  #endif
X          lp = curwp->w_linep;
X          while (n-- && lback(lp)!=curbp->b_linep)
X                  lp = lback(lp);
X          curwp->w_linep = lp;
X!         curwp->w_dotp  = lp;
X          curwp->w_doto  = 0;
X          curwp->w_flag |= WFHARD;
X          return(TRUE);
X  }
X--- 449,480 ----
X                  n *= curwp->w_ntrows;           /* to lines.            */
X  #endif
X          lp = curwp->w_linep;
X+ 
X+ #if	KEEPPOS
X+         if ((lastflag&CFCPCN) == 0)
X+                 curgoal = getccol(FALSE);
X+ 	/* flag this command as a line move */
X+         thisflag |= CFCPCN;
X+         lp1 = lp;
X+         currow = 0;
X+         while (lp1 != curwp->w_dotp ) {
X+         	currow++;
X+         	lp1 = lforw(lp1);
X+         }
X+ #endif
X+ 
X          while (n-- && lback(lp)!=curbp->b_linep)
X                  lp = lback(lp);
X          curwp->w_linep = lp;
X!         
X! #if	KEEPPOS
X!         while (currow-- && lp!=curbp->b_linep) lp = lforw(lp);
X! 	curwp->w_doto = getgoal(lp);
X! #else
X          curwp->w_doto  = 0;
X+ #endif
X+ 
X+         curwp->w_dotp  = lp;
X          curwp->w_flag |= WFHARD;
X          return(TRUE);
X  }
X*** orig.src/window.c	Fri Jun  9 22:00:31 1989
X--- window.c	Wed May 24 09:51:25 1989
X***************
X*** 30,37 ****
X   */
X  PASCAL NEAR refresh(f, n)
X      {
X!     if (f == FALSE)
X          sgarbf = TRUE;
X      else
X          {
X          curwp->w_force = 0;             /* Center dot. */
X--- 30,41 ----
X   */
X  PASCAL NEAR refresh(f, n)
X      {
X!     if (f == FALSE) {
X          sgarbf = TRUE;
X+ 
X+         thisflag = lastflag; /* jbayer */
X+         
X+     }   
X      else
X          {
X          curwp->w_force = 0;             /* Center dot. */
X*** orig.src/line.c	Fri Jun  9 22:00:16 1989
X--- line.c	Wed May 24 09:47:07 1989
X***************
X*** 569,574 ****
X--- 569,613 ----
X  	return(TRUE);
X  }
X  
X+ 
X+ 
X+ /*
X+  * Delete the line the cursor is on
X+  */
X+ PASCAL	NEAR	delline(f, n)
X+ {
X+ 
X+ /*		Use the lines associated with  i  in order to keep the
X+ 		cursor in the same column when deleting a line.  If you
X+ 		comment these lines out then the cursor will revert to 
X+ 		the first column.					*/
X+ 		
X+  int	i,i1;
X+ 
X+ 	i1 = lastflag;
X+         i = getccol(FALSE); 
X+ 	gotobol(f,n);
X+ 
X+ 	lastflag = thisflag;
X+ 	thisflag = 0;
X+ 	setmark(f,n);
X+ 
X+ 	lastflag = thisflag;
X+ 	thisflag = 0;
X+ 	forwline(f,n);
X+ 
X+ 	lastflag = i1;		/* This so if several lines are killed at the */
X+ 	thisflag = 0;		/* same time, they will all go into the same  */
X+ 	killregion(f); 		/* kill buffer				      */
X+ 
X+ 	curgoal = i;
X+ 	curwp->w_doto = getgoal(curwp->w_dotp);
X+ 
X+ 	lastflag = i1;	
X+ 	return(TRUE);
X+ }
X+ 
X+ 
X  /*
X   * Delete all of the text saved in the kill buffer. Called by commands when a
X   * new kill context is being created. The kill buffer array is released, just
X*** orig.src/random.c	Fri Jun  9 22:00:23 1989
X--- random.c	Wed May 24 09:41:40 1989
X***************
X*** 237,242 ****
X--- 237,261 ----
X                  stabsize = n;
X                  return(TRUE);
X          }
X+ 
X+ #if	SOFTAB
X+ 	
X+ 	if (curwp->w_bufp->b_mode & MDOVER)  {
X+ 		if (! tabsize) {
X+            		curgoal = getccol(FALSE) | 0x07;  
X+ 	   		curgoal++;
X+ 	   	}
X+ 	   	else {
X+ 		   	curgoal = tabsize - (getccol(FALSE) % tabsize) + getccol(FALSE);
X+ 		}
X+ 
X+ 		curwp->w_doto =  getgoal(curwp->w_dotp);
X+    		return(TRUE);
X+ 	} 
X+ 
X+ #endif
X+ 
X+ 
X          if (!stabsize)
X                  return(linsert(1, '\t'));
X          return(linsert(stabsize - (getccol(FALSE) % stabsize), ' '));
X***************
X*** 433,445 ****
X--- 452,490 ----
X          return(s);
X  }
X  
X+ 
X  /*
X+  * Toggle overwrite mode.  Bound to the ins key.
X+  */
X+ PASCAL	NEAR	toggleovermode(f, n)	/* toggle overwrite mode */
X+ 
X+ int	f, n;		/* default and argument */
X+ 
X+ {
X+ 	if (curwp->w_bufp->b_mode & MDOVER)
X+ 		curwp->w_bufp->b_mode &= ~MDOVER;
X+ 	else
X+ 		curwp->w_bufp->b_mode |= MDOVER;
X+ 	upmode();
X+ }
X+ 
X+ 
X+ /*
X   * Insert a newline. Bound to "C-M". If we are in CMODE, do automatic
X   * indentation as specified.
X   */
X  PASCAL NEAR newline(f, n)
X  {
X  	register int    s;
X+ 	
X+ #if	SOFTAB
X+ 	
X+ 	if (curwp->w_bufp->b_mode & MDOVER)  {
X+ 		gotobol(f,1);
X+ 		thisflag = 0;
X+ 		return(forwline(f,1));
X+ 	}
X+ #endif
X  
X  	if (curbp->b_mode&MDVIEW)	/* don't allow this command if	*/
X  		return(rdonly());	/* we are in read only mode	*/
X***************
X*** 1120,1126 ****
X--- 1165,1176 ----
X  	   yet to solve......... */
X  	if (count == 0) {
X  		forwchar(FALSE, 1);
X+ #if	XENIX
X+ 		update(TRUE);
X+ 		nap(500L);
X+ #else
X  		for (i = 0; i < term.t_pause; i++)
X+ #endif
X  			update(FALSE);
X  	}
X  
X*** orig.src/unix.c	Fri Jun  9 22:03:35 1989
X--- unix.c	Tue Apr 11 14:24:26 1989
X***************
X*** 15,21 ****
X  #include	<signal.h>
X  #include	<termio.h>
X  #include	<fcntl.h>
X! #include	<ndir.h>
X  int kbdflgs;			/* saved keyboard fd flags	*/
X  int kbdpoll;			/* in O_NDELAY mode			*/
X  int kbdqp;			/* there is a char in kbdq	*/
X--- 15,23 ----
X  #include	<signal.h>
X  #include	<termio.h>
X  #include	<fcntl.h>
X! #include	<sys/ndir.h>
X! #include	<sys/types.h>
X! #include	<sys/stat.h>
X  int kbdflgs;			/* saved keyboard fd flags	*/
X  int kbdpoll;			/* in O_NDELAY mode			*/
X  int kbdqp;			/* there is a char in kbdq	*/
X***************
X*** 217,223 ****
X  		if (fcntl(0, F_SETFL, kbdflgs | O_NDELAY) < 0 && kbdpoll)
X  			return(FALSE);
X  		kbdpoll = TRUE;
X! 		kbdqp = (1 == read(0, kbdq, 1));
X  	}
X  	return(kbdqp);
X  #endif
X--- 219,225 ----
X  		if (fcntl(0, F_SETFL, kbdflgs | O_NDELAY) < 0 && kbdpoll)
X  			return(FALSE);
X  		kbdpoll = TRUE;
X! 		kbdqp = (1 == read(0, &kbdq, 1));
X  	}
X  	return(kbdqp);
X  #endif
X***************
X*** 531,543 ****
X  	register int extflag;		/* does the file have an extention? */
X  
X  	/* first parse the file path off the file spec */
X  	strcpy(path, fspec);
X  	index = strlen(path) - 1;
X  	while (index >= 0 && (path[index] != '/' &&
X  				path[index] != '\\' && path[index] != ':'))
X  		--index;
X  	path[index+1] = 0;
X! 
X  	/* check for an extension */
X  	point = strlen(fspec) - 1;
X  	extflag = FALSE;
X--- 533,546 ----
X  	register int extflag;		/* does the file have an extention? */
X  
X  	/* first parse the file path off the file spec */
X+ 	
X  	strcpy(path, fspec);
X  	index = strlen(path) - 1;
X  	while (index >= 0 && (path[index] != '/' &&
X  				path[index] != '\\' && path[index] != ':'))
X  		--index;
X  	path[index+1] = 0;
X! 	
X  	/* check for an extension */
X  	point = strlen(fspec) - 1;
X  	extflag = FALSE;
X***************
X*** 554,561 ****
X  		closedir(dirptr);
X  		dirptr = NULL;
X  	}
X! 	dirptr = opendir(path);
X! 	if (dirptr == NULL)
X  		return(NULL);
X  
X  	strcpy(rbuf, path);
X--- 557,566 ----
X  		closedir(dirptr);
X  		dirptr = NULL;
X  	}
X! 	if (strlen(path) == 0)		/* modified 4/10/89 by j. bayer */
X! 		dirptr = opendir("./");	
X! 	else dirptr = opendir(path);
X! 	if (dirptr == NULL) 
X  		return(NULL);
X  
X  	strcpy(rbuf, path);
X*** orig.src/epath.h	Fri Jun  9 22:00:33 1989
X--- epath.h	Mon Apr 10 17:27:45 1989
X***************
X*** 54,60 ****
X  };
X  #endif
X  
X! #if	V7 | BSD | USG | HPUX
X  {
X  	".emacsrc",
X  	"emacs.hlp",
X--- 54,60 ----
X  };
X  #endif
X  
X! #if	V7 | BSD | USG | HPUX | XENIX
X  {
X  	".emacsrc",
X  	"emacs.hlp",
END_OF_FILE
if test 50388 -ne `wc -c <'diffs'`; then
    echo shar: \"'diffs'\" unpacked with wrong size!
fi
# end of 'diffs'
fi
echo shar: End of archive 2 \(of 2\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Jonathan Bayer			      Beware: The light at the end of the
Intelligent Software Products, Inc.	      tunnel may be an oncoming dragon
500 Oakwood Ave.				...uunet!ispi!root
Roselle Park, NJ   07204    (201) 245-5922    jbayer@ispi.UUCP