File readline-callback.diff of Package gdb

From nobody Sun Dec  3 11:01:14 2006
From: "H. J. Lu" <hjl@lucon.org>
Subject: PATCH: PR tui/2173: Arrow keys no longer works in breakpoint command list
To: GDB <gdb-patches@sources.redhat.com>
Date: Tue, 21 Nov 2006 13:32:05 -0800

The problem is callback in readline 5.1 is changed. When gdb readline
callback calls readline (), readline is really confused since although
it is called from gdb callback, it isn't really in callback state. This
kludge seems to work for me.


H.J.
----
2006-11-21  H.J. Lu  <hongjiu.lu@intel.com>

	PR tui/2173
	* top.c (gdb_readline_wrapper): Unset and reset RL_STATE_CALLBACK
	around readline if needed.

--- gdb/top.c.arrow	2006-07-21 07:46:53.000000000 -0700
+++ gdb/top.c	2006-11-21 13:20:04.000000000 -0800
@@ -724,6 +724,9 @@ The filename in which to record the comm
 char *
 gdb_readline_wrapper (char *prompt)
 {
+  char *line;
+  int in_callback;
+
   /* Set the hook that works in this case.  */
   if (after_char_processing_hook)
     {
@@ -731,7 +734,19 @@ gdb_readline_wrapper (char *prompt)
       after_char_processing_hook = NULL;
     }
 
-  return readline (prompt);
+  /* When we call readline, we have to make sure that readline isn't in
+     the callback state. Otherwise, it will get really confused.
+     PR tui/2173.  */
+  in_callback = RL_ISSTATE (RL_STATE_CALLBACK);
+  if (in_callback)
+    RL_UNSETSTATE (RL_STATE_CALLBACK);
+
+  line = readline (prompt);
+
+  if (in_callback)
+    RL_SETSTATE (RL_STATE_CALLBACK);
+
+  return line;
 }
 
 

openSUSE Build Service is sponsored by