>From dd7f1a8342b9e544ac7507cb3d057676559c1c4a Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 15 Oct 2023 13:13:03 +0200 Subject: [PATCH 7/8] MSVC port, part 7: Screen and input handling like with mingw. * info/terminal.c: Treat native Windows like mingw. * info/pcterm.c (pc_put_text, pc_write_chars, pc_initialize_terminal): Likewise. * info/scan.c (nl_langinfo, rpl_nl_langinfo): Likewise. * info/session.c: Likewise. (info_gather_typeahead): On native Windows, don't use ioctl. This is not emulated by gnulib, and specific code for native Windows follows in a #else. --- info/pcterm.c | 6 +++--- info/scan.c | 6 ++++-- info/session.c | 10 +++++----- info/terminal.c | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/info/pcterm.c b/info/pcterm.c index 77ff6ffd06..314a90a43a 100644 --- a/info/pcterm.c +++ b/info/pcterm.c @@ -1027,7 +1027,7 @@ pc_put_text (string) { if (speech_friendly) fputs (string, stdout); -#ifdef __MINGW32__ +#ifdef _WIN32 else if (hscreen == INVALID_HANDLE_VALUE) fputs (string, stdout); else if (output_cp == CP_UTF8 || output_cp == CP_UTF7) @@ -1062,7 +1062,7 @@ pc_write_chars (string, nchars) if (speech_friendly) printf ("%.*s", nchars, string); -#ifdef __MINGW32__ +#ifdef _WIN32 else if (hscreen == INVALID_HANDLE_VALUE) printf ("%.*s", nchars, string); else if (output_cp == CP_UTF8 || output_cp == CP_UTF7) @@ -1264,7 +1264,7 @@ pc_initialize_terminal (term_name) pc_get_screen_size (); -#ifdef __MINGW32__ +#ifdef _WIN32 /* Record the screen output codepage. */ output_cp = GetConsoleOutputCP (); #endif diff --git a/info/scan.c b/info/scan.c index d6183ae9ae..628611ca97 100644 --- a/info/scan.c +++ b/info/scan.c @@ -28,10 +28,12 @@ # include #endif #include -#ifdef __MINGW32__ -/* MinGW uses a replacement nl_langinfo, see pcterm.c. */ +#ifdef _WIN32 +/* On native Windows, we use a replacement nl_langinfo, see pcterm.c. */ # define nl_langinfo rpl_nl_langinfo extern char * rpl_nl_langinfo (nl_item); +#endif +#ifdef __MINGW32__ /* MinGW uses its own replacement wcwidth, see pcterm.c for the reasons. Since Gnulib's wchar.h might redirect wcwidth to rpl_wcwidth, we explicitly undo that here. */ diff --git a/info/session.c b/info/session.c index 881749ae4c..4a3a3420b8 100644 --- a/info/session.c +++ b/info/session.c @@ -30,7 +30,7 @@ #ifdef HAVE_SYS_IOCTL_H #include #endif -#ifdef __MINGW32__ +#ifdef _WIN32 # undef read # define read(f,b,s) w32_read(f,b,s) # undef _read @@ -454,7 +454,7 @@ info_gather_typeahead (int wait) space_avail = sizeof (info_input_buffer) - (push_index - pop_index); /* If we can just find out how many characters there are to read, do so. */ -#if defined (FIONREAD) +#if defined (FIONREAD) && ! defined (_WIN32) { ioctl (tty, FIONREAD, &chars_avail); @@ -503,7 +503,7 @@ info_gather_typeahead (int wait) chars_avail = read (tty, &input[0], chars_avail); } # else -# ifdef __MINGW32__ +# ifdef _WIN32 { extern long w32_chars_avail (int); @@ -739,7 +739,7 @@ get_input_key_internal (void) } } -#if !defined (FD_SET) && defined (__MINGW32__) +#if !defined (FD_SET) && defined (_WIN32) # define WIN32_LEAN_AND_MEAN # include #endif @@ -761,7 +761,7 @@ pause_or_input (void) timer.tv_sec = 2; timer.tv_usec = 0; select (fileno (stdin) + 1, &readfds, NULL, NULL, &timer); -#elif defined (__MINGW32__) +#elif defined (_WIN32) /* This is signalled on key release, so flush it and wait again. */ WaitForSingleObject (GetStdHandle (STD_INPUT_HANDLE), 2000); FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE)); diff --git a/info/terminal.c b/info/terminal.c index 92bf106048..3b348a72c1 100644 --- a/info/terminal.c +++ b/info/terminal.c @@ -1131,6 +1131,6 @@ terminal_unprep_terminal (void) terminal_end_using_terminal (); } -#if defined(__MSDOS__) || defined(__MINGW32__) +#if defined(__MSDOS__) || defined(_WIN32) # include "pcterm.c" #endif -- 2.34.1