changeset 83460:dbd791ef90a1

Eliminate wrong_kboard_jmpbuf. * src/keyboard.c (read_char, read_char_minibuf_menu_prompt) (read_key_sequence, read_filtered_event): Eliminate wrong_kboard_jmpbuf. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-500
author Karoly Lorentey <lorentey@elte.hu>
date Sun, 29 Jan 2006 00:17:11 +0000
parents 8d8bc8469c77
children 9b150bc96d33
files README.multi-tty src/keyboard.c src/lread.c
diffstat 3 files changed, 38 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/README.multi-tty	Sat Jan 28 22:46:08 2006 +0000
+++ b/README.multi-tty	Sun Jan 29 00:17:11 2006 +0000
@@ -404,10 +404,6 @@
 ** Understand how `quit_throw_to_read_char' works, and fix any bugs
    that come to light.
 
-** Replace wrong_kboard_jmpbuf with a special return value of
-   read_char.  It is absurd that we use setjmp/longjmp just to return
-   to the immediate caller.
-
 ** See if getcjmp can be eliminated somehow.  Why does Emacs allow
    asynchronous input processing while it's reading input anyway?
 
@@ -1452,6 +1448,11 @@
    `getcjmp' when Emacs was waiting for input when the C-g event
    arrived.)
 
+-- Replace wrong_kboard_jmpbuf with a special return value of
+   read_char.  It is absurd that we use setjmp/longjmp just to return
+   to the immediate caller.
+
+   (Done in patch-500.)
 
 ;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d
 
--- a/src/keyboard.c	Sat Jan 28 22:46:08 2006 +0000
+++ b/src/keyboard.c	Sun Jan 29 00:17:11 2006 +0000
@@ -651,8 +651,7 @@
 						Lisp_Object, int *));
 static Lisp_Object read_char_x_menu_prompt ();
 static Lisp_Object read_char_minibuf_menu_prompt P_ ((int, int,
-						      Lisp_Object *,
-                                                      jmp_buf *));
+						      Lisp_Object *));
 static Lisp_Object make_lispy_event P_ ((struct input_event *));
 #ifdef HAVE_MOUSE
 static Lisp_Object make_lispy_movement P_ ((struct frame *, Lisp_Object,
@@ -678,7 +677,7 @@
 static void timer_stop_idle P_ ((void));
 static void timer_resume_idle P_ ((void));
 
-Lisp_Object read_char P_ ((int, int, Lisp_Object *, Lisp_Object, int *, jmp_buf *));
+Lisp_Object read_char P_ ((int, int, Lisp_Object *, Lisp_Object, int *));
 
 /* Nonzero means don't try to suspend even if the operating system seems
    to support it.  */
@@ -2460,19 +2459,18 @@
    if we used a mouse menu to read the input, or zero otherwise.  If
    USED_MOUSE_MENU is null, we don't dereference it.
 
-   WRONG_KBOARD_JMPBUF should be a stack context to longjmp to in case
-   we find input on another keyboard.
-   
+   Value is -2 when we find input on another keyboard.  A second call
+   to read_char will read it. 
+
    Value is t if we showed a menu and the user rejected it.  */
 
 Lisp_Object
-read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, wrong_kboard_jmpbuf)
+read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
      int commandflag;
      int nmaps;
      Lisp_Object *maps;
      Lisp_Object prev_event;
      int *used_mouse_menu;
-     jmp_buf *wrong_kboard_jmpbuf;
 {
   volatile Lisp_Object c;
   int count;
@@ -2688,8 +2686,11 @@
       && unread_command_char < 0
       && !detect_input_pending_run_timers (0))
     {
-      c = read_char_minibuf_menu_prompt (commandflag, nmaps, maps,
-                                         wrong_kboard_jmpbuf);
+      c = read_char_minibuf_menu_prompt (commandflag, nmaps, maps);
+
+      if (INTEGERP (c) && XINT (c) == -2)
+        return c;               /* wrong_kboard_jmpbuf */
+
       if (! NILP (c))
 	{
 	  key_already_recorded = 1;
@@ -2742,9 +2743,7 @@
 	    /* This is going to exit from read_char
 	       so we had better get rid of this frame's stuff.  */
 	    UNGCPRO;
-            if (wrong_kboard_jmpbuf == NULL)
-              abort ();
-	    longjmp (*wrong_kboard_jmpbuf, 1);
+            return make_number (-2); /* wrong_kboard_jmpbuf */
 	  }
       }
 #endif
@@ -2888,9 +2887,7 @@
   if (NILP (c) && current_kboard != orig_kboard)
     {
       UNGCPRO;
-      if (wrong_kboard_jmpbuf == NULL)
-        abort ();
-      longjmp (*wrong_kboard_jmpbuf, 1);
+      return make_number (-2);  /* wrong_kboard_jmpbuf */
     }
 
   /* If this has become non-nil here, it has been set by a timer
@@ -2941,9 +2938,7 @@
 	    /* This is going to exit from read_char
 	       so we had better get rid of this frame's stuff.  */
 	    UNGCPRO;
-            if (wrong_kboard_jmpbuf == NULL)
-              abort ();
-	    longjmp (*wrong_kboard_jmpbuf, 1);
+            return make_number (-2); /* wrong_kboard_jmpbuf */
 	  }
     }
 #endif
@@ -2990,9 +2985,7 @@
 	  /* This is going to exit from read_char
 	     so we had better get rid of this frame's stuff.  */
 	  UNGCPRO;
-          if (wrong_kboard_jmpbuf == NULL)
-            abort ();
-	  longjmp (*wrong_kboard_jmpbuf, 1);
+          return make_number (-2);
 	}
 #endif
     }
@@ -3310,7 +3303,7 @@
 
       cancel_echoing ();
       do
-	c = read_char (0, 0, 0, Qnil, 0, wrong_kboard_jmpbuf);
+	c = read_char (0, 0, 0, Qnil, 0);
       while (BUFFERP (c));
       /* Remove the help from the frame */
       unbind_to (count, Qnil);
@@ -3320,7 +3313,7 @@
 	{
 	  cancel_echoing ();
 	  do
-	    c = read_char (0, 0, 0, Qnil, 0, wrong_kboard_jmpbuf);
+	    c = read_char (0, 0, 0, Qnil, 0);
 	  while (BUFFERP (c));
 	}
     }
@@ -8241,11 +8234,10 @@
 static int read_char_minibuf_menu_width;
 
 static Lisp_Object
-read_char_minibuf_menu_prompt (commandflag, nmaps, maps, wrong_kboard_jmpbuf)
+read_char_minibuf_menu_prompt (commandflag, nmaps, maps)
      int commandflag ;
      int nmaps;
      Lisp_Object *maps;
-     jmp_buf *wrong_kboard_jmpbuf;
 {
   int mapno;
   register Lisp_Object name;
@@ -8468,12 +8460,14 @@
       orig_defn_macro = current_kboard->defining_kbd_macro;
       current_kboard->defining_kbd_macro = Qnil;
       do
-	obj = read_char (commandflag, 0, 0, Qt, 0, wrong_kboard_jmpbuf);
+	obj = read_char (commandflag, 0, 0, Qt, 0);
       while (BUFFERP (obj));
       current_kboard->defining_kbd_macro = orig_defn_macro;
 
       if (!INTEGERP (obj))
 	return obj;
+      else if (XINT (obj) == -2)
+        return obj;
       else
 	ch = XINT (obj);
 
@@ -8838,7 +8832,7 @@
   /* Read the first char of the sequence specially, before setting
      up any keymaps, in case a filter runs and switches buffers on us.  */
   first_event = read_char (NILP (prompt), 0, submaps, last_nonmenu_event,
-			   &junk, NULL);
+			   &junk);
 #endif /* GOBBLE_FIRST_EVENT */
 
   orig_local_map = get_local_map (PT, current_buffer, Qlocal_map);
@@ -9014,7 +9008,12 @@
 #ifdef MULTI_KBOARD
 	    KBOARD *interrupted_kboard = current_kboard;
 	    struct frame *interrupted_frame = SELECTED_FRAME ();
-	    if (setjmp (*wrong_kboard_jmpbuf))
+#endif
+	    key = read_char (NILP (prompt), nmaps,
+			     (Lisp_Object *) submaps, last_nonmenu_event,
+			     &used_mouse_menu);
+#ifdef MULTI_KBOARD
+	    if (INTEGERP (key) && XINT (key) == -2) /* wrong_kboard_jmpbuf */
 	      {
 		int found = 0;
 		struct kboard *k;
@@ -9063,9 +9062,6 @@
 		goto replay_sequence;
 	      }
 #endif
-	    key = read_char (NILP (prompt), nmaps,
-			     (Lisp_Object *) submaps, last_nonmenu_event,
-			     &used_mouse_menu, wrong_kboard_jmpbuf);
 	  }
 
 	  /* read_char returns t when it shows a menu and the user rejects it.
--- a/src/lread.c	Sat Jan 28 22:46:08 2006 +0000
+++ b/src/lread.c	Sun Jan 29 00:17:11 2006 +0000
@@ -435,7 +435,7 @@
 
 /* Get a character from the tty.  */
 
-extern Lisp_Object read_char P_ ((int, int, Lisp_Object *, Lisp_Object, int *, jmp_buf *));
+extern Lisp_Object read_char P_ ((int, int, Lisp_Object *, Lisp_Object, int *));
 
 /* Read input events until we get one that's acceptable for our purposes.
 
@@ -461,7 +461,6 @@
      int no_switch_frame, ascii_required, error_nonascii, input_method;
 {
   volatile register Lisp_Object val, delayed_switch_frame;
-  jmp_buf *volatile wrong_kboard_jmpbuf = alloca (sizeof (jmp_buf));
 
 #ifdef HAVE_WINDOW_SYSTEM
   if (display_hourglass_p)
@@ -472,12 +471,10 @@
 
   /* Read until we get an acceptable event.  */
  retry:
-  setjmp (*wrong_kboard_jmpbuf);
-
-  val = read_char (0, 0, 0,
-		   (input_method ? Qnil : Qt),
-		   0, wrong_kboard_jmpbuf);
- 
+  do 
+    val = read_char (0, 0, 0, (input_method ? Qnil : Qt), 0);
+  while (INTEGERP (val) && XINT (val) == -2); /* wrong_kboard_jmpbuf */
+
   if (BUFFERP (val))
     goto retry;