changeset 53657:4d786e2695ba

(handle_async_input): New fun, extracted from input_available_signal. (input_available_signal, reinvoke_input_signal): Use it.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 21 Jan 2004 05:15:12 +0000
parents f2b9a3d38bf2
children c6460069583e
files src/keyboard.c
diffstat 1 files changed, 31 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/keyboard.c	Wed Jan 21 05:03:24 2004 +0000
+++ b/src/keyboard.c	Wed Jan 21 05:15:12 2004 +0000
@@ -1,5 +1,5 @@
 /* Keyboard and mouse input; editor command loop.
-   Copyright (C) 1985,86,87,88,89,93,94,95,96,97,99,2000,01,02,03
+   Copyright (C) 1985,86,87,88,89,93,94,95,96,97,99,2000,01,02,03,04
      Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -6747,6 +6747,30 @@
 }
 #endif /* not VMS */
 
+void
+handle_async_input ()
+{
+#ifdef BSD4_1
+  extern int select_alarmed;
+#endif
+  interrupt_input_pending = 0;
+
+  while (1)
+    {
+      int nread;
+      nread = read_avail_input (1);
+      /* -1 means it's not ok to read the input now.
+	 UNBLOCK_INPUT will read it later; now, avoid infinite loop.
+	 0 means there was no keyboard input available.  */
+      if (nread <= 0)
+	break;
+
+#ifdef BSD4_1
+      select_alarmed = 1;  /* Force the select emulator back to life */
+#endif
+    }
+}
+
 #ifdef SIGIO   /* for entire page */
 /* Note SIGIO has been undef'd if FIONREAD is missing.  */
 
@@ -6756,9 +6780,6 @@
 {
   /* Must preserve main program's value of errno.  */
   int old_errno = errno;
-#ifdef BSD4_1
-  extern int select_alarmed;
-#endif
 
 #if defined (USG) && !defined (POSIX_SIGNALS)
   /* USG systems forget handlers when they are used;
@@ -6773,20 +6794,11 @@
   if (input_available_clear_time)
     EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
 
-  while (1)
-    {
-      int nread;
-      nread = read_avail_input (1);
-      /* -1 means it's not ok to read the input now.
-	 UNBLOCK_INPUT will read it later; now, avoid infinite loop.
-	 0 means there was no keyboard input available.  */
-      if (nread <= 0)
-	break;
-
-#ifdef BSD4_1
-      select_alarmed = 1;  /* Force the select emulator back to life */
-#endif
-    }
+#ifdef SYNC_INPUT
+  interrupt_input_pending = 1;
+#else
+  handle_async_input ();
+#endif
 
 #ifdef BSD4_1
   sigfree ();
@@ -6805,7 +6817,7 @@
 reinvoke_input_signal ()
 {
 #ifdef SIGIO
-  kill (getpid (), SIGIO);
+  handle_async_input ();
 #endif
 }