From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17122 invoked by alias); 7 Apr 2006 20:01:56 -0000 Received: (qmail 17114 invoked by uid 22791); 7 Apr 2006 20:01:55 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Fri, 07 Apr 2006 20:01:51 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1FRx9R-0007yw-E1; Fri, 07 Apr 2006 16:01:49 -0400 Date: Fri, 07 Apr 2006 20:11:00 -0000 From: Daniel Jacobowitz To: bug-readline@gnu.org Cc: gdb@sourceware.org Subject: MinGW status for readline Message-ID: <20060407200149.GA28248@nevyn.them.org> Mail-Followup-To: bug-readline@gnu.org, gdb@sourceware.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.8i X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00108.txt.bz2 Hi Chet, I just tried to use GDB with readline 5.1, on MinGW32. I have four items to report. #1 and #4 have readline patches, #2 I'll fix in GDB, #3 is a readline bug that I do not know how to fix - I'd appreciate advice on that one! 1. Readline 5.1 currently fails to build for MinGW, in tilde.c. The problem is: dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len); I've just moved the else branch inside the #if defined (HAVE_GETPWENT), from just below. With that change, readline builds. Here's the patch: 2006-04-07 Daniel Jacobowitz * tilde.c (tilde_expand_word): Don't use pw_dir if !HAVE_GETPWENT. --- /space/symbian/readline/readline-5.1/tilde.c 2005-05-07 14:49:51.000000000 -0400 +++ ./tilde.c 2006-04-07 14:16:10.000000000 -0400 @@ -410,12 +410,12 @@ tilde_expand_word (filename) if (dirname == 0) dirname = savestring (filename); } +#if defined (HAVE_GETPWENT) else { free (username); dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len); } -#if defined (HAVE_GETPWENT) endpwent (); #endif return (dirname); 2. The changes in the handling of multi-key sequences cause control to return to GDB between \0340 and the following 'H' (two-character sequence indicating an arrow key). This used to happen entirely in readline. I don't think this is a bug in readline, though it did surprise me. It also broke GDB's select implementation for MinGW32, but that's my problem, not yours. 3. RL_STATE_MULTIKEY also broke macros which push multi-key sequences into the input stream. For instance, put this in .inputrc: Control-y: "\e[D" Then try to use that. It works in bash, which does not use callback mode; it fails in GDB, which does. All the other readline-using apps I checked on my system don't use callbacks, so I couldn't be sure it wasn't GDB's fault, but I don't think it is. What happens in GDB is that rl_callback_read_char has special handling for various states, including RL_STATE_MULTIKEY. But if there's a macro in progress, it just loops at the bottom checking RL_STATE_MACROINPUT and calling readline_internal_char. This doesn't use the keymap saved in _rl_kscxt. So the escape character is not properly handled, and I get a beep followed by a literal [D. I think this is readline's fault. 4. There's some use of uninitialized variables when checking for pending input on mingw32, because we exercise the no-select code path, so here's a patch to fix that. I was hoping that this would fix #2, but I'm going to have to fix that in GDB instead. The patch is still right, though, so please apply. (The uninitialized variable was chars_available.) 2006-04-07 Daniel Jacobowitz * input.c (rl_gather_tyi): Use _kbhit for Windows consoles. (_rl_input_available): Likewise. --- readline-5.1.orig/input.c 2005-07-04 22:30:24.000000000 -0400 +++ readline-5.1/input.c 2006-04-07 15:04:57.000000000 -0400 @@ -220,6 +220,16 @@ rl_gather_tyi () } #endif /* O_NDELAY */ +#if defined (__MINGW32__) + /* We use getch to read console input, so use the same + mechanism to check for more. Otherwise, we don't know. */ + if (isatty (fileno (rl_instream))) + chars_avail = _kbhit (); + else + chars_avail = 0; + result = 0; +#endif + /* If there's nothing available, don't waste time trying to read something. */ if (chars_avail <= 0) @@ -305,6 +315,13 @@ _rl_input_available () #endif +#if defined (__MINGW32__) + /* We use getch to read console input, so use the same + mechanism to check for more. Otherwise, we don't know. */ + if (isatty (fileno (rl_instream))) + return _kbhit (); +#endif + return 0; } -- Daniel Jacobowitz CodeSourcery