diff options
author | Tom Tromey <tromey@adacore.com> | 2022-04-18 12:56:41 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2022-04-25 07:29:02 -0600 |
commit | 4324e94471818eac36520c2fc0c7d108d5395d14 (patch) | |
tree | 4b4b352eb7094aa88c8ce78eb5df4913bdac9730 | |
parent | e312dfbe9556d8e4557abe7fd3f1a4681e15da06 (diff) | |
download | binutils-gdb-4324e94471818eac36520c2fc0c7d108d5395d14.tar.gz |
Import gnulib changes
This imports the gnulib patches that were mentioned by Eli. I created
the patches from gnulib git, ran them through filterdiff, and then
applied them using update-gnulib.sh's patch-applying facility.
I think the patches are either obviously Windows-specific or harmless,
but I encourage you to look for yourself.
I tested by rebuilding on x86-64 Fedora 34, and also using the Fedora
mingw cross toolchain.
-rw-r--r-- | gnulib/Makefile.in | 2 | ||||
-rw-r--r-- | gnulib/doc/gendocs_template | 2 | ||||
-rw-r--r-- | gnulib/doc/gendocs_template_min | 2 | ||||
-rw-r--r-- | gnulib/import/glob.c | 19 | ||||
-rw-r--r-- | gnulib/import/select.c | 9 | ||||
-rw-r--r-- | gnulib/import/unistd.in.h | 12 | ||||
-rw-r--r-- | gnulib/patches/0002-glob-tilde-check | 49 | ||||
-rw-r--r-- | gnulib/patches/0003-unistd-h-fix | 36 | ||||
-rw-r--r-- | gnulib/patches/0004-select-mingw | 33 | ||||
-rwxr-xr-x | gnulib/update-gnulib.sh | 4 |
10 files changed, 158 insertions, 10 deletions
diff --git a/gnulib/Makefile.in b/gnulib/Makefile.in index af264c3c12d..a29a9b6ce88 100644 --- a/gnulib/Makefile.in +++ b/gnulib/Makefile.in @@ -14,7 +14,7 @@ @SET_MAKE@ -# Copyright (C) 2019-2021 Free Software Foundation, Inc. +# Copyright (C) 2019-2022 Free Software Foundation, Inc. # This file is part of GDB. diff --git a/gnulib/doc/gendocs_template b/gnulib/doc/gendocs_template index c8c8fc61001..cd9ac38319a 100644 --- a/gnulib/doc/gendocs_template +++ b/gnulib/doc/gendocs_template @@ -2,7 +2,7 @@ <!-- Parent-Version: 1.78 --> <!-- -Copyright (C) 2006-2022 Free Software Foundation, Inc. +Copyright (C) 2006-2021 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright diff --git a/gnulib/doc/gendocs_template_min b/gnulib/doc/gendocs_template_min index 369f494476a..36e60ff79f9 100644 --- a/gnulib/doc/gendocs_template_min +++ b/gnulib/doc/gendocs_template_min @@ -4,7 +4,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <!-- -Copyright (C) 2007-2022 Free Software Foundation, Inc. +Copyright (C) 2007-2021 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright diff --git a/gnulib/import/glob.c b/gnulib/import/glob.c index 1bfcafb7b36..6307b1e91e7 100644 --- a/gnulib/import/glob.c +++ b/gnulib/import/glob.c @@ -743,6 +743,8 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), else { #ifndef WINDOWS32 + /* Recognize ~user as a shorthand for the specified user's home + directory. */ char *end_name = strchr (dirname, '/'); char *user_name; int malloc_user_name = 0; @@ -881,7 +883,22 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), } scratch_buffer_free (&pwtmpbuf); } -#endif /* !WINDOWS32 */ +#else /* WINDOWS32 */ + /* On native Windows, access to a user's home directory + (via GetUserProfileDirectory) or to a user's environment + variables (via ExpandEnvironmentStringsForUser) requires + the credentials of the user. Therefore we cannot support + the ~user syntax on this platform. + Handling ~user specially (and treat it like plain ~) if + user is getenv ("USERNAME") would not be a good idea, + since it would make people think that ~user is supported + in general. */ + if (flags & GLOB_TILDE_CHECK) + { + retval = GLOB_NOMATCH; + goto out; + } +#endif /* WINDOWS32 */ } } diff --git a/gnulib/import/select.c b/gnulib/import/select.c index 56ac8bb7b58..3a6857d1ccd 100644 --- a/gnulib/import/select.c +++ b/gnulib/import/select.c @@ -530,12 +530,13 @@ restart: if (h != handle_array[nhandles]) { /* Perform handle->descriptor mapping. */ - WSAEventSelect ((SOCKET) h, NULL, 0); - if (FD_ISSET (h, &handle_rfds)) + SOCKET s = (SOCKET) h; + WSAEventSelect (s, NULL, 0); + if (FD_ISSET (s, &handle_rfds)) FD_SET (i, rfds); - if (FD_ISSET (h, &handle_wfds)) + if (FD_ISSET (s, &handle_wfds)) FD_SET (i, wfds); - if (FD_ISSET (h, &handle_xfds)) + if (FD_ISSET (s, &handle_xfds)) FD_SET (i, xfds); } else diff --git a/gnulib/import/unistd.in.h b/gnulib/import/unistd.in.h index 5e9b47d981e..460d24866bc 100644 --- a/gnulib/import/unistd.in.h +++ b/gnulib/import/unistd.in.h @@ -2033,9 +2033,17 @@ _GL_WARN_ON_USE (sleep, "sleep is unportable - " # undef swab # define swab _swab # endif -_GL_CXXALIAS_MDA (swab, void, (char *from, char *to, int n)); -# else +/* Need to cast, because in old mingw the arguments are + (const char *from, char *to, size_t n). */ +_GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, int n)); +# else +# if defined __hpux /* HP-UX */ +_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n)); +# elif defined __sun && !defined _XPG4 /* Solaris */ +_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n)); +# else _GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n)); +# endif # endif _GL_CXXALIASWARN (swab); #endif diff --git a/gnulib/patches/0002-glob-tilde-check b/gnulib/patches/0002-glob-tilde-check new file mode 100644 index 00000000000..98bf54ed857 --- /dev/null +++ b/gnulib/patches/0002-glob-tilde-check @@ -0,0 +1,49 @@ +commit 38d0749a3077b03fda46567510b1217fb5e4e170 +Author: Bruno Haible <bruno@clisp.org> +Date: Fri Apr 2 17:34:46 2021 +0200 + + glob: Reject ~user syntax, when flag GLOB_TILDE_CHECK is given. + + Reported and patch suggested by Eli Zaretskii <eliz@gnu.org> in + <https://lists.gnu.org/archive/html/bug-gnulib/2021-03/msg00136.html>. + + * lib/glob.c (__glob) [WINDOWS32]: If flag GLOB_TILDE_CHECK is given, do + error handling like when ~user is allowed by the user is unknown. + +diff --git a/gnulib/import/glob.c b/gnulib/import/glob.c +index 775911ef5b..e148f8d761 100644 +--- a/gnulib/import/glob.c ++++ b/gnulib/import/glob.c +@@ -743,6 +743,8 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), + else + { + #ifndef WINDOWS32 ++ /* Recognize ~user as a shorthand for the specified user's home ++ directory. */ + char *end_name = strchr (dirname, '/'); + char *user_name; + int malloc_user_name = 0; +@@ -881,7 +883,22 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), + } + scratch_buffer_free (&pwtmpbuf); + } +-#endif /* !WINDOWS32 */ ++#else /* WINDOWS32 */ ++ /* On native Windows, access to a user's home directory ++ (via GetUserProfileDirectory) or to a user's environment ++ variables (via ExpandEnvironmentStringsForUser) requires ++ the credentials of the user. Therefore we cannot support ++ the ~user syntax on this platform. ++ Handling ~user specially (and treat it like plain ~) if ++ user is getenv ("USERNAME") would not be a good idea, ++ since it would make people think that ~user is supported ++ in general. */ ++ if (flags & GLOB_TILDE_CHECK) ++ { ++ retval = GLOB_NOMATCH; ++ goto out; ++ } ++#endif /* WINDOWS32 */ + } + } + diff --git a/gnulib/patches/0003-unistd-h-fix b/gnulib/patches/0003-unistd-h-fix new file mode 100644 index 00000000000..f573872ffa9 --- /dev/null +++ b/gnulib/patches/0003-unistd-h-fix @@ -0,0 +1,36 @@ +commit c7b1e060d17023065c776757da406d728310cc38 +Author: Bruno Haible <bruno@clisp.org> +Date: Sun Jun 20 17:18:26 2021 +0200 + + unistd: Avoid compilation error in C++ mode on Solaris, HP-UX, mingw. + + Reported by Eli Zaretskii <eliz@gnu.org> in + <https://lists.gnu.org/archive/html/bug-gnulib/2021-03/msg00135.html>. + + * lib/unistd.in.h (swab): Consider different declarations on Solaris, + HP-UX, and old mingw. + +diff --git a/gnulib/import/unistd.in.h b/gnulib/import/unistd.in.h +index d4d4ba7743..73c882f97b 100644 +--- a/gnulib/import/unistd.in.h ++++ b/gnulib/import/unistd.in.h +@@ -2034,9 +2034,17 @@ _GL_WARN_ON_USE (sleep, "sleep is unportable - " + # undef swab + # define swab _swab + # endif +-_GL_CXXALIAS_MDA (swab, void, (char *from, char *to, int n)); +-# else ++/* Need to cast, because in old mingw the arguments are ++ (const char *from, char *to, size_t n). */ ++_GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, int n)); ++# else ++# if defined __hpux /* HP-UX */ ++_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n)); ++# elif defined __sun && !defined _XPG4 /* Solaris */ ++_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n)); ++# else + _GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n)); ++# endif + # endif + _GL_CXXALIASWARN (swab); + #endif diff --git a/gnulib/patches/0004-select-mingw b/gnulib/patches/0004-select-mingw new file mode 100644 index 00000000000..912ae4d8503 --- /dev/null +++ b/gnulib/patches/0004-select-mingw @@ -0,0 +1,33 @@ +commit 21fccfa0451ba59fba479e439465da9c360353d3 +Author: Paul Eggert <eggert@cs.ucla.edu> +Date: Thu Jul 8 10:00:30 2021 -0700 + + select: port better to MinGW + + Problem reported by Eli Zaretskii in: + https://lists.gnu.org/r/bug-gnulib/2021-07/msg00017.html + * lib/select.c (rpl_select) [_WIN32 && !__CYGWIN__]: + Pass a SOCKET, not a HANDLE, to FD_ISSET. + +diff --git a/gnulib/import/select.c b/gnulib/import/select.c +index 2fe6a18064..eddac4b61f 100644 +--- a/gnulib/import/select.c ++++ b/gnulib/import/select.c +@@ -530,12 +530,13 @@ restart: + if (h != handle_array[nhandles]) + { + /* Perform handle->descriptor mapping. */ +- WSAEventSelect ((SOCKET) h, NULL, 0); +- if (FD_ISSET (h, &handle_rfds)) ++ SOCKET s = (SOCKET) h; ++ WSAEventSelect (s, NULL, 0); ++ if (FD_ISSET (s, &handle_rfds)) + FD_SET (i, rfds); +- if (FD_ISSET (h, &handle_wfds)) ++ if (FD_ISSET (s, &handle_wfds)) + FD_SET (i, wfds); +- if (FD_ISSET (h, &handle_xfds)) ++ if (FD_ISSET (s, &handle_xfds)) + FD_SET (i, xfds); + } + else diff --git a/gnulib/update-gnulib.sh b/gnulib/update-gnulib.sh index e4a910ff6c5..7e8a54410cf 100755 --- a/gnulib/update-gnulib.sh +++ b/gnulib/update-gnulib.sh @@ -180,6 +180,7 @@ fi # Apply our local patches. apply_patches () { + echo "Applying $1..." patch -p2 -f -i "$1" if [ $? -ne 0 ]; then echo "Failed to apply some patches. Aborting." @@ -188,6 +189,9 @@ apply_patches () } apply_patches "patches/0001-use-windows-stat" +apply_patches "patches/0002-glob-tilde-check" +apply_patches "patches/0003-unistd-h-fix" +apply_patches "patches/0004-select-mingw" # Regenerate all necessary files... aclocal && |