                      Release 5 Public Patch #26
                           MIT X Consortium

To apply this patch:

cd to the top of the source tree (to the directory containing the "mit"
and "contrib" subdirectories) and do:
        patch -p -s < ThisFile
Patch will work silently unless an error occurs.
If you want to watch patch do its thing, leave out the "-s" argument to patch.


Finally, to rebuild after applying this patch, cd to the "mit" subdirectory
and do:
        make -k >& make.log

This patch removes xterm's logging feature.  Logging is a security
problem when xterm is installed setuid.  In addition, this patch
contains the following Xt fixes:

Xt: Convert.c - linked list of cache pointers incorrectly traversed
Xt: Keyboard pseudoTrace array not being updated when focus is changed
Xt: XtSetKeyboardFocus could be ineffective across identical subtree
Xt: XtUninstallTranslations from a nonfinal action in a series is broken
Xt: XtOverrideTranslations from a nonfinal action in a series is broken
Xt: fd.h has a bad definition for FD_SETSIZE on RS6000/AIX
Xt: XtParseAcceleratorTable() doesn't ignore "#replace"

Prereq: public-patch-25

*** /tmp/da20646	Wed Nov  3 20:04:26 1993
--- mit/bug-report	Wed Nov  3 20:04:25 1993
***************
*** 2,8 ****
  Subject: [area]: [synopsis]   [replace with actual area and short description]
  
  VERSION:
!     R5, public-patch-25
      [MIT public patches will edit this line to indicate the patch level]
  
  CLIENT MACHINE and OPERATING SYSTEM:
--- 2,8 ----
  Subject: [area]: [synopsis]   [replace with actual area and short description]
  
  VERSION:
!     R5, public-patch-26
      [MIT public patches will edit this line to indicate the patch level]
  
  CLIENT MACHINE and OPERATING SYSTEM:
*** /tmp/da21897	Thu Nov  4 08:57:24 1993
--- mit/clients/xterm/misc.c	Thu Nov  4 08:57:23 1993
***************
*** 1,5 ****
  /*
!  *	$XConsortium: misc.c,v 1.92 92/03/13 17:02:08 gildea Exp $
   */
  
  /*
--- 1,5 ----
  /*
!  *	$XConsortium: misc.c,v 1.95.1.1 93/11/04 08:56:48 gildea Exp $
   */
  
  /*
***************
*** 444,449 ****
--- 444,518 ----
  	}
  }
  
+ #if defined(ALLOWLOGGING) || defined(DEBUG)
+ 
+ #ifndef X_NOT_POSIX
+ #define HAS_WAITPID
+ #endif
+ 
+ /*
+  * create a file only if we could with the permissions of the real user id.
+  * We could emulate this with careful use of access() and following
+  * symbolic links, but that is messy and has race conditions.
+  * Forking is messy, too, but we can't count on setreuid() or saved set-uids
+  * being available.
+  */
+ void
+ creat_as(uid, gid, pathname, mode)
+     int uid;
+     int gid;
+     char *pathname;
+     int mode;
+ {
+     int fd;
+     int waited;
+     int pid;
+ #ifndef HAS_WAITPID
+     int (*chldfunc)();
+ 
+     chldfunc = signal(SIGCHLD, SIG_DFL);
+ #endif
+     pid = fork();
+     switch (pid)
+     {
+     case 0:			/* child */
+ 	setgid(gid);
+ 	setuid(uid);
+ 	fd = open(pathname, O_WRONLY|O_CREAT|O_APPEND, mode);
+ 	if (fd >= 0) {
+ 	    close(fd);
+ 	    _exit(0);
+ 	} else
+ 	    _exit(1);
+     case -1:			/* error */
+ 	return;
+     default:			/* parent */
+ #ifdef HAS_WAITPID
+ 	waitpid(pid, NULL, 0);
+ #else
+ 	waited = wait(NULL);
+ 	signal(SIGCHLD, chldfunc);
+ 	/*
+ 	  Since we had the signal handler uninstalled for a while,
+ 	  we might have missed the termination of our screen child.
+ 	  If we can check for this possibility without hanging, do so.
+ 	*/
+ 	do
+ 	    if (waited == term->screen.pid)
+ 		Cleanup(0);
+ 	while ( (waited=nonblocking_wait()) > 0);
+ #endif
+     }
+ }
+ #endif
+ 
+ #ifdef ALLOWLOGGING
+ /*
+  * logging is a security hole, since it allows a setuid program to
+  * write arbitrary data to an arbitrary file.  So it is disabled
+  * by default.
+  */ 
+ 
  StartLog(screen)
  register TScreen *screen;
  {
***************
*** 530,551 ****
  		return;
  #endif
  	} else {
! 		if(access(screen->logfile, F_OK) == 0) {
! 			if(access(screen->logfile, W_OK) < 0)
! 				return;
! 		} else if(cp = rindex(screen->logfile, '/')) {
! 			*cp = 0;
! 			i = access(screen->logfile, W_OK);
! 			*cp = '/';
! 			if(i < 0)
! 				return;
! 		} else if(access(".", W_OK) < 0)
  			return;
! 		if((screen->logfd = open(screen->logfile, O_WRONLY | O_APPEND |
! 		 O_CREAT, 0644)) < 0)
! 			return;
! 		chown(screen->logfile, screen->uid, screen->gid);
  
  	}
  	screen->logstart = screen->TekEmu ? Tbptr : bptr;
  	screen->logging = TRUE;
--- 599,618 ----
  		return;
  #endif
  	} else {
! 		if(access(screen->logfile, F_OK) != 0) {
! 		    if (errno == ENOENT)
! 			creat_as(screen->uid, screen->gid,
! 				 screen->logfile, 0644);
! 		    else
  			return;
! 		}
  
+ 		if(access(screen->logfile, F_OK) != 0
+ 		   || access(screen->logfile, W_OK) != 0)
+ 		    return;
+ 		if((screen->logfd = open(screen->logfile, O_WRONLY | O_APPEND,
+ 					 0644)) < 0)
+ 			return;
  	}
  	screen->logstart = screen->TekEmu ? Tbptr : bptr;
  	screen->logging = TRUE;
***************
*** 587,592 ****
--- 654,660 ----
  		CloseLog(screen);
  }
  #endif /* ALLOWLOGFILEEXEC */
+ #endif /* ALLOWLOGGING */
  
  
  do_osc(func)
***************
*** 626,631 ****
--- 694,700 ----
  		Changetitle(buf);
  		break;
  
+ #ifdef ALLOWLOGGING
  	 case 46:	/* new log file */
  #ifdef ALLOWLOGFILECHANGES
  		/*
***************
*** 643,648 ****
--- 712,718 ----
  		Bell();
  #endif
  		break;
+ #endif /* ALLOWLOGGING */
  
  	case 50:
  		SetVTFont (fontMenu_fontescape, True, buf, NULL);
***************
*** 903,912 ****
--- 973,984 ----
      register TScreen *screen = &term->screen;
  
      if (screen->TekEmu) {
+ #ifdef ALLOWLOGGING
  	if (screen->logging) {
  	    FlushLog (screen);
  	    screen->logstart = buffer;
  	}
+ #endif
  	longjmp(Tekend, 1);
      } 
      return;
***************
*** 917,926 ****
--- 989,1000 ----
      register TScreen *screen = &term->screen;
  
      if (!screen->TekEmu) {
+ #ifdef ALLOWLOGGING
  	if(screen->logging) {
  	    FlushLog(screen);
  	    screen->logstart = Tbuffer;
  	}
+ #endif
  	screen->TekEmu = TRUE;
  	longjmp(VTend, 1);
      } 
*** /tmp/da17839	Wed Nov  3 18:16:38 1993
--- mit/clients/xterm/Tekproc.c	Wed Nov  3 18:16:37 1993
***************
*** 1,5 ****
  /*
!  * $XConsortium: Tekproc.c,v 1.107 91/06/25 19:49:48 gildea Exp $
   *
   * Warning, there be crufty dragons here.
   */
--- 1,5 ----
  /*
!  * $XConsortium: Tekproc.c,v 1.112 93/02/25 17:17:40 gildea Exp $
   *
   * Warning, there be crufty dragons here.
   */
***************
*** 46,51 ****
--- 46,52 ----
  #include <stdio.h>
  #include <errno.h>
  #include <setjmp.h>
+ #include <signal.h>
  
  /*
   * Check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
***************
*** 74,80 ****
  
  #define TekColormap DefaultColormap( screen->display, \
  				    DefaultScreen(screen->display) )
! #define DefaultGCID DefaultGC(screen->display, DefaultScreen(screen->display))->gid
  
  /* Tek defines */
  
--- 75,81 ----
  
  #define TekColormap DefaultColormap( screen->display, \
  				    DefaultScreen(screen->display) )
! #define DefaultGCID XGContextFromGC(DefaultGC(screen->display, DefaultScreen(screen->display)))
  
  /* Tek defines */
  
***************
*** 188,194 ****
--- 189,197 ----
      /* menu actions */
      { "allow-send-events",	HandleAllowSends },
      { "set-visual-bell",	HandleSetVisualBell },
+ #ifdef ALLOWLOGGING
      { "set-logging",		HandleLogging },
+ #endif
      { "redraw",			HandleRedraw },
      { "send-signal",		HandleSendSignal },
      { "quit",			HandleQuit },
***************
*** 335,342 ****
  	register int c, x, y;
  	char ch;
  
! 	for( ; ; )
! 		switch(Tparsestate[c = input()]) {
  		 case CASE_REPORT:
  			/* report address */
  			if(screen->TekGIN) {
--- 338,346 ----
  	register int c, x, y;
  	char ch;
  
! 	for( ; ; ) {
! 	    c = input();
! 	    switch(Tparsestate[c]) {
  		 case CASE_REPORT:
  			/* report address */
  			if(screen->TekGIN) {
***************
*** 356,365 ****
--- 360,371 ----
  			/* special return to vt102 mode */
  			Tparsestate = curstate;
  			TekRecord->ptr[-1] = NAK; /* remove from recording */
+ #ifdef ALLOWLOGGING
  			if(screen->logging) {
  				FlushLog(screen);
  				screen->logstart = buffer;
  			}
+ #endif
  			return;
  
  		 case CASE_SPT_STATE:
***************
*** 626,631 ****
--- 632,638 ----
  			Tparsestate = curstate;
  			break;
  		}
+ 	}
  }			
  
  static int rcnt;
***************
*** 667,675 ****
  				       (int *) NULL, &crocktimeout);
  #endif
  			if(Tselect_mask & pty_mask) {
  				if(screen->logging)
  					FlushLog(screen);
! 				Tbcnt = read(screen->respond, Tbptr = Tbuffer, BUF_SIZE);
  				if(Tbcnt < 0) {
  					if(errno == EIO)
  						Cleanup (0);
--- 674,684 ----
  				       (int *) NULL, &crocktimeout);
  #endif
  			if(Tselect_mask & pty_mask) {
+ #ifdef ALLOWLOGGING
  				if(screen->logging)
  					FlushLog(screen);
! #endif
! 				Tbcnt = read(screen->respond, (char *)(Tbptr = Tbuffer), BUF_SIZE);
  				if(Tbcnt < 0) {
  					if(errno == EIO)
  						Cleanup (0);
***************
*** 1150,1157 ****
   * The following is called the create the tekWidget
   */
  
! static void TekInitialize(request, new)
      Widget request, new;
  {
      /* look for focus related events on the shell, because we need
       * to care about the shell's border being part of our focus.
--- 1159,1168 ----
   * The following is called the create the tekWidget
   */
  
! static void TekInitialize(request, new, args, num_args)
      Widget request, new;
+     ArgList args;
+     Cardinal *num_args;
  {
      /* look for focus related events on the shell, because we need
       * to care about the shell's border being part of our focus.
***************
*** 1549,1565 ****
  }
  
  
  /* write copy of screen to a file */
  
  TekCopy()
  {
- 	register TekLink *Tp;
- 	register int tekcopyfd;
  	register TScreen *screen = &term->screen;
  	register struct tm *tp;
  	long l;
  	char buf[32];
  
  	time(&l);
  	tp = localtime(&l);
  	sprintf(buf, "COPY%02d-%02d-%02d.%02d:%02d:%02d", tp->tm_year,
--- 1560,1585 ----
  }
  
  
+ #ifndef X_NOT_POSIX
+ #define HAS_WAITPID
+ #endif
+ 
  /* write copy of screen to a file */
  
  TekCopy()
  {
  	register TScreen *screen = &term->screen;
  	register struct tm *tp;
  	long l;
  	char buf[32];
+ 	int waited;
+ 	int pid;
+ #ifndef HAS_WAITPID
+ 	int (*chldfunc)();
  
+ 	chldfunc = signal(SIGCHLD, SIG_DFL);
+ #endif
+ 
  	time(&l);
  	tp = localtime(&l);
  	sprintf(buf, "COPY%02d-%02d-%02d.%02d:%02d:%02d", tp->tm_year,
***************
*** 1573,1593 ****
  		Bell();
  		return;
  	}
! 	if((tekcopyfd = open(buf, O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0) {
! 		Bell();
! 		return;
! 	}
! 	chown(buf, screen->uid, screen->gid);
! 	sprintf(buf, "\033%c\033%c", screen->page.fontsize + '8',
! 	 screen->page.linetype + '`');
! 	write(tekcopyfd, buf, 4);
! 	Tp = &Tek0; 
! 	do {
  		write(tekcopyfd, (char *)Tp->data, Tp->count);
  		Tp = Tp->next;
! 	} while(Tp);
! 	close(tekcopyfd);
  }
- 
- 
- 
--- 1593,1645 ----
  		Bell();
  		return;
  	}
! 
! 	/* Write the file in an unprivileged child process because
! 	   using access before the open still leaves a small window
! 	   of opportunity. */
! 	pid = fork();
! 	switch (pid)
! 	{
! 	case 0:			/* child */
! 	{
! 	    register int tekcopyfd;
! 	    char initbuf[5];
! 	    register TekLink *Tp;
! 
! 	    setgid(screen->gid);
! 	    setuid(screen->uid);
! 	    tekcopyfd = open(buf, O_WRONLY | O_CREAT | O_TRUNC, 0666);
! 	    if (tekcopyfd < 0)
! 		_exit(1);
! 	    sprintf(initbuf, "\033%c\033%c", screen->page.fontsize + '8',
! 		    screen->page.linetype + '`');
! 	    write(tekcopyfd, initbuf, 4);
! 	    Tp = &Tek0; 
! 	    do {
  		write(tekcopyfd, (char *)Tp->data, Tp->count);
  		Tp = Tp->next;
! 	    } while(Tp);
! 	    close(tekcopyfd);
! 	    _exit(0);
! 	}
! 	case -1:		/* error */
! 	    Bell();
! 	    return;
! 	default:		/* parent */
! #ifdef HAS_WAITPID
! 	    waitpid(pid, NULL, 0);
! #else
! 	    waited = wait(NULL);
! 	    signal(SIGCHLD, chldfunc);
! 	    /*
! 	      Since we had the signal handler uninstalled for a while,
! 	      we might have missed the termination of our screen child.
! 	      If we can check for this possibility without hanging, do so.
! 	      */
! 	    do
! 		if (waited == term->screen.pid)
! 		    Cleanup(0);
! 	    while ( (waited=nonblocking_wait()) > 0);
! #endif
! 	}
  }
*** /tmp/da17865	Wed Nov  3 18:16:45 1993
--- mit/clients/xterm/main.c	Wed Nov  3 18:16:43 1993
***************
*** 1,5 ****
  #ifndef lint
! static char *rid="$XConsortium: main.c,v 1.200 92/03/11 17:36:12 gildea Exp $";
  #endif /* lint */
  
  /*
--- 1,5 ----
  #ifndef lint
! static char *rid="$XConsortium: main.c,v 1.200.1.1 93/11/02 17:14:14 gildea Exp $";
  #endif /* lint */
  
  /*
***************
*** 490,495 ****
--- 490,496 ----
  {"-fb",		"*boldFont",	XrmoptionSepArg,	(caddr_t) NULL},
  {"-j",		"*jumpScroll",	XrmoptionNoArg,		(caddr_t) "on"},
  {"+j",		"*jumpScroll",	XrmoptionNoArg,		(caddr_t) "off"},
+ /* parse logging options anyway for compatibility */
  {"-l",		"*logging",	XrmoptionNoArg,		(caddr_t) "on"},
  {"+l",		"*logging",	XrmoptionNoArg,		(caddr_t) "off"},
  {"-lf",		"*logFile",	XrmoptionSepArg,	(caddr_t) NULL},
***************
*** 568,575 ****
--- 569,581 ----
  { "-fb fontname",          "bold text font" },
  { "-/+im",		   "use insert mode for TERMCAP" },
  { "-/+j",                  "turn on/off jump scroll" },
+ #ifdef ALLOWLOGGING
  { "-/+l",                  "turn on/off logging" },
  { "-lf filename",          "logging filename" },
+ #else
+ { "-/+l",                  "turn on/off logging (not supported)" },
+ { "-lf filename",          "logging filename (not supported)" },
+ #endif
  { "-/+ls",                 "turn on/off login shell" },
  { "-/+mb",                 "turn on/off margin bell" },
  { "-mc milliseconds",      "multiclick time in milliseconds" },
***************
*** 743,749 ****
  char **argv;
  {
  	register TScreen *screen;
! 	register int i, pty;
  	int Xsocket, mode;
  	char *base_name();
  	int xerror(), xioerror();
--- 749,755 ----
  char **argv;
  {
  	register TScreen *screen;
! 	register int pty;
  	int Xsocket, mode;
  	char *base_name();
  	int xerror(), xioerror();
***************
*** 997,1003 ****
--- 1003,1011 ----
  	}
  
  	inhibit = 0;
+ #ifdef ALLOWLOGGING
  	if (term->misc.logInhibit) 	    inhibit |= I_LOG;
+ #endif
  	if (term->misc.signalInhibit)		inhibit |= I_SIGNAL;
  	if (term->misc.tekInhibit)			inhibit |= I_TEK;
  
***************
*** 1041,1053 ****
  	if(screen->TekEmu && !TekInit())
  		exit(ERROR_INIT);
  
- 	/* set up stderr properly */
- 	i = -1;
  #ifdef DEBUG
! 	if(debug)
! 		i = open ("xterm.debug.log", O_WRONLY | O_CREAT | O_TRUNC,
! 		 0666);
! #endif	/* DEBUG */
  	if(i >= 0) {
  #if defined(USE_SYSV_TERMIO) && !defined(SVR4)
  		/* SYSV has another pointer which should be part of the
--- 1049,1064 ----
  	if(screen->TekEmu && !TekInit())
  		exit(ERROR_INIT);
  
  #ifdef DEBUG
!     {
! 	/* Set up stderr properly.  Opening this log file cannot be
! 	 done securely by a privileged xterm process (although we try),
! 	 so the debug feature is disabled by default. */
! 	int i = -1;
! 	if(debug) {
! 	        creat_as (getuid(), getgid(), "xterm.debug.log", 0666);
! 		i = open ("xterm.debug.log", O_WRONLY | O_TRUNC, 0666);
! 	}
  	if(i >= 0) {
  #if defined(USE_SYSV_TERMIO) && !defined(SVR4)
  		/* SYSV has another pointer which should be part of the
***************
*** 1065,1070 ****
--- 1076,1083 ----
  		/* mark this file as close on exec */
  		(void) fcntl(i, F_SETFD, 1);
  	}
+     }
+ #endif	/* DEBUG */
  
  	/* open a terminal for client */
  	get_terminal ();
***************
*** 1087,1095 ****
--- 1100,1110 ----
  	    write (pty, buf, strlen (buf));
  	}
  
+ #ifdef ALLOWLOGGING
  	if (term->misc.log_on) {
  		StartLog(screen);
  	}
+ #endif
  	screen->inhibit = inhibit;
  
  #ifdef AIXV3
***************
*** 2615,2620 ****
--- 2630,2640 ----
  	int fd;			/* for /etc/wtmp */
  	int i;
  #endif
+ 
+ #ifdef PUCC_PTYD
+ 	closepty(ttydev, ptydev, (resource.utmpInhibit ?  OPTY_NOP : OPTY_LOGIN), Ptyfd);
+ #endif /* PUCC_PTYD */
+ 
  	/* cleanup the utmp entry we forged earlier */
  	if (!resource.utmpInhibit
  #ifdef USE_HANDSHAKE		/* without handshake, no way to know */
***************
*** 2668,2675 ****
--- 2688,2697 ----
  #endif	/* USE_SYSV_UTMP */
  #endif	/* UTMP */
          close(pty); /* close explicitly to avoid race with slave side */
+ #ifdef ALLOWLOGGING
  	if(screen->logging)
  		CloseLog(screen);
+ #endif
  
  	if (!am_slave) {
  		/* restore ownership of tty and pty */
***************
*** 2731,2800 ****
  #endif /* USE_SYSV_ENVVARS */
  }
  
! /* ARGSUSED */
! static SIGNAL_T reapchild (n)
!     int n;
  {
  #ifdef USE_POSIX_WAIT
          pid_t pid;
  
  	pid = waitpid(-1, NULL, WNOHANG);
- 	if (pid <= 0) {
- #ifdef USE_SYSV_SIGNALS
- 		(void) signal(SIGCHLD, reapchild);
- #endif /* USE_SYSV_SIGNALS */
- 		SIGNAL_RETURN;
- 	}
  #else /* USE_POSIX_WAIT */
  #if defined(USE_SYSV_SIGNALS) && (defined(CRAY) || !defined(SIGTSTP))
! 	int status, pid;
! 
! 	pid = wait(&status);
! 	if (pid == -1) {
! 		(void) signal(SIGCHLD, reapchild);
! 		SIGNAL_RETURN;
! 	}
  #else	/* defined(USE_SYSV_SIGNALS) && (defined(CRAY) || !defined(SIGTSTP)) */
  	union wait status;
  	register int pid;
! 	
! #ifdef DEBUG
! 	if (debug) fputs ("Exiting\n", stderr);
! #endif	/* DEBUG */
! 	pid  = wait3 (&status, WNOHANG, (struct rusage *)NULL);
! 	if (!pid) {
! #ifdef USE_SYSV_SIGNALS
! 		(void) signal(SIGCHLD, reapchild);
! #endif /* USE_SYSV_SIGNALS */
! 		SIGNAL_RETURN;
! 	}
  #endif /* defined(USE_SYSV_SIGNALS) && !defined(SIGTSTP) */
  #endif /* USE_POSIX_WAIT else */
  
! #ifdef PUCC_PTYD
! 		closepty(ttydev, ptydev, (resource.utmpInhibit ?  OPTY_NOP : OPTY_LOGIN), Ptyfd);
! #endif /* PUCC_PTYD */
  
! 	if (pid != term->screen.pid) {
  #ifdef USE_SYSV_SIGNALS
! 		(void) signal(SIGCHLD, reapchild);
! #endif	/* USE_SYSV_SIGNALS */
! 		SIGNAL_RETURN;
  	}
! 	
! 	/*
! 	 * Use pid instead of process group (which would have to get before
! 	 * the wait call above) so that we don't accidentally hose other
! 	 * applications.  Otherwise, somebody could write a program which put
! 	 * itself in somebody else's process group.  Also, we call Exit instead
! 	 * of Cleanup so that we don't do a killpg on -1 by accident.  Some
! 	 * operating systems seem to do very nasty things with that.
! 	 */
! 	if (pid > 1) {
! 	    kill_process_group (pid, SIGHUP);
! 	}
! 	Exit (0);
! 	SIGNAL_RETURN;
  }
  
  /* VARARGS1 */
--- 2753,2809 ----
  #endif /* USE_SYSV_ENVVARS */
  }
  
! /*
!  * Does a non-blocking wait for a child process.  If the system
!  * doesn't support non-blocking wait, do nothing.
!  * Returns the pid of the child, or 0 or -1 if none or error.
!  */
! int
! nonblocking_wait()
  {
  #ifdef USE_POSIX_WAIT
          pid_t pid;
  
  	pid = waitpid(-1, NULL, WNOHANG);
  #else /* USE_POSIX_WAIT */
  #if defined(USE_SYSV_SIGNALS) && (defined(CRAY) || !defined(SIGTSTP))
! 	/* cannot do non-blocking wait */
! 	int pid = 0;
  #else	/* defined(USE_SYSV_SIGNALS) && (defined(CRAY) || !defined(SIGTSTP)) */
  	union wait status;
  	register int pid;
! 
! 	pid = wait3 (&status, WNOHANG, (struct rusage *)NULL);
  #endif /* defined(USE_SYSV_SIGNALS) && !defined(SIGTSTP) */
  #endif /* USE_POSIX_WAIT else */
  
! 	return pid;
! }
  
! /* ARGSUSED */
! static SIGNAL_T reapchild (n)
!     int n;
! {
!     int pid;
! 
!     pid = wait(NULL);
! 
  #ifdef USE_SYSV_SIGNALS
!     /* cannot re-enable signal before waiting for child
!        because then SVR4 loops.  Sigh.  HP-UX 9.01 too. */
!     (void) signal(SIGCHLD, reapchild);
! #endif
! 
!     do {
! 	if (pid == term->screen.pid) {
! #ifdef DEBUG
! 	    if (debug) fputs ("Exiting\n", stderr);
! #endif
! 	    Cleanup (0);
  	}
!     } while ( (pid=nonblocking_wait()) > 0);
! 
!     SIGNAL_RETURN;
  }
  
  /* VARARGS1 */
*** /tmp/da17891	Wed Nov  3 18:16:51 1993
--- mit/clients/xterm/charproc.c	Wed Nov  3 18:16:49 1993
***************
*** 1,5 ****
  /*
!  * $XConsortium: charproc.c,v 1.176 92/03/13 18:00:30 gildea Exp $
   */
  
  /*
--- 1,5 ----
  /*
!  * $XConsortium: charproc.c,v 1.176.1.1 93/11/03 17:24:20 gildea Exp $
   */
  
  /*
***************
*** 99,107 ****
--- 99,109 ----
  #define XtNtekGeometry "tekGeometry"
  #define XtNinternalBorder "internalBorder"
  #define XtNjumpScroll "jumpScroll"
+ #ifdef ALLOWLOGGING
  #define XtNlogFile "logFile"
  #define XtNlogging "logging"
  #define XtNlogInhibit "logInhibit"
+ #endif
  #define XtNloginShell "loginShell"
  #define XtNmarginBell "marginBell"
  #define XtNpointerColor "pointerColor"
***************
*** 141,149 ****
--- 143,153 ----
  #define XtCEightBitOutput "EightBitOutput"
  #define XtCGeometry "Geometry"
  #define XtCJumpScroll "JumpScroll"
+ #ifdef ALLOWLOGGING
  #define XtCLogfile "Logfile"
  #define XtCLogging "Logging"
  #define XtCLogInhibit "LogInhibit"
+ #endif
  #define XtCLoginShell "LoginShell"
  #define XtCMarginBell "MarginBell"
  #define XtCMultiClickTime "MultiClickTime"
***************
*** 286,292 ****
--- 290,298 ----
      /* menu actions */
      { "allow-send-events",	HandleAllowSends },
      { "set-visual-bell",	HandleSetVisualBell },
+ #ifdef ALLOWLOGGING
      { "set-logging",		HandleLogging },
+ #endif
      { "redraw",			HandleRedraw },
      { "send-signal",		HandleSendSignal },
      { "quit",			HandleQuit },
***************
*** 377,382 ****
--- 383,389 ----
  {XtNjumpScroll, XtCJumpScroll, XtRBoolean, sizeof(Boolean),
  	XtOffsetOf(XtermWidgetRec, screen.jumpscroll),
  	XtRBoolean, (caddr_t) &defaultTRUE},
+ #ifdef ALLOWLOGGING
  {XtNlogFile, XtCLogfile, XtRString, sizeof(char *),
  	XtOffsetOf(XtermWidgetRec, screen.logfile),
  	XtRString, (caddr_t) NULL},
***************
*** 386,391 ****
--- 393,399 ----
  {XtNlogInhibit, XtCLogInhibit, XtRBoolean, sizeof(Boolean),
  	XtOffsetOf(XtermWidgetRec, misc.logInhibit),
  	XtRBoolean, (caddr_t) &defaultFALSE},
+ #endif
  {XtNloginShell, XtCLoginShell, XtRBoolean, sizeof(Boolean),
  	XtOffsetOf(XtermWidgetRec, misc.login_shell),
  	XtRBoolean, (caddr_t) &defaultFALSE},
***************
*** 1251,1258 ****
--- 1259,1268 ----
  
      for( ; ; ) {
  	if (select_mask & pty_mask && eventMode == NORMAL) {
+ #ifdef ALLOWLOGGING
  	    if (screen->logging)
  		FlushLog(screen);
+ #endif
  	    bcnt = read(screen->respond, (char *)(bptr = buffer), BUF_SIZE);
  	    if (bcnt < 0) {
  		if (errno == EIO)
***************
*** 1589,1598 ****
--- 1599,1610 ----
  			break;
  		case 38:		/* DECTEK			*/
  			if(func == bitset && !(screen->inhibit & I_TEK)) {
+ #ifdef ALLOWLOGGING
  				if(screen->logging) {
  					FlushLog(screen);
  					screen->logstart = Tbuffer;
  				}
+ #endif
  				screen->TekEmu = TRUE;
  			}
  			break;
***************
*** 1614,1619 ****
--- 1626,1632 ----
  			(*func)(&termw->flags, REVERSEWRAP);
  			update_reversewrap();
  			break;
+ #ifdef ALLOWLOGGING
  		case 46:		/* logging		*/
  #ifdef ALLOWLOGFILEONOFF
  			/*
***************
*** 1629,1634 ****
--- 1642,1648 ----
  			Bell();
  #endif /* ALLOWLOGFILEONOFF */
  			break;
+ #endif
  		case 47:		/* alternate buffer */
  			if (!termw->misc.titeInhibit) {
  			    if(func == bitset)
***************
*** 1703,1711 ****
--- 1717,1727 ----
  		case 45:		/* reverse wraparound	*/
  			screen->save_modes[13] = termw->flags & REVERSEWRAP;
  			break;
+ #ifdef ALLOWLOGGING
  		case 46:		/* logging		*/
  			screen->save_modes[14] = screen->logging;
  			break;
+ #endif
  		case 47:		/* alternate buffer		*/
  			screen->save_modes[15] = screen->alternate;
  			break;
***************
*** 1820,1825 ****
--- 1836,1842 ----
  			termw->flags |= screen->save_modes[13] & REVERSEWRAP;
  			update_reversewrap();
  			break;
+ #ifdef ALLOWLOGGING
  		case 46:		/* logging		*/
  #ifdef ALLOWLOGFILEONOFF
  			if(screen->save_modes[14])
***************
*** 1829,1834 ****
--- 1846,1852 ----
  #endif /* ALLOWLOGFILEONOFF */
  			/* update_logging done by StartLog and CloseLog */
  			break;
+ #endif
  		case 47:		/* alternate buffer */
  			if (!termw->misc.titeInhibit) {
  			    if(screen->save_modes[15])
***************
*** 2171,2177 ****
--- 2189,2197 ----
     new->screen.cursorcolor = request->screen.cursorcolor;
     new->screen.border = request->screen.border;
     new->screen.jumpscroll = request->screen.jumpscroll;
+ #ifdef ALLOWLOGGING
     new->screen.logfile = request->screen.logfile;
+ #endif
     new->screen.marginbell = request->screen.marginbell;
     new->screen.mousecolor = request->screen.mousecolor;
     new->screen.mousecolorback = request->screen.mousecolorback;
*** /tmp/da17918	Wed Nov  3 18:16:54 1993
--- mit/clients/xterm/ptyx.h	Wed Nov  3 18:16:54 1993
***************
*** 1,5 ****
  /*
!  *	$XConsortium: ptyx.h,v 1.60 91/06/24 20:45:02 gildea Exp $
   */
  
  /*
--- 1,5 ----
  /*
!  *	$XConsortium: ptyx.h,v 1.60.1.1 93/11/03 17:29:39 gildea Exp $
   */
  
  /*
***************
*** 216,227 ****
  					/* and position information	*/
  	int		select;		/* xterm selected		*/
  	Boolean		visualbell;	/* visual bell mode		*/
- 	int		logging;	/* logging mode			*/
  	Boolean		allowSendEvents;/* SendEvent mode		*/
  	Boolean		grabbedKbd;	/* keyboard is grabbed		*/
  	int		logfd;		/* file descriptor of log	*/
  	char		*logfile;	/* log file name		*/
  	unsigned char	*logstart;	/* current start of log buffer	*/
  	int		inhibit;	/* flags for inhibiting changes	*/
  
  /* VT window parameters */
--- 216,229 ----
  					/* and position information	*/
  	int		select;		/* xterm selected		*/
  	Boolean		visualbell;	/* visual bell mode		*/
  	Boolean		allowSendEvents;/* SendEvent mode		*/
  	Boolean		grabbedKbd;	/* keyboard is grabbed		*/
+ #ifdef ALLOWLOGGING
+ 	int		logging;	/* logging mode			*/
  	int		logfd;		/* file descriptor of log	*/
  	char		*logfile;	/* log file name		*/
  	unsigned char	*logstart;	/* current start of log buffer	*/
+ #endif
  	int		inhibit;	/* flags for inhibiting changes	*/
  
  /* VT window parameters */
***************
*** 380,386 ****
--- 382,390 ----
      char *T_geometry;
      char *f_n;
      char *f_b;
+ #ifdef ALLOWLOGGING
      Boolean log_on;
+ #endif
      Boolean login_shell;
      Boolean re_verse;
      int resizeGravity;
***************
*** 522,528 ****
--- 526,534 ----
  #define	TOGGLE		1
  
  /* flags for inhibit */
+ #ifdef ALLOWLOGGING
  #define	I_LOG		0x01
+ #endif
  #define	I_SIGNAL	0x02
  #define	I_TEK		0x04
  
*** /tmp/da17942	Wed Nov  3 18:16:57 1993
--- mit/clients/xterm/data.c	Wed Nov  3 18:16:56 1993
***************
*** 1,5 ****
  /*
!  *	$XConsortium: data.c,v 1.10 91/02/06 14:23:58 gildea Exp $
   */
  
  /*
--- 1,5 ----
  /*
!  *	$XConsortium: data.c,v 1.11 93/02/25 17:21:27 gildea Exp $
   */
  
  /*
***************
*** 89,95 ****
--- 89,97 ----
  int X_mask;
  char *ptydev;
  char *ttydev;
+ #ifdef ALLOWLOGGING
  char log_def_name[] = "XtermLog.XXXXX";
+ #endif
  int T_lastx = -1;
  int T_lasty = -1;
  
*** /tmp/da17966	Wed Nov  3 18:16:59 1993
--- mit/clients/xterm/data.h	Wed Nov  3 18:16:58 1993
***************
*** 1,5 ****
  /*
!  *	$XConsortium: data.h,v 1.9 91/02/05 19:44:30 gildea Exp $
   */
  /*
   * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
--- 1,5 ----
  /*
!  *	$XConsortium: data.h,v 1.10 93/02/25 17:21:28 gildea Exp $
   */
  /*
   * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
***************
*** 35,41 ****
--- 35,43 ----
  extern Char *Tpushb;
  extern Char *Tpushback;
  extern Char *bptr;
+ #ifdef ALLOWLOGGING
  extern char log_def_name[];
+ #endif
  extern char *ptydev;
  extern char *ttydev;
  extern char *xterm_name;
*** /tmp/da17990	Wed Nov  3 18:17:01 1993
--- mit/clients/xterm/error.h	Wed Nov  3 18:17:00 1993
***************
*** 1,5 ****
  /*
!  *	$XConsortium: error.h,v 1.8 91/07/17 17:43:54 rws Exp $
   */
  
  
--- 1,5 ----
  /*
!  *	$XConsortium: error.h,v 1.9 93/02/25 17:21:29 gildea Exp $
   */
  
  
***************
*** 77,83 ****
--- 77,87 ----
  #define	ERROR_BMALLOC2	71	/* SaltTextAway: malloc() failed */
  
  /* misc.c */
+ #ifdef ALLOWLOGGING
+ #ifdef ALLOWLOGFILEEXEC
  #define	ERROR_LOGEXEC	80	/* StartLog: exec() failed */
+ #endif
+ #endif
  #define	ERROR_XERROR	83	/* xerror: XError event */
  #define	ERROR_XIOERROR	84	/* xioerror: X I/O error */
  #define ERROR_WINNAME   85      /* get_terminal: malloc failed */
*** /tmp/da18014	Wed Nov  3 18:17:03 1993
--- mit/clients/xterm/menu.c	Wed Nov  3 18:17:03 1993
***************
*** 1,4 ****
! /* $XConsortium: menu.c,v 1.61 92/04/20 18:46:39 rws Exp $ */
  /*
  Copyright 1989 Massachusetts Institute of Technology
  
--- 1,4 ----
! /* $XConsortium: menu.c,v 1.62 93/02/25 17:21:30 gildea Exp $ */
  /*
  Copyright 1989 Massachusetts Institute of Technology
  
***************
*** 32,38 ****
  
  void do_hangup();
  
! static void do_securekbd(), do_allowsends(), do_visualbell(), do_logging(),
      do_redraw(), do_suspend(), do_continue(), do_interrupt(), 
      do_terminate(), do_kill(), do_quit(), do_scrollbar(), do_jumpscroll(),
      do_reversevideo(), do_autowrap(), do_reversewrap(), do_autolinefeed(),
--- 32,41 ----
  
  void do_hangup();
  
! static void do_securekbd(), do_allowsends(), do_visualbell(),
! #ifdef ALLOWLOGGING
!     do_logging(),
! #endif
      do_redraw(), do_suspend(), do_continue(), do_interrupt(), 
      do_terminate(), do_kill(), do_quit(), do_scrollbar(), do_jumpscroll(),
      do_reversevideo(), do_autowrap(), do_reversewrap(), do_autolinefeed(),
***************
*** 51,57 ****
--- 54,62 ----
  MenuEntry mainMenuEntries[] = {
      { "securekbd",	do_securekbd, NULL },		/*  0 */
      { "allowsends",	do_allowsends, NULL },		/*  1 */
+ #ifdef ALLOWLOGGING
      { "logging",	do_logging, NULL },		/*  2 */
+ #endif
      { "redraw",		do_redraw, NULL },		/*  3 */
      { "line1",		NULL, NULL },			/*  4 */
      { "suspend",	do_suspend, NULL },		/*  5 */
***************
*** 155,161 ****
--- 160,168 ----
  					    XtNumber(mainMenuEntries));
  	    update_securekbd();
  	    update_allowsends();
+ #ifdef ALLOWLOGGING
  	    update_logging();
+ #endif
  #ifndef SIGTSTP
  	    set_sensitivity (screen->mainMenu,
  			     mainMenuEntries[mainMenu_suspend].widget, FALSE);
***************
*** 358,363 ****
--- 365,371 ----
      update_visualbell();
  }
  
+ #ifdef ALLOWLOGGING
  static void do_logging (gw, closure, data)
      Widget gw;
      caddr_t closure, data;
***************
*** 371,378 ****
      }
      /* update_logging done by CloseLog and StartLog */
  }
  
- 
  static void do_redraw (gw, closure, data)
      Widget gw;
      caddr_t closure, data;
--- 379,386 ----
      }
      /* update_logging done by CloseLog and StartLog */
  }
+ #endif
  
  static void do_redraw (gw, closure, data)
      Widget gw;
      caddr_t closure, data;
***************
*** 879,884 ****
--- 887,893 ----
  		   params, *param_count, w, NULL, NULL);
  }
  
+ #ifdef ALLOWLOGGING
  void HandleLogging(w, event, params, param_count)
      Widget w;
      XEvent *event;
***************
*** 888,893 ****
--- 897,903 ----
      handle_toggle (do_logging, (int) term->screen.logging,
  		   params, *param_count, w, NULL, NULL);
  }
+ #endif
  
  /* ARGSUSED */
  void HandleRedraw(w, event, params, param_count)
*** /tmp/da18038	Wed Nov  3 18:17:06 1993
--- mit/clients/xterm/menu.h	Wed Nov  3 18:17:05 1993
***************
*** 1,4 ****
! /* $XConsortium: menu.h,v 1.23 91/06/25 19:49:44 gildea Exp $ */
  
  /* Copyright 1989 Massachusetts Institute of Technology */
  
--- 1,4 ----
! /* $XConsortium: menu.h,v 1.24 93/02/25 17:21:31 gildea Exp $ */
  
  /* Copyright 1989 Massachusetts Institute of Technology */
  
***************
*** 26,32 ****
--- 26,34 ----
  
  extern void HandleAllowSends();
  extern void HandleSetVisualBell();
+ #ifdef ALLOWLOGGING
  extern void HandleLogging();
+ #endif
  extern void HandleRedraw();
  extern void HandleSendSignal();
  extern void HandleQuit();
***************
*** 65,71 ****
--- 67,75 ----
   */
  #define mainMenu_securekbd 0
  #define mainMenu_allowsends 1
+ #ifdef ALLOWLOGGING
  #define mainMenu_logging 2
+ #endif
  #define mainMenu_redraw 3
  #define mainMenu_line1 4
  #define mainMenu_suspend 5
***************
*** 169,179 ****
  		    mainMenuEntries[mainMenu_allowsends].widget, \
  		    term->screen.allowSendEvents)
  
  #define update_logging() \
    update_menu_item (term->screen.mainMenu, \
  		    mainMenuEntries[mainMenu_logging].widget, \
  		    term->screen.logging)
! 
  
  #define update_scrollbar() \
    update_menu_item (term->screen.vtMenu, \
--- 173,184 ----
  		    mainMenuEntries[mainMenu_allowsends].widget, \
  		    term->screen.allowSendEvents)
  
+ #ifdef ALLOWLOGGING
  #define update_logging() \
    update_menu_item (term->screen.mainMenu, \
  		    mainMenuEntries[mainMenu_logging].widget, \
  		    term->screen.logging)
! #endif
  
  #define update_scrollbar() \
    update_menu_item (term->screen.vtMenu, \
*** /tmp/da18064	Wed Nov  3 18:17:09 1993
--- mit/clients/xterm/xterm.man	Wed Nov  3 18:17:08 1993
***************
*** 1,4 ****
! .\" $XConsortium: xterm.man,v 1.72 91/08/23 18:46:18 gildea Exp $
  .TH XTERM 1 "Release 5" "X Version 11"
  .SH NAME
  xterm \- terminal emulator for X
--- 1,4 ----
! .\" $XConsortium: xterm.man,v 1.72.1.1 93/11/03 18:03:48 gildea Exp $
  .TH XTERM 1 "Release 5" "X Version 11"
  .SH NAME
  xterm \- terminal emulator for X
***************
*** 39,45 ****
  .PP
  Many of the special
  .I xterm
! features (like logging) may be modified under program control
  through a set of escape sequences different from the standard VT102 escape
  sequences.  
  (See the
--- 39,45 ----
  .PP
  Many of the special
  .I xterm
! features may be modified under program control
  through a set of escape sequences different from the standard VT102 escape
  sequences.  
  (See the
***************
*** 93,103 ****
  on exit.  
  .PP
  In either VT102 or Tektronix mode, there are escape sequences to change the
! name of the windows and to specify a new log file name.
  See \fIXterm Control Sequences\fP for details.
- Enabling the escape sequence to change the
- log file name is a compile-time option;
- by default this escape sequence is ignored for security reasons.
  .SH OPTIONS
  The \fIxterm\fP terminal emulator 
  accepts all of the standard X Toolkit command line options as well as
--- 93,100 ----
  on exit.  
  .PP
  In either VT102 or Tektronix mode, there are escape sequences to change the
! name of the windows.
  See \fIXterm Control Sequences\fP for details.
  .SH OPTIONS
  The \fIxterm\fP terminal emulator 
  accepts all of the standard X Toolkit command line options as well as
***************
*** 203,227 ****
  .B \+j
  This option indicates that \fIxterm\fP should not do jump scrolling.
  .TP 8
- .B \-l
- This option indicates that \fIxterm\fP should send all terminal output to
- a log file as well as to the screen.  This option can be enabled or disabled
- using the ``VT Options'' menu.
- .TP 8
- .B \+l
- This option indicates that \fIxterm\fP should not do logging.
- .TP 8
- .BI \-lf " filename"
- This option specifies the name of the file to which the output log described
- above is written.  If \fIfile\fP begins with a pipe symbol (|), the rest of 
- the string is assumed to be a command to be used as the endpoint of a pipe.
- The ability to log to a pipe is a compile-time option which is
- disabled by default for security reasons.
- The default filename is ``\fBXtermLog.\fIXXXXX\fR'' (where \fIXXXXX\fP
- is the process id of \fIxterm\fP) and is created in the directory from which
- \fIxterm\fP was started (or the user's home directory in the case of a
- login window).
- .TP 8
  .B \-ls
  This option indicates that the shell that is started in the \fIxterm\fP window
  be a login shell (i.e. the first character of argv[0] will be a dash,
--- 200,205 ----
***************
*** 634,652 ****
  .B "jumpScroll (\fPclass\fB JumpScroll)"
  Specifies whether or not jump scroll should be used.  The default is ``true.''
  .TP 8
- .B "logFile (\fPclass\fB Logfile)"
- Specifies the name of the file to which a terminal session is logged.  The
- default is ``\fBXtermLog.\fIXXXXX\fR'' (where \fIXXXXX\fP
- is the process id of \fIxterm\fP).
- .TP 8
- .B "logging (\fPclass\fB Logging)"
- Specifies whether or not a terminal session should be logged.  The default is
- ``false.''
- .TP 8
- .B "logInhibit (\fPclass\fB LogInhibit)"
- Specifies whether or not terminal session logging should be inhibited.  The
- default is ``false.''
- .TP 8
  .B "loginShell (\fPclass\fB LoginShell)"
  Specifies whether or not the shell to be run in the window should be started
  as a login shell.  The default is ``false.''
--- 612,617 ----
***************
*** 804,812 ****
  .B "allowsends (\fPclass\fB SmeBSB)"
  This entry invokes the \fBallow-send-events(toggle)\fP action.
  .TP 8
- .B "logging (\fPclass\fB SmeBSB)"
- This entry invokes the \fBset-logging(toggle)\fP action.
- .TP 8
  .B "redraw (\fPclass\fB SmeBSB)"
  This entry invokes the \fBredraw()\fP action.
  .TP 8
--- 769,774 ----
***************
*** 1375,1384 ****
  This action set or toggles the \fBallowSendEvents\fP resource and is also
  invoked by the \fBallowsends\fP entry in \fImainMenu\fP.
  .TP 8
- .B "set-logging(\fIon/off/toggle\fP)"
- This action toggles the \fBlogging\fP resource and is also invoked
- by the \fBlogging\fP entry in \fImainMenu\fP.
- .TP 8
  .B "redraw()"
  This action redraws the window and is also invoked by the
  \fIredraw\fP entry in \fImainMenu\fP.
--- 1337,1342 ----
***************
*** 1630,1637 ****
  widgets that don't know about each other.  Ideally, you'd like to be able to
  pick and choose emulator widgets and stick them into a single control widget.
  .PP
! There needs to be a dialog box to allow entry of log file name
! and the COPY file name.
  .SH COPYRIGHT
  Copyright 1989, Massachusetts Institute of Technology.
  .br
--- 1588,1594 ----
  widgets that don't know about each other.  Ideally, you'd like to be able to
  pick and choose emulator widgets and stick them into a single control widget.
  .PP
! There needs to be a dialog box to allow entry of the Tek COPY file name.
  .SH COPYRIGHT
  Copyright 1989, Massachusetts Institute of Technology.
  .br
*** /tmp/da4081	Wed Nov  3 18:08:41 1993
--- mit/lib/Xt/Convert.c	Wed Nov  3 18:08:40 1993
***************
*** 1,4 ****
! /* $XConsortium: Convert.c,v 1.67 92/08/31 17:02:24 converse Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
--- 1,4 ----
! /* $XConsortium: Convert.c,v 1.68 93/07/12 14:52:00 converse Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
***************
*** 994,999 ****
--- 994,1001 ----
  	    CEXT(p->next)->prev = CEXT(p)->prev;
      } else {
  	*prev = p->next;
+ 	if (p->next && p->next->has_ext)
+ 	    CEXT(p->next)->prev = prev;
      }
      if (p->must_be_freed) {
  	register int i;
*** /tmp/da4177	Wed Nov  3 18:09:58 1993
--- mit/lib/Xt/Keyboard.c	Wed Nov  3 18:09:57 1993
***************
*** 1,4 ****
! /* $XConsortium: Keyboard.c,v 1.26 92/10/06 14:01:53 converse Exp $ */
  
  /********************************************************
  
--- 1,4 ----
! /* $XConsortium: Keyboard.c,v 1.28 93/07/14 14:38:07 converse Exp $ */
  
  /********************************************************
  
***************
*** 689,699 ****
      XtPointer call_data;
  {
      XtSetKeyboardFocus((Widget)closure, None);
-     /* invalidate FindKeyDestination's ancestor list if it is still for us */
-     if (pseudoTraceDepth &&
- 	pseudoTraceDisplay == XtDisplay((Widget)closure) &&
- 	_GetWindowedAncestor(widget) == pseudoTrace[0])
- 	pseudoTraceDepth = 0;
  }
  
  void XtSetKeyboardFocus(widget, descendant)
--- 689,694 ----
***************
*** 719,728 ****
  	/* all the rest handles focus ins and focus outs and misc gunk */
  	
  	if (oldDesc) {
! 	    if (!oldDesc->core.being_destroyed) {
! 		XtRemoveCallback (oldDesc, XtNdestroyCallback, 
! 				  FocusDestroyCallback, (XtPointer) widget);
! 	    }
  
  	    if (!oldTarget->core.being_destroyed) {
  		if (pwi->map_handler_added) {
--- 714,726 ----
  	/* all the rest handles focus ins and focus outs and misc gunk */
  	
  	if (oldDesc) {
! 	    /* invalidate FindKeyDestination's ancestor list */
! 	    if (pseudoTraceDepth && pseudoTraceDisplay == XtDisplay(widget) &&
! 		oldTarget == pseudoTrace[0])
! 		pseudoTraceDepth = 0;
! 
! 	    XtRemoveCallback(oldDesc, XtNdestroyCallback, 
! 			     FocusDestroyCallback, (XtPointer)widget);
  
  	    if (!oldTarget->core.being_destroyed) {
  		if (pwi->map_handler_added) {
*** /tmp/da26059	Wed Nov  3 18:10:11 1993
--- mit/lib/Xt/fd.h	Wed Nov  3 18:10:10 1993
***************
*** 1,5 ****
  /*
! * $XConsortium: fd.h,v 1.14 89/10/05 13:32:53 swick Exp $
  * $oHeader: fd.h,v 1.4 88/08/26 14:49:54 asente Exp $
  */
  
--- 1,5 ----
  /*
! * $XConsortium: fd.h,v 1.15 93/07/08 13:29:55 kaleb Exp $
  * $oHeader: fd.h,v 1.4 88/08/26 14:49:54 asente Exp $
  */
  
***************
*** 30,36 ****
  #ifndef _Xt_fd_set
  #define _Xt_fd_set
  
! #if defined(CRAY) && !defined(FD_SETSIZE)
  #include <sys/select.h>		/* defines FD stuff except howmany() */
  #endif
  
--- 30,36 ----
  #ifndef _Xt_fd_set
  #define _Xt_fd_set
  
! #if (defined(SVR4) || defined(CRAY) || defined(AIXV3)) && !defined(FD_SETSIZE)
  #include <sys/select.h>		/* defines FD stuff except howmany() */
  #endif
  
*** /tmp/da26095	Wed Nov  3 18:19:14 1993
--- mit/lib/Xt/TranslateI.h	Wed Nov  3 18:19:13 1993
***************
*** 1,4 ****
! /* $XConsortium: TranslateI.h,v 1.45 92/12/22 17:17:33 converse Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
--- 1,4 ----
! /* $XConsortium: TranslateI.h,v 1.46 93/08/18 11:26:41 kaleb Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
***************
*** 112,118 ****
      unsigned int	isSimple:1;
      unsigned int	hasActions:1;
      unsigned int	hasCycles:1;
!     int			more:13;
      TMShortCard		typeIndex;
      TMShortCard		modIndex;
  }TMBranchHeadRec, *TMBranchHead;
--- 112,118 ----
      unsigned int	isSimple:1;
      unsigned int	hasActions:1;
      unsigned int	hasCycles:1;
!     unsigned int	more:13;
      TMShortCard		typeIndex;
      TMShortCard		modIndex;
  }TMBranchHeadRec, *TMBranchHead;
*** /tmp/da26122	Wed Nov  3 18:20:27 1993
--- mit/lib/Xt/InitialI.h	Wed Nov  3 18:20:26 1993
***************
*** 1,4 ****
! /* $XConsortium: InitialI.h,v 1.64 93/01/08 16:04:57 converse Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
--- 1,4 ----
! /* $XConsortium: InitialI.h,v 1.64.1.1 93/07/20 16:26:20 kaleb Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
***************
*** 140,145 ****
--- 140,146 ----
      DestroyRec* destroy_list;
      Widget in_phase2_destroy;
      LangProcRec langProcRec;
+     struct _TMBindCacheRec * free_bindings;
  } XtAppStruct;
  
  #ifdef XTTRACEMEMORY
***************
*** 343,348 ****
--- 344,355 ----
  #if NeedFunctionPrototypes
      XtAppContext /* app */,
      int		 /* dispatch_level */
+ #endif
+ );
+ 
+ extern void _XtDoFreeBindings(
+ #if NeedFunctionPrototypes
+     XtAppContext /* app */
  #endif
  );
  
*** /tmp/da26150	Wed Nov  3 18:21:29 1993
--- mit/lib/Xt/Display.c	Wed Nov  3 18:21:27 1993
***************
*** 1,4 ****
! /* $XConsortium: Display.c,v 1.89 93/03/15 15:27:35 converse Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
--- 1,4 ----
! /* $XConsortium: Display.c,v 1.89.1.1 93/07/20 16:32:36 kaleb Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
***************
*** 325,330 ****
--- 325,331 ----
  #ifndef NO_IDENTIFY_WINDOWS
  	app->identify_windows = False;
  #endif
+ 	app->free_bindings = NULL;
  	return app;
  }
  
***************
*** 355,360 ****
--- 356,362 ----
  	*prev_app = app->next;
  	if (app->process->defaultAppContext == app)
  	    app->process->defaultAppContext = NULL;
+ 	if (app->free_bindings) _XtDoFreeBindings (app);
  	XtFree((char *)app);
  }
  
*** /tmp/da26177	Wed Nov  3 18:22:35 1993
--- mit/lib/Xt/TMaction.c	Wed Nov  3 18:22:33 1993
***************
*** 1,4 ****
! /* $XConsortium: TMaction.c,v 1.18 93/05/13 15:14:24 converse Exp $ */
  /*LINTLIBRARY*/
  
  /***********************************************************
--- 1,4 ----
! /* $XConsortium: TMaction.c,v 1.18.1.1 93/07/20 16:43:49 kaleb Exp $ */
  /*LINTLIBRARY*/
  
  /***********************************************************
***************
*** 419,424 ****
--- 419,425 ----
      Widget		w;
      XtActionProc 	*procs;
  {
+     XtAppContext	app = XtWidgetToApplicationContext (w);
      TMClassCache	classCache = GetClassCache(w);
      TMBindCache		*bindCachePtr = (TMBindCache *)&classCache->bindCache;
      TMBindCache		bindCache;
***************
*** 448,454 ****
  			_XtGlobalTM.numBindCache--;
  #endif /* TRACE_TM */
  		      *bindCachePtr = bindCache->next;
! 		      XtFree((XtPointer)bindCache);
  		  }
  		break;
  	    }
--- 449,456 ----
  			_XtGlobalTM.numBindCache--;
  #endif /* TRACE_TM */
  		      *bindCachePtr = bindCache->next;
! 		      bindCache->next = app->free_bindings;
! 		      app->free_bindings = bindCache;
  		  }
  		break;
  	    }
***************
*** 942,945 ****
--- 944,957 ----
      }
  }
  
+ void _XtDoFreeBindings(app)
+     XtAppContext app;
+ {
+     TMBindCache bcp;
  
+     while (app->free_bindings) {
+ 	bcp = app->free_bindings->next;
+ 	XtFree ((char *) app->free_bindings);
+ 	app->free_bindings = bcp;
+     }
+ }
*** /tmp/da26204	Wed Nov  3 18:23:42 1993
--- mit/lib/Xt/Event.c	Wed Nov  3 18:23:38 1993
***************
*** 1,4 ****
! /* $XConsortium: Event.c,v 1.137 92/11/19 17:24:47 converse Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
--- 1,4 ----
! /* $XConsortium: Event.c,v 1.137.1.1 93/07/20 16:35:37 kaleb Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
***************
*** 1085,1090 ****
--- 1085,1091 ----
      if (_XtSafeToDestroy(app)) {
  	if (_XtAppDestroyCount != 0) _XtDestroyAppContexts();
  	if (_XtDpyDestroyCount != 0) _XtCloseDisplays();
+ 	if (app->free_bindings) _XtDoFreeBindings(app);
      }
      
      return (was_dispatched != XtDidNothing);
*** /tmp/da12861	Thu Nov  4 12:03:24 1993
--- mit/lib/Xt/TMparse.c	Thu Nov  4 12:03:22 1993
***************
*** 1,4 ****
! /* $XConsortium: TMparse.c,v 1.134 92/12/30 13:02:26 converse Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
--- 1,4 ----
! /* $XConsortium: TMparse.c,v 1.135 93/08/05 11:54:10 kaleb Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
***************
*** 1925,1930 ****
--- 1925,1932 ----
        return (XtTranslations)NULL;
  
      source = CheckForPoundSign(source, defaultOp, &actualOp);
+     if (isAccelerator && actualOp == XtTableReplace)
+ 	actualOp = defaultOp;
  
      parseTree->isSimple = True;
      parseTree->mappingNotifyInterest = False;
