changeset 6875:1862df471cac

(make_lispy_event): Put mouse event code into MULTI_FRAME conditional. (read_avail_input): Separate local var n_to_read so that reading doesn't clobber that info when it sets nread.
author Richard M. Stallman <rms@gnu.org>
date Thu, 14 Apr 1994 11:59:28 +0000
parents 12dcd89cfd88
children 92cef0f29878
files src/keyboard.c
diffstat 1 files changed, 17 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/keyboard.c	Thu Apr 14 09:31:42 1994 +0000
+++ b/src/keyboard.c	Thu Apr 14 11:59:28 1994 +0000
@@ -2464,6 +2464,7 @@
 				   / sizeof (lispy_function_keys[0])));
       break;
 
+#ifdef MULTI_FRAME
       /* A mouse click.  Figure out where it is, decide whether it's 
          a press, click or drag, and build the appropriate structure.  */
     case mouse_click:
@@ -2692,6 +2693,7 @@
 				 Qnil));
 	}
       }
+#endif /* MULTI_FRAME */
 
       /* The 'kind' field of the event is something we don't recognize.  */
     default:
@@ -3301,14 +3303,17 @@
 	 the kbd_buffer can really hold.  That may prevent loss
 	 of characters on some systems when input is stuffed at us.  */
       unsigned char cbuf[KBD_BUFFER_SIZE - 1];
-
+      int n_to_read;
+
+      /* Determine how many characters we should *try* to read.  */
 #ifdef MSDOS
-      nread = dos_keysns ();
-      if (nread == 0) return 0;
+      n_to_read = dos_keysns ();
+      if (n_to_read == 0)
+	return 0;
 #else */ not MSDOS */
 #ifdef FIONREAD
       /* Find out how much input is available.  */
-      if (ioctl (0, FIONREAD, &nread) < 0)
+      if (ioctl (0, FIONREAD, &n_to_read) < 0)
 	/* Formerly simply reported no input, but that sometimes led to
 	   a failure of Emacs to terminate.
 	   SIGHUP seems appropriate if we can't reach the terminal.  */
@@ -3316,14 +3321,14 @@
 	   rather than to the whole process group?
 	   Perhaps on systems with FIONREAD Emacs is alone in its group.  */
 	kill (getpid (), SIGHUP);
-      if (nread == 0)
+      if (n_to_read == 0)
 	return 0;
-      if (nread > sizeof cbuf)
-	nread = sizeof cbuf;
+      if (n_to_read > sizeof cbuf)
+	n_to_read = sizeof cbuf;
 #else /* no FIONREAD */
 #if defined(USG) || defined(DGUX)
       /* Read some input if available, but don't wait.  */
-      nread = sizeof cbuf;
+      n_to_read = sizeof cbuf;
       fcntl (fileno (stdin), F_SETFL, O_NDELAY);
 #else
       you lose;
@@ -3331,14 +3336,15 @@
 #endif
 #endif /* not MSDOS */
 
-      /* Now read; for one reason or another, this will not block.  */
+      /* Now read; for one reason or another, this will not block.
+	 NREAD is set to the number of chars read.  */
       while (1)
 	{
 #ifdef MSDOS
 	  cbuf[0] = dos_keyread();
 	  nread = 1;
 #else
-	  nread = read (fileno (stdin), cbuf, nread);
+	  nread = read (fileno (stdin), cbuf, n_to_read);
 #endif
 #ifdef AIX
 	  /* The kernel sometimes fails to deliver SIGHUP for ptys.
@@ -3348,9 +3354,7 @@
 	  if (nread == 0)
 	    kill (0, SIGHUP);
 #endif
-	  /* This code is wrong, but at least it gets the right results.
-	     Fix it for 19.23.  */
-	  /* Retry the read if it is interrupted.  */
+	  /* Retry the read if it was interrupted.  */
 	  if (nread >= 0
 	      || ! (errno == EAGAIN 
 #ifdef EFAULT