On mingw 5.0.3, there are no test failures any more. A big improvement, compared to 7.0.90 (see my earlier report at <https://lists.gnu.org/archive/html/bug-texinfo/2023-08/msg00030.html>).
With MSVC 14 (64-bit) instead of mingw, though, there are compilation errors and warnings: C:\cygwin64\home\bruno\texinfo-7.0.94\info\man.c(439): warning C4047: '=': 'FILE *' differs in levels of indirection from 'int' C:\cygwin64\home\bruno\texinfo-7.0.94\info\man.c(491): error C2079: 'timeout' uses undefined struct 'timeval' C:\cygwin64\home\bruno\texinfo-7.0.94\info\tilde.c(45): warning C4312: 'type cast': conversion from 'int' to 'passwd *' of greater size C:\cygwin64\home\bruno\texinfo-7.0.94\info\tilde.c(47): error C2037: left of 'pw_dir' specifies undefined struct/union 'passwd' C:\cygwin64\home\bruno\texinfo-7.0.94\info\tilde.c(85): error C2037: left of 'pw_dir' specifies undefined struct/union 'passwd' C:\cygwin64\home\bruno\texinfo-7.0.94\info\tilde.c(85): error C2198: 'strlen': too few arguments for call C:\cygwin64\home\bruno\texinfo-7.0.94\info\tilde.c(87): error C2037: left of 'pw_dir' specifies undefined struct/union 'passwd' C:\cygwin64\home\bruno\texinfo-7.0.94\info\tilde.c(87): error C2198: 'strcpy': too few arguments for call C:\cygwin64\home\bruno\texinfo-7.0.94\info\filesys.c(416): warning C4047: '=': 'FILE *' differs in levels of indirection from 'int' install-info.obj : error LNK2019: unresolved external symbol popen referenced in function open_possibly_compressed_file install-info.obj : error LNK2019: unresolved external symbol pclose referenced in function readfile For 'popen' and 'pclose', one needs the gnulib modules 'popen' and 'pclose', respectively. For 'timeval', one needs the gnulib module 'sys_time'. Then, some link errors are seen: man.obj : error LNK2019: unresolved external symbol select_used_without_including_sys_select_h referenced in function read_from_fd session.obj : error LNK2001: unresolved external symbol select_used_without_including_sys_select_h session.obj : error LNK2019: unresolved external symbol ioctl referenced in function info_gather_typeahead To resolve this, one needs the gnulib module 'select'. Thus, I'm arriving at the following changes, that make texinfo work with MSVC, like it does with mingw: - "make check" passes. - The behaviour of the 'ginfo' program on MSVC is the same as on mingw, albeit not really useful currently: './info -f texinfo.info' spits out the entire manual to stdout at once. It looks like the device gets set to stdout, or there is no knowledge about the terminal window's height, or something like that. Note the preprocessor predefs: - __MINGW32__ is defined on mingw (both 32-bit and 64-bit Windows), - _WIN32 is defined on native Windows (i.e. Windows except Cygwin), also both 32-bit and 64-bit. That includes mingw. See <https://github.com/cpredef/predef>. I'm not saying that it's perfect. For example, the function pause_or_input has specific code for native Windows; thus the socket-able code with select() on stdin could probably be disabled? (This applies to both mingw and MSVC.) Note: I wouldn't push for these changes before the 7.1 release, since in particular the 'select' module can trigger behaviour changes. Rather, this is post-7.1 stuff IMO. Bruno
0001-MSVC-port-part-1-Ran-gnulib-tool-add-import-popen-pc.patch.gz
Description: application/gzip
>From c89961391cd3ad616cdd457c89c25f22c3213713 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Sun, 15 Oct 2023 12:30:04 +0200 Subject: [PATCH 2/8] MSVC port, part 2: Accommodate the added gnulib modules. * configure.ac: Don't test for sys/time.h, since gnulib now provides it. * info/man.c: Assume that sys/time.h. Also include <sys/select.h>, for the select() function. * info/session.c: Likewise. * info/Makefile.am (LDADD): Add $(SELECT_LIB), needed for the 'select' module. --- configure.ac | 2 +- info/Makefile.am | 3 +++ info/man.c | 3 +-- info/session.c | 11 ++--------- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 7fa457deb2..bd34937e06 100644 --- a/configure.ac +++ b/configure.ac @@ -220,7 +220,7 @@ AC_SUBST([DIFF_A_OPTION]) # Checks for header files. AC_CHECK_HEADERS(io.h pwd.h \ termcap.h termios.h unistd.h \ - sys/ioctl.h sys/time.h sys/wait.h) + sys/ioctl.h sys/wait.h) AC_SYS_POSIX_TERMIOS diff --git a/info/Makefile.am b/info/Makefile.am index f57b341ea2..0cc770413f 100644 --- a/info/Makefile.am +++ b/info/Makefile.am @@ -29,6 +29,9 @@ LDADD = $(top_builddir)/gnulib/lib/libgnu.a $(TERMLIBS) # for various gnulib modules LDADD += $(LIBINTL) $(LIBICONV) $(LIBC32CONV) $(LIBUNISTRING) $(LIBTHREAD) +# for select gnulib module +LDADD += $(SELECT_LIB) + # for hard-locale gnulib module which is brought in indirectly LDADD += $(HARD_LOCALE_LIB) $(SETLOCALE_NULL_LIB) diff --git a/info/man.c b/info/man.c index 49a0d0636f..cbb8451cb7 100644 --- a/info/man.c +++ b/info/man.c @@ -19,9 +19,8 @@ #include "info.h" #include "signals.h" -#if defined (HAVE_SYS_TIME_H) #include <sys/time.h> -#endif +#include <sys/select.h> #if defined (HAVE_SYS_WAIT_H) #include <sys/wait.h> #endif diff --git a/info/session.c b/info/session.c index 7c1a9d30a9..881749ae4c 100644 --- a/info/session.c +++ b/info/session.c @@ -38,10 +38,8 @@ extern ssize_t w32_read (int, void *, size_t); #endif -#if defined (HAVE_SYS_TIME_H) -# include <sys/time.h> -# define HAVE_STRUCT_TIMEVAL -#endif /* HAVE_SYS_TIME_H */ +#include <sys/time.h> +#include <sys/select.h> /* **************************************************************** */ /* */ @@ -741,11 +739,6 @@ get_input_key_internal (void) } } -#if defined (HAVE_SYS_TIME_H) -# include <sys/time.h> -# define HAVE_STRUCT_TIMEVAL -#endif /* HAVE_SYS_TIME_H */ - #if !defined (FD_SET) && defined (__MINGW32__) # define WIN32_LEAN_AND_MEAN # include <windows.h> -- 2.34.1
>From b7a2ae4b63814d0bd6a95212a0e3f487710b6007 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Sun, 15 Oct 2023 12:36:57 +0200 Subject: [PATCH 3/8] MSVC port, part 3: Support compilers other than GCC. * info/pcterm.c (w32_info_init): Make non-static. If !__GNUC__, don't use __attribute__((constructor)). * info/info.c (main) [!__GNUC__]: Invoke w32_info_init from here. --- info/info.c | 5 +++++ info/pcterm.c | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/info/info.c b/info/info.c index 8ca4a17e58..3ab0126a27 100644 --- a/info/info.c +++ b/info/info.c @@ -690,6 +690,11 @@ main (int argc, char *argv[]) char *init_file = 0; /* Name of init file specified. */ char *error = 0; /* Error message to display in mini-buffer. */ +#if defined (_WIN32) && !defined (__GNUC__) + extern void w32_info_init (void); + w32_info_init (); +#endif + #ifdef HAVE_SETLOCALE /* Set locale via LC_ALL. */ setlocale (LC_ALL, ""); diff --git a/info/pcterm.c b/info/pcterm.c index a48478d29d..77ff6ffd06 100644 --- a/info/pcterm.c +++ b/info/pcterm.c @@ -162,10 +162,12 @@ w32_cleanup (void) } } -static void w32_info_init (void) __attribute__((constructor)); +#if defined (__GNUC__) +void w32_info_init (void) __attribute__((constructor)); +#endif static void pc_initialize_terminal (char *); -static void +void w32_info_init (void) { /* We need to set this single hook here; the rest -- 2.34.1
>From d15fa95c0c9509cb96691529e58a4b161a22c4ee Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Sun, 15 Oct 2023 12:48:32 +0200 Subject: [PATCH 4/8] MSVC port, part 4: Use CR-LF handling like with mingw. * info/filesys.c (convert_eols, filesys_read_info_file): Treat native Windows like mingw. --- info/filesys.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/info/filesys.c b/info/filesys.c index 4befe15bce..273d5f16ab 100644 --- a/info/filesys.c +++ b/info/filesys.c @@ -272,7 +272,7 @@ info_add_extension (char *dirname, char *filename, struct stat *finfo) return 0; } -#if defined (__MSDOS__) || defined (__MINGW32__) +#if defined (__MSDOS__) || defined (_WIN32) /* Given a chunk of text and its length, convert all CRLF pairs at every end-of-line into a single Newline character. Return the length of produced text. @@ -350,7 +350,7 @@ filesys_read_info_file (char *pathname, size_t *filesize, close (descriptor); } -#if defined (__MSDOS__) || defined (__MINGW32__) +#if defined (__MSDOS__) || defined (_WIN32) /* Old versions of makeinfo on MS-DOS or MS-Windows generated Info files with CR-LF line endings which are only counted as one byte in the file tag table. Convert any of these DOS-style CRLF EOLs into Unix-style NL -- 2.34.1
>From b3d5cc8cdaf11525c10c75988dab5a3de9385123 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Sun, 15 Oct 2023 12:53:29 +0200 Subject: [PATCH 5/8] MSVC port, part 5: Home directory handling like with mingw. * info/infomap.c (fetch_user_maps): Treat native Windows like mingw. * info/tilde.c (tilde_expand_word): Likewise. --- info/infomap.c | 4 ++-- info/tilde.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/info/infomap.c b/info/infomap.c index 71ed4098b8..0f9f6d82f6 100644 --- a/info/infomap.c +++ b/info/infomap.c @@ -563,7 +563,7 @@ fetch_user_maps (char *init_file) if (init_file) filename = xstrdup (init_file); else if ((homedir = getenv ("HOME")) != NULL -#ifdef __MINGW32__ +#ifdef _WIN32 || (homedir = getenv ("USERPROFILE")) != NULL #endif ) @@ -573,7 +573,7 @@ fetch_user_maps (char *init_file) strcat (filename, "/"); strcat (filename, INFOKEY_FILE); } -#if defined(__MSDOS__) || defined(__MINGW32__) +#if defined(__MSDOS__) || defined(_WIN32) /* Poor baby, she doesn't have a HOME... */ else filename = xstrdup (INFOKEY_FILE); /* try current directory */ diff --git a/info/tilde.c b/info/tilde.c index 0f78f3f25b..ffe427955a 100644 --- a/info/tilde.c +++ b/info/tilde.c @@ -39,7 +39,7 @@ tilde_expand_word (const char *filename) the password database. */ if (!temp_home) { -#ifndef __MINGW32__ +#ifndef _WIN32 struct passwd *entry; entry = (struct passwd *) getpwuid (getuid ()); @@ -63,7 +63,7 @@ tilde_expand_word (const char *filename) } else { -#ifndef __MINGW32__ +#ifndef _WIN32 struct passwd *user_entry; #endif char *username = xmalloc (257); @@ -78,7 +78,7 @@ tilde_expand_word (const char *filename) } username[i - 1] = 0; -#ifndef __MINGW32__ +#ifndef _WIN32 user_entry = (struct passwd *) getpwnam (username); if (user_entry) { -- 2.34.1
>From f4aa5dbc214b1678a53df8a72c0d7666924d7907 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Sun, 15 Oct 2023 13:05:25 +0200 Subject: [PATCH 6/8] MSVC port, part 6: File name handling like with mingw. * info/util.h (fncmp): Declare as a function on native Windows. * info/util.c (fncmp): Define on native Windows. --- info/util.c | 2 +- info/util.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/info/util.c b/info/util.c index bbd6ea369c..d4fbca6940 100644 --- a/info/util.c +++ b/info/util.c @@ -416,7 +416,7 @@ text_buffer_printf (struct text_buffer *buf, const char *format, ...) return n; } -#if defined(__MSDOS__) || defined(__MINGW32__) +#if defined(__MSDOS__) || defined(_WIN32) /* Cannot use FILENAME_CMP here, since that does not consider forward- and back-slash characters equal. */ int diff --git a/info/util.h b/info/util.h index 461d0979bd..a615b37a0c 100644 --- a/info/util.h +++ b/info/util.h @@ -67,7 +67,7 @@ size_t text_buffer_printf (struct text_buffer *buf, const char *format, ...); #define text_buffer_base(buf) ((buf)->base) #define text_buffer_off(buf) ((buf)->off) -#if defined(__MSDOS__) || defined(__MINGW32__) +#if defined(__MSDOS__) || defined(_WIN32) int fncmp (const char *fn1, const char *fn2); #else # define fncmp(s,t) strcmp(s,t) -- 2.34.1
>From dd7f1a8342b9e544ac7507cb3d057676559c1c4a Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> 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 <iconv.h> #endif #include <wchar.h> -#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 <sys/ioctl.h> #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 <windows.h> #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
>From 5161a37128e3422a5af073e35361442f1e2b54d4 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Sun, 15 Oct 2023 13:15:11 +0200 Subject: [PATCH 8/8] MSVC port, part 8: --speech-friendly option like with mingw. * info/info.c (speech_friendly, short_options, main, info_short_help): Treat native Windows like mingw. --- info/info.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/info/info.c b/info/info.c index 3ab0126a27..44a7045d94 100644 --- a/info/info.c +++ b/info/info.c @@ -99,7 +99,7 @@ static int print_where_p = 0; /* Non-zero means don't try to be smart when searching for nodes. */ int strict_node_location_p = 0; -#if defined(__MSDOS__) || defined(__MINGW32__) +#if defined(__MSDOS__) || defined(_WIN32) /* Non-zero indicates that screen output should be made 'speech-friendly'. Since on MSDOS the usual behavior is to write directly to the video memory, speech synthesizer software cannot grab the output. Therefore, @@ -143,14 +143,14 @@ static struct option long_options[] = { { "version", 0, &print_version_p, 1 }, { "vi-keys", 0, &vi_keys_p, 1 }, { "where", 0, &print_where_p, 1 }, -#if defined(__MSDOS__) || defined(__MINGW32__) +#if defined(__MSDOS__) || defined(_WIN32) { "speech-friendly", 0, &speech_friendly, 1 }, #endif {NULL, 0, NULL, 0} }; /* String describing the shorthand versions of the long options found above. */ -#if defined(__MSDOS__) || defined(__MINGW32__) +#if defined(__MSDOS__) || defined(_WIN32) static char *short_options = "ak:d:n:f:ho:ORsv:wbx:"; #else static char *short_options = "ak:d:n:f:ho:ORv:wsx:"; @@ -786,12 +786,12 @@ main (int argc, char *argv[]) print_where_p = 1; break; -#if defined(__MSDOS__) || defined(__MINGW32__) +#if defined(__MSDOS__) || defined(_WIN32) /* User wants speech-friendly output. */ case 'b': speech_friendly = 1; break; -#endif /* __MSDOS__ || __MINGW32__ */ +#endif /* __MSDOS__ || _WIN32 */ /* User has specified a string to search all indices for. */ case 'k': @@ -1119,7 +1119,7 @@ Frequently-used options:\n\ -n, --node=NODENAME specify nodes in first visited Info file\n\ -o, --output=FILE output selected nodes to FILE")); -#if defined(__MSDOS__) || defined(__MINGW32__) +#if defined(__MSDOS__) || defined(_WIN32) puts (_("\ -b, --speech-friendly be friendly to speech synthesizers")); #endif -- 2.34.1