[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-readline] GDB-related problems in Readline
From: |
Eli Zaretskii |
Subject: |
[Bug-readline] GDB-related problems in Readline |
Date: |
Tue, 14 Jul 2015 18:12:54 +0300 |
[Please CC me on any replies, as I'm not subscribed to the list.]
Back in January, I sent the patches below, see
http://lists.gnu.org/archive/html/bug-readline/2015-01/msg00003.html
They are needed to prevent misbehavior of GDB built for native Windows
debugging with MinGW. In particular, when GDB is invoked without the
-tui switch, it exits on the first keystroke, because Readline calls
'getch' from ncurses.
I didn't receive any response then, and mistakenly assumed that the
patches were accepted. But now I see that the pretest of GDB 7.10 and
the GDB Git repository still don't have these issues fixed, so I guess
I was mistaken, and should have followed up back then.
Can these patches please be applied to Readline? Thanks.
--- readline/input.c~0 2014-06-11 19:34:41.000000000 +0300
+++ readline/input.c 2015-02-21 12:37:13.630889300 +0200
@@ -86,6 +86,36 @@ static int ibuffer_space PARAMS((void));
static int rl_get_char PARAMS((int *));
static int rl_gather_tyi PARAMS((void));
+#if defined (_WIN32) && !defined (__CYGWIN__)
+
+/* 'isatty' in the Windows runtime returns non-zero for every
+ character device, including the null device. Repair that. */
+#include <io.h>
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+
+int w32_isatty (int fd)
+{
+ if (_isatty(fd))
+ {
+ HANDLE h = (HANDLE) _get_osfhandle (fd);
+ DWORD ignored;
+
+ if (h == INVALID_HANDLE_VALUE)
+ {
+ errno = EBADF;
+ return 0;
+ }
+ if (GetConsoleMode (h, &ignored) != 0)
+ return 1;
+ }
+ errno = ENOTTY;
+ return 0;
+}
+
+#define isatty(x) w32_isatty(x)
+#endif
+
/* **************************************************************** */
/* */
/* Character Input Buffering */
@@ -465,8 +495,10 @@ rl_getc (stream)
RL_CHECK_SIGNALS ();
#if defined (__MINGW32__)
+ /* Use _getch to make sure we call the function from MS runtime,
+ even if some curses library is linked in. */
if (isatty (fileno (stream)))
- return (getch ());
+ return (_getch ());
#endif
result = read (fileno (stream), &c, sizeof (unsigned char));
--- readline/config.h.in~0 2014-06-11 19:34:41.000000000 +0300
+++ readline/config.h.in 2015-02-21 11:45:52.921875000 +0200
@@ -186,6 +186,9 @@
/* Define if you have the <termcap.h> header file. */
#undef HAVE_TERMCAP_H
+/* Define if you have the <ncurses/termcap.h> header file. */
+#undef HAVE_NCURSES_TERMCAP_H
+
/* Define if you have the <termio.h> header file. */
#undef HAVE_TERMIO_H
--- readline/configure.in~0 2014-06-11 19:34:41.000000000 +0300
+++ readline/configure.in 2015-02-21 11:44:01.109375000 +0200
@@ -198,6 +198,9 @@ if test "$TERMCAP_LIB" = "./lib/termcap/
TERMCAP_LIB=-ltermcap #default
fi
fi
+if test "$TERMCAP_LIB" = "-lncurses"; then
+ AC_CHECK_HEADERS(ncurses/termcap.h)
+fi
BASH_CHECK_MULTIBYTE
--- readline/tcap.h~0 2014-06-11 19:34:41.000000000 +0300
+++ readline/tcap.h 2015-02-21 11:43:19.203125000 +0200
@@ -31,6 +31,8 @@
# include "rltty.h"
# endif
# include <termcap.h>
+#elif defined (HAVE_NCURSES_TERMCAP_H)
+# include <ncurses/termcap.h>
#else
/* On Solaris2, sys/types.h #includes sys/reg.h, which #defines PC.
--- readline/display.c~ 2014-06-11 19:34:41.000000000 +0300
+++ readline/display.c 2015-02-21 11:30:18.625000000 +0200
@@ -2374,7 +2374,7 @@ insert_some_chars (string, count, col)
char *string;
int count, col;
{
-#if defined (__MSDOS__) || defined (__MINGW32__)
+#if defined (__MSDOS__) || (defined (__MINGW32__) && !defined
(NCURSES_VERSION))
_rl_output_some_chars (string, count);
#else
/* DEBUGGING */
@@ -2426,7 +2426,7 @@ delete_chars (count)
if (count > _rl_screenwidth) /* XXX */
return;
-#if !defined (__MSDOS__) && !defined (__MINGW32__)
+#if !defined (__MSDOS__) && !(defined (__MINGW32__) && !defined
(NCURSES_VERSION))
if (_rl_term_DC && *_rl_term_DC)
{
char *buffer;
- [Bug-readline] GDB-related problems in Readline,
Eli Zaretskii <=