From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12414 invoked by alias); 9 May 2005 20:18:08 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 12007 invoked from network); 9 May 2005 20:17:51 -0000 Received: from unknown (HELO sethra.codesourcery.com) (65.74.133.9) by sourceware.org with SMTP; 9 May 2005 20:17:51 -0000 Received: from sethra.codesourcery.com (localhost.localdomain [127.0.0.1]) by sethra.codesourcery.com (8.12.11/8.12.11) with ESMTP id j49KFo4f028907; Mon, 9 May 2005 13:15:50 -0700 Received: (from mitchell@localhost) by sethra.codesourcery.com (8.12.11/8.12.11/Submit) id j49KFoPw028903; Mon, 9 May 2005 13:15:50 -0700 Date: Mon, 09 May 2005 20:42:00 -0000 Message-Id: <200505092015.j49KFoPw028903@sethra.codesourcery.com> From: Mark Mitchell To: bug-readline@gnu.org Cc: gdb-patches@sources.redhat.com Subject: PATCH: Use getche on Win32 Reply-to: mark@codesourcery.com X-SW-Source: 2005-05/txt/msg00214.txt.bz2 [This is the penultimate GDB-on-MinGW patch.] Windows console semantics are different from UNIX. If we just use "read" to read what the user's typing, we end up blocking until a newline is available, and even then there are some oddities. The easiest thing seems to be to use the special "getche" (short for "get character with echo") routine which does the right thing. Reviews? -- Mark Mitchell CodeSourcery, LLC mark@codesourcery.com 2005-05-09 Mark Mitchell * readline/input.c (rl_getc): Use getche to read console input on Windows. Index: input.c =================================================================== RCS file: /cvs/src/src/readline/input.c,v retrieving revision 1.5 retrieving revision 1.5.60.1 diff -c -5 -p -r1.5 -r1.5.60.1 *** input.c 8 Dec 2002 22:31:37 -0000 1.5 --- input.c 5 Apr 2005 17:53:04 -0000 1.5.60.1 *************** rl_getc (stream) *** 422,431 **** --- 422,438 ---- int result; unsigned char c; while (1) { + #ifdef __MINGW32__ + /* On Windows, use a special routine to read a single character + from the console. (Otherwise, no characters are available + until the user hits the return key.) */ + if (isatty (fileno (stream))) + return getche (); + #endif result = read (fileno (stream), &c, sizeof (unsigned char)); if (result == sizeof (unsigned char)) return (c);