Hi, I've built Readline 8.2 today on MS-Windows using MinGW, and found the following problems:
. input.c and rlprivate.h use fd_set without the #ifdef guards that are used elsewhere, where the corresponding functions are implemented. On Windows, fd_set is only usable with sockets, and the header file sys/select.h does not exist, so this fails the compilation. . there's a syntax error in rl_getc, in a fragment specific to MinGW: a closing parenthesis is missing . one of the flavors of MinGW doesn't have the 'alarm' function in its headers/libraries (and the functionality doesn't work even in the flavors which do have it). The patches for these problems are below. Thank you for developing Readline. --- ./input.c~0 2022-04-08 22:43:24.000000000 +0300 +++ ./input.c 2024-07-11 16:12:07.317365800 +0300 @@ -144,6 +144,14 @@ win32_isatty (int fd) # define RL_TIMEOUT_USE_SELECT #else # define RL_TIMEOUT_USE_SIGALRM +# ifdef __MINGW32_MAJOR_VERSION +/* mingw.org's MinGW doesn't have 'alarm'. */ +unsigned int +alarm (unsigned int seconds) +{ + return 0; +} +# endif #endif int rl_set_timeout (unsigned int, unsigned int); @@ -151,7 +159,9 @@ int rl_timeout_remaining (unsigned int * int _rl_timeout_init (void); int _rl_timeout_sigalrm_handler (void); +#if defined (HAVE_PSELECT) || defined (HAVE_SELECT) int _rl_timeout_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *, const sigset_t *); +#endif static void _rl_timeout_handle (void); #if defined (RL_TIMEOUT_USE_SIGALRM) @@ -818,7 +828,7 @@ rl_getc (FILE *stream) /* We know at this point that _rl_caught_signal == 0 */ #if defined (__MINGW32__) - if (isatty (fd) + if (isatty (fd)) return (_getch ()); /* "There is no error return." */ #endif result = 0; --- ./rlprivate.h~0 2022-08-12 01:35:16.000000000 +0300 +++ ./rlprivate.h 2024-07-11 15:59:31.132508800 +0300 @@ -304,9 +304,11 @@ extern int _rl_pushed_input_available (v extern int _rl_timeout_init (void); extern int _rl_timeout_handle_sigalrm (void); #if defined (_POSIXSELECT_H_) +#if defined (HAVE_PSELECT) || defined (HAVE_SELECT) /* use as a sentinel for fd_set, struct timeval, and sigset_t definitions */ extern int _rl_timeout_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *, const sigset_t *); #endif +#endif /* isearch.c */ extern _rl_search_cxt *_rl_scxt_alloc (int, int);