From 127ba08f6ea5b0950c627e6ab34c85abd3c73a15 Mon Sep 17 00:00:00 2001 From: Mitch Capper Date: Wed, 27 Nov 2024 01:54:40 -0800 Subject: [PATCH] Patch updates for latest gnulib --- ...s_GNULIB_BUILD_AUX_HANDLE_DOT_A_LIBS.patch | 18 +- ...LIB_FIX_SYSSTAT_TIMESPEC_DISABLE_BUG.patch | 4 +- patches/patches_GNULIB_FTS_MINOR_FIXES.patch | 11 +- ...IB_GNULIB_TOOL_APPLY_PATCHES_BY_FILE.patch | 14 +- ..._MSVC_PARAMETER_HANDLER_M4_MACRO_FIX.patch | 8 +- ...WINDOWS_CHOWN_CHMOD_GETUSER_GETGROUP.patch | 16 +- ...ches_GNULIB_PHYSMEM_TEST_MAIN_RENAME.patch | 8 +- ...ches_GNULIB_SPAWN_PIPE_FORK_FD_FIXES.patch | 12 +- patches/patches_GNULIB_WIN32_POLL_FIXES.patch | 14 +- ...tches_GNULIB_WINDOWS_SYMLINK_SUPPORT.patch | 48 +- .../patches_GNULIB_WINDOW_PATH_FIXES.patch | 1128 ++--------------- .../patches_GNULIB_WIN_FSUSAGE_FIXES.patch | 20 +- patches/repo_coreutils.patch | 2 +- patches/repo_findutils.patch | 138 +- 14 files changed, 275 insertions(+), 1166 deletions(-) diff --git a/patches/patches_GNULIB_BUILD_AUX_HANDLE_DOT_A_LIBS.patch b/patches/patches_GNULIB_BUILD_AUX_HANDLE_DOT_A_LIBS.patch index 59cc7aa..6fd0da3 100644 --- a/patches/patches_GNULIB_BUILD_AUX_HANDLE_DOT_A_LIBS.patch +++ b/patches/patches_GNULIB_BUILD_AUX_HANDLE_DOT_A_LIBS.patch @@ -1,5 +1,5 @@ diff --git a/build-aux/ar-lib b/build-aux/ar-lib -index 17de55e79c..33f0b676ef 100644 +index 1521987496..fa651e18a5 100644 --- a/build-aux/ar-lib +++ b/build-aux/ar-lib @@ -1,6 +1,11 @@ @@ -12,9 +12,9 @@ index 17de55e79c..33f0b676ef 100644 + . "$(dirname "$(readlink -f "$0")")/wrapper_helper.sh" "$@" +fi me=ar-lib - scriptversion=2019-07-04.01; # UTC + scriptversion=2024-06-19.01; # UTC -@@ -29,6 +34,14 @@ scriptversion=2019-07-04.01; # UTC +@@ -29,6 +34,14 @@ scriptversion=2024-06-19.01; # UTC # bugs to or send patches to # . @@ -57,7 +57,7 @@ index 17de55e79c..33f0b676ef 100644 done } -@@ -205,7 +223,7 @@ if test -n "$delete"; then +@@ -209,7 +227,7 @@ if test -n "$delete"; then ;; *) func_file_conv "$1" @@ -66,7 +66,7 @@ index 17de55e79c..33f0b676ef 100644 ;; esac done -@@ -223,15 +241,15 @@ elif test -n "$extract"; then +@@ -227,15 +245,15 @@ elif test -n "$extract"; then ;; *) func_file_conv "$1" @@ -85,7 +85,7 @@ index 17de55e79c..33f0b676ef 100644 done fi -@@ -262,14 +280,14 @@ elif test -n "$quick$replace"; then +@@ -266,14 +284,14 @@ elif test -n "$quick$replace"; then done if test -n "$orig_archive"; then @@ -104,7 +104,7 @@ index 17de55e79c..33f0b676ef 100644 + func_ar_run -LIST ${COLOR_MAJOR}"$archive"${COLOR_NONE} fi diff --git a/build-aux/compile b/build-aux/compile -index ba883b54aa..4e9157a535 100644 +index 49b3d05fde..a88792bed9 100644 --- a/build-aux/compile +++ b/build-aux/compile @@ -1,5 +1,10 @@ @@ -116,7 +116,7 @@ index ba883b54aa..4e9157a535 100644 + . "$(dirname "$(readlink -f "$0")")/wrapper_helper.sh" "$@" +fi - scriptversion=2018-03-07.03; # UTC + scriptversion=2024-06-19.01; # UTC @@ -49,6 +54,10 @@ func_file_conv () / | /[!/]*) # absolute file, and not a UNC file @@ -242,7 +242,7 @@ index ba883b54aa..4e9157a535 100644 do @@ -145,16 +189,32 @@ func_cl_wrapper () case $2 in - *.o | *.[oO][bB][jJ]) + *.o | *.lo | *.[oO][bB][jJ]) func_file_conv "$2" - set x "$@" -Fo"$file" + set x "$@" -Fo${COLOR_MAJOR}"$file"${COLOR_NONE} diff --git a/patches/patches_GNULIB_FIX_SYSSTAT_TIMESPEC_DISABLE_BUG.patch b/patches/patches_GNULIB_FIX_SYSSTAT_TIMESPEC_DISABLE_BUG.patch index 62b00a3..7b0cd95 100644 --- a/patches/patches_GNULIB_FIX_SYSSTAT_TIMESPEC_DISABLE_BUG.patch +++ b/patches/patches_GNULIB_FIX_SYSSTAT_TIMESPEC_DISABLE_BUG.patch @@ -1,8 +1,8 @@ diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h -index ad4da17fa4..da61a13df1 100644 +index 81138bce25..3139abaefc 100644 --- a/lib/sys_stat.in.h +++ b/lib/sys_stat.in.h -@@ -143,9 +143,10 @@ struct stat +@@ -170,9 +170,10 @@ struct stat # define st_ctime st_ctim.tv_sec /* Indicator, for gnulib internal purposes. */ # define _GL_WINDOWS_STAT_TIMESPEC 1 diff --git a/patches/patches_GNULIB_FTS_MINOR_FIXES.patch b/patches/patches_GNULIB_FTS_MINOR_FIXES.patch index fb0cf09..1b0061c 100644 --- a/patches/patches_GNULIB_FTS_MINOR_FIXES.patch +++ b/patches/patches_GNULIB_FTS_MINOR_FIXES.patch @@ -1,5 +1,5 @@ diff --git a/lib/fts.c b/lib/fts.c -index faeb4b20a5..f2bb85552a 100644 +index 92306bc72f..2073e4ff6b 100644 --- a/lib/fts.c +++ b/lib/fts.c @@ -123,6 +123,9 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; @@ -12,12 +12,3 @@ index faeb4b20a5..f2bb85552a 100644 enum { -@@ -1864,7 +1867,7 @@ fts_sort (FTS *sp, FTSENT *head, register size_t nitems) - FTSENT *dummy; - int (*compare) (void const *, void const *) = - ((sizeof &dummy == sizeof (void *) -- && (long int) &dummy == (long int) (void *) &dummy) -+ && (long long int) &dummy == (long long int) (void *) &dummy) - ? (int (*) (void const *, void const *)) sp->fts_compar - : fts_compar); - diff --git a/patches/patches_GNULIB_GNULIB_TOOL_APPLY_PATCHES_BY_FILE.patch b/patches/patches_GNULIB_GNULIB_TOOL_APPLY_PATCHES_BY_FILE.patch index b458904..2fc6176 100644 --- a/patches/patches_GNULIB_GNULIB_TOOL_APPLY_PATCHES_BY_FILE.patch +++ b/patches/patches_GNULIB_GNULIB_TOOL_APPLY_PATCHES_BY_FILE.patch @@ -1,13 +1,13 @@ -diff --git a/gnulib-tool b/gnulib-tool -index ae1b17f4dd..7b38761978 100644 ---- a/gnulib-tool -+++ b/gnulib-tool -@@ -1793,7 +1793,7 @@ func_lookup_file () +diff --git a/gnulib-tool.sh b/gnulib-tool.sh +index d4f8792898..0e291be22e 100644 +--- a/gnulib-tool.sh ++++ b/gnulib-tool.sh +@@ -1825,7 +1825,7 @@ func_lookup_file () IFS="$PATH_SEPARATOR" for patchfile in $lkpatches; do - IFS="$save_IFS" + IFS="$saved_IFS" - patch -s "$tmp/$lkbase" < "$patchfile" >&2 \ + patch --ignore-whitespace -i "$patchfile" "$tmp/$lkbase" >&2 \ || func_fatal_error "patch file $patchfile didn't apply cleanly" done - IFS="$save_IFS" + IFS="$saved_IFS" diff --git a/patches/patches_GNULIB_MSVC_PARAMETER_HANDLER_M4_MACRO_FIX.patch b/patches/patches_GNULIB_MSVC_PARAMETER_HANDLER_M4_MACRO_FIX.patch index 0b1209c..311e13a 100644 --- a/patches/patches_GNULIB_MSVC_PARAMETER_HANDLER_M4_MACRO_FIX.patch +++ b/patches/patches_GNULIB_MSVC_PARAMETER_HANDLER_M4_MACRO_FIX.patch @@ -1,12 +1,12 @@ diff --git a/m4/printf.m4 b/m4/printf.m4 -index 8b8f01067f..198e3363b7 100644 +index 4c3e8ecf2d..e1d99ea315 100644 --- a/m4/printf.m4 +++ b/m4/printf.m4 -@@ -908,6 +908,7 @@ int main () +@@ -931,6 +931,7 @@ int main () { int count = -1; #ifdef _MSC_VER + _set_error_mode(1); #1 being _OUT_TO_STDERR, disable abort/retry/ignore popup in debug mode _set_invalid_parameter_handler (invalid_parameter_handler); - #endif - /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) + /* Also avoid an Abort/Retry/Ignore dialog in debug builds. + */ diff --git a/patches/patches_GNULIB_NOOP_FOR_WINDOWS_CHOWN_CHMOD_GETUSER_GETGROUP.patch b/patches/patches_GNULIB_NOOP_FOR_WINDOWS_CHOWN_CHMOD_GETUSER_GETGROUP.patch index b97e415..49242b7 100644 --- a/patches/patches_GNULIB_NOOP_FOR_WINDOWS_CHOWN_CHMOD_GETUSER_GETGROUP.patch +++ b/patches/patches_GNULIB_NOOP_FOR_WINDOWS_CHOWN_CHMOD_GETUSER_GETGROUP.patch @@ -1,8 +1,8 @@ diff --git a/lib/dirchownmod.c b/lib/dirchownmod.c -index b3dbac3374..992b810c97 100644 +index d5f7b5432a..42ab816fa8 100644 --- a/lib/dirchownmod.c +++ b/lib/dirchownmod.c -@@ -62,6 +62,7 @@ dirchownmod (int fd, char const *dir, mode_t mkdir_mode, +@@ -68,6 +68,7 @@ dirchownmod (int fd, char const *dir, mode_t mkdir_mode, uid_t owner, gid_t group, mode_t mode, mode_t mode_bits) { @@ -10,7 +10,7 @@ index b3dbac3374..992b810c97 100644 struct stat st; int result = (fd < 0 ? stat (dir, &st) : fstat (fd, &st)); -@@ -138,4 +139,7 @@ dirchownmod (int fd, char const *dir, mode_t mkdir_mode, +@@ -144,4 +145,7 @@ dirchownmod (int fd, char const *dir, mode_t mkdir_mode, } return result; @@ -19,7 +19,7 @@ index b3dbac3374..992b810c97 100644 +#endif } diff --git a/lib/idcache.c b/lib/idcache.c -index ff1233aa17..2a2d8b6202 100644 +index ccaf56dad2..239a332746 100644 --- a/lib/idcache.c +++ b/lib/idcache.c @@ -22,8 +22,10 @@ @@ -107,10 +107,10 @@ index ff1233aa17..2a2d8b6202 100644 + #endif } diff --git a/lib/savewd.c b/lib/savewd.c -index 4eddba32dc..dcddb342a0 100644 +index 3a0361425a..301127e7e0 100644 --- a/lib/savewd.c +++ b/lib/savewd.c -@@ -70,7 +70,11 @@ savewd_save (struct savewd *wd) +@@ -87,7 +87,11 @@ savewd_save (struct savewd *wd) /* "Save" the initial working directory by forking a new subprocess that will attempt all the work from the chdir until the next savewd_restore. */ @@ -122,7 +122,7 @@ index 4eddba32dc..dcddb342a0 100644 if (wd->val.child != 0) { if (0 < wd->val.child) -@@ -204,8 +208,12 @@ savewd_restore (struct savewd *wd, int status) +@@ -221,8 +225,12 @@ savewd_restore (struct savewd *wd, int status) if (0 < child) { int child_status; @@ -136,7 +136,7 @@ index 4eddba32dc..dcddb342a0 100644 if (! WIFEXITED (child_status)) raise (WTERMSIG (child_status)); diff --git a/lib/userspec.c b/lib/userspec.c -index 5958883ff4..b0912df1fc 100644 +index 833f7f58d7..1f992e083a 100644 --- a/lib/userspec.c +++ b/lib/userspec.c @@ -24,8 +24,12 @@ diff --git a/patches/patches_GNULIB_PHYSMEM_TEST_MAIN_RENAME.patch b/patches/patches_GNULIB_PHYSMEM_TEST_MAIN_RENAME.patch index 7e2d607..ee23f32 100644 --- a/patches/patches_GNULIB_PHYSMEM_TEST_MAIN_RENAME.patch +++ b/patches/patches_GNULIB_PHYSMEM_TEST_MAIN_RENAME.patch @@ -1,17 +1,17 @@ diff --git a/lib/physmem.c b/lib/physmem.c -index 398f99b727..15a3f0898e 100644 +index 5c226b8abf..b640a7706e 100644 --- a/lib/physmem.c +++ b/lib/physmem.c -@@ -313,7 +313,7 @@ physmem_available (void) +@@ -398,7 +398,7 @@ physmem_available (void) + return physmem_claimable (0.0); } - -#if DEBUG +#if TEST # include # include -@@ -325,7 +325,7 @@ main (void) +@@ -410,7 +410,7 @@ main (void) exit (0); } diff --git a/patches/patches_GNULIB_SPAWN_PIPE_FORK_FD_FIXES.patch b/patches/patches_GNULIB_SPAWN_PIPE_FORK_FD_FIXES.patch index 90468de..de63993 100644 --- a/patches/patches_GNULIB_SPAWN_PIPE_FORK_FD_FIXES.patch +++ b/patches/patches_GNULIB_SPAWN_PIPE_FORK_FD_FIXES.patch @@ -1,10 +1,10 @@ diff --git a/lib/pipe.c b/lib/pipe.c -index e8573ed97f..ea11ab21fa 100644 +index 167d8f8c5e..92a8e602bb 100644 --- a/lib/pipe.c +++ b/lib/pipe.c @@ -34,7 +34,7 @@ pipe (int fd[2]) /* Mingw changes fd to {-1,-1} on failure, but this violates - http://austingroupbugs.net/view.php?id=467 */ + https://austingroupbugs.net/view.php?id=467 */ int tmp[2]; - int result = _pipe (tmp, 4096, _O_BINARY); + int result = _pipe (tmp, 4096, _O_BINARY | _O_NOINHERIT); @@ -12,10 +12,10 @@ index e8573ed97f..ea11ab21fa 100644 { fd[0] = tmp[0]; diff --git a/lib/spawn-pipe.c b/lib/spawn-pipe.c -index d2d21e6e8e..e730c9dedc 100644 +index fe60646c43..d9e44d0161 100644 --- a/lib/spawn-pipe.c +++ b/lib/spawn-pipe.c -@@ -593,7 +593,7 @@ create_pipe (const char *progname, +@@ -596,7 +596,7 @@ create_pipe (const char *progname, fail_with_saved_errno: if (exit_on_error || !null_stderr) error (exit_on_error ? EXIT_FAILURE : 0, saved_errno, @@ -25,7 +25,7 @@ index d2d21e6e8e..e730c9dedc 100644 return -1; } diff --git a/lib/spawn_faction_addclose.c b/lib/spawn_faction_addclose.c -index c87a23794b..9087ac4af1 100644 +index af1e77a0d4..f4685fbacd 100644 --- a/lib/spawn_faction_addclose.c +++ b/lib/spawn_faction_addclose.c @@ -15,7 +15,12 @@ @@ -60,7 +60,7 @@ index c87a23794b..9087ac4af1 100644 return posix_spawn_file_actions_addclose (file_actions, fd); #else diff --git a/lib/w32sock.h b/lib/w32sock.h -index 84e46e3356..8ffd214597 100644 +index 166a5f777e..18a6d781ec 100644 --- a/lib/w32sock.h +++ b/lib/w32sock.h @@ -33,7 +33,7 @@ diff --git a/patches/patches_GNULIB_WIN32_POLL_FIXES.patch b/patches/patches_GNULIB_WIN32_POLL_FIXES.patch index dae1e62..1b28e4f 100644 --- a/patches/patches_GNULIB_WIN32_POLL_FIXES.patch +++ b/patches/patches_GNULIB_WIN32_POLL_FIXES.patch @@ -1,8 +1,8 @@ diff --git a/lib/poll.c b/lib/poll.c -index ec8d2c2b55..80a68aff03 100644 +index 37cb2d7ba4..292d3b3b99 100644 --- a/lib/poll.c +++ b/lib/poll.c -@@ -364,6 +364,11 @@ compute_revents (int fd, int sought, fd_set *rfds, fd_set *wfds, fd_set *efds) +@@ -359,6 +359,11 @@ compute_revents (int fd, int sought, fd_set *rfds, fd_set *wfds, fd_set *efds) } #endif /* !MinGW */ @@ -14,7 +14,7 @@ index ec8d2c2b55..80a68aff03 100644 int poll (struct pollfd *pfd, nfds_t nfd, int timeout) { -@@ -463,11 +468,13 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout) +@@ -458,11 +463,13 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout) return rc; #else static struct timeval tv0; @@ -29,7 +29,7 @@ index ec8d2c2b55..80a68aff03 100644 BOOL poll_again; MSG msg; int rc = 0; -@@ -539,6 +546,9 @@ restart: +@@ -534,6 +541,9 @@ restart: timeout = 0; } } @@ -39,7 +39,7 @@ index ec8d2c2b55..80a68aff03 100644 if (select (0, &rfds, &wfds, &xfds, &tv0) > 0) { -@@ -575,8 +585,13 @@ restart: +@@ -570,8 +580,13 @@ restart: break; } @@ -55,7 +55,7 @@ index ec8d2c2b55..80a68aff03 100644 /* Place a sentinel at the end of the array. */ handle_array[nhandles] = NULL; -@@ -632,3 +647,21 @@ restart: +@@ -627,3 +642,21 @@ restart: return rc; #endif } @@ -79,7 +79,7 @@ index ec8d2c2b55..80a68aff03 100644 +} \ No newline at end of file diff --git a/lib/poll.in.h b/lib/poll.in.h -index 75ca21f4cc..2d57f3ffdb 100644 +index 29b2d26150..48a2f7565c 100644 --- a/lib/poll.in.h +++ b/lib/poll.in.h @@ -124,7 +124,7 @@ _GL_WARN_ON_USE (poll, "poll is unportable - " diff --git a/patches/patches_GNULIB_WINDOWS_SYMLINK_SUPPORT.patch b/patches/patches_GNULIB_WINDOWS_SYMLINK_SUPPORT.patch index dbb1ab4..cfb4c43 100644 --- a/patches/patches_GNULIB_WINDOWS_SYMLINK_SUPPORT.patch +++ b/patches/patches_GNULIB_WINDOWS_SYMLINK_SUPPORT.patch @@ -1,5 +1,5 @@ diff --git a/lib/c-file-type.c b/lib/c-file-type.c -index efc17c5ccc..0fd9b92b9e 100644 +index 1c558796f9..90c0832f77 100644 --- a/lib/c-file-type.c +++ b/lib/c-file-type.c @@ -39,12 +39,12 @@ c_file_type (struct stat const *st) @@ -19,19 +19,19 @@ index efc17c5ccc..0fd9b92b9e 100644 of S_ISNAM, and we want the more-specialized interpretation. */ diff --git a/lib/dirent.in.h b/lib/dirent.in.h -index d409a031ec..f9956d6edc 100644 +index a0ac39b496..42da5b2a1d 100644 --- a/lib/dirent.in.h +++ b/lib/dirent.in.h -@@ -57,6 +57,7 @@ struct dirent - # define DT_SOCK 12 /* socket */ - # define DT_WHT 14 /* whiteout */ +@@ -47,6 +47,7 @@ struct dirent + char d_name[1]; + }; # define GNULIB_defined_struct_dirent 1 +# define HAVE_STRUCT_DIRENT_D_TYPE 1 //we could mod scripts that only look for rthiss or just say we have dirent # endif #endif diff --git a/lib/filemode.c b/lib/filemode.c -index 318d287f27..c92bec74a4 100644 +index 9be6aad187..5af42eacdf 100644 --- a/lib/filemode.c +++ b/lib/filemode.c @@ -45,6 +45,8 @@ ftypelet (mode_t bits) @@ -53,7 +53,7 @@ index 318d287f27..c92bec74a4 100644 return 'p'; diff --git a/lib/fstatat.c b/lib/fstatat.c -index 372965ef5f..84f2e92044 100644 +index 470ef336cf..66171a7c82 100644 --- a/lib/fstatat.c +++ b/lib/fstatat.c @@ -113,7 +113,7 @@ rpl_fstatat (int fd, char const *file, struct stat *st, int flag) @@ -66,7 +66,7 @@ index 372965ef5f..84f2e92044 100644 /* Likewise, if there is no native 'lstat', then the gnulib diff --git a/lib/fts.c b/lib/fts.c -index faeb4b20a5..c2f51b2062 100644 +index 92306bc72f..587663e40c 100644 --- a/lib/fts.c +++ b/lib/fts.c @@ -117,9 +117,7 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; @@ -100,7 +100,7 @@ index faeb4b20a5..c2f51b2062 100644 return (FTS_F); return (FTS_DEFAULT); diff --git a/lib/readdir.c b/lib/readdir.c -index 04dbba21bc..608f1f3fe5 100644 +index fab1964308..2f4206ad52 100644 --- a/lib/readdir.c +++ b/lib/readdir.c @@ -77,10 +77,11 @@ readdir (DIR *dirp) @@ -119,7 +119,7 @@ index 04dbba21bc..608f1f3fe5 100644 & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN diff --git a/lib/readlink.c b/lib/readlink.c -index 14bbb7f10c..23549b8989 100644 +index f4af30ebc4..b7fb31caf2 100644 --- a/lib/readlink.c +++ b/lib/readlink.c @@ -27,7 +27,7 @@ @@ -309,7 +309,7 @@ index 14bbb7f10c..23549b8989 100644 #else /* HAVE_READLINK */ diff --git a/lib/stat-w32.c b/lib/stat-w32.c -index 2f01197584..28f8f74ea4 100644 +index ddd6f59856..3bf1007962 100644 --- a/lib/stat-w32.c +++ b/lib/stat-w32.c @@ -260,13 +260,18 @@ _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf) @@ -334,7 +334,7 @@ index 2f01197584..28f8f74ea4 100644 /* Determine whether the file is executable by looking at the file name suffix. diff --git a/lib/stat.c b/lib/stat.c -index 7987e26583..d258d141d2 100644 +index ecf9f9bbe9..882db060ac 100644 --- a/lib/stat.c +++ b/lib/stat.c @@ -107,7 +107,24 @@ is_unc_root (const char *rname) @@ -411,7 +411,7 @@ index 7987e26583..d258d141d2 100644 /* Determine whether the file is executable by looking at the file name suffix. */ diff --git a/lib/symlink.c b/lib/symlink.c -index b5009ae835..abca0f5b50 100644 +index 6ba83666e1..1d8aa84e7f 100644 --- a/lib/symlink.c +++ b/lib/symlink.c @@ -24,7 +24,10 @@ @@ -455,7 +455,7 @@ index b5009ae835..abca0f5b50 100644 #else /* !HAVE_SYMLINK */ diff --git a/lib/symlinkat.c b/lib/symlinkat.c -index 11eda8289a..7bae7b1486 100644 +index 920001a6fa..93f7feb078 100644 --- a/lib/symlinkat.c +++ b/lib/symlinkat.c @@ -47,7 +47,7 @@ rpl_symlinkat (char const *contents, int fd, char const *name) @@ -468,10 +468,10 @@ index 11eda8289a..7bae7b1486 100644 wrapper than to go through at-func.c to call rpl_symlink. */ diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h -index ad4da17fa4..523873e39f 100644 +index 81138bce25..14a486e437 100644 --- a/lib/sys_stat.in.h +++ b/lib/sys_stat.in.h -@@ -220,12 +220,23 @@ struct stat +@@ -247,12 +247,23 @@ struct stat # endif #endif @@ -495,7 +495,7 @@ index ad4da17fa4..523873e39f 100644 #endif #ifndef S_ISMPB /* V7 */ -@@ -878,7 +889,11 @@ _GL_WARN_ON_USE (stat, "stat is unportable - " +@@ -914,7 +925,11 @@ _GL_WARN_ON_USE (stat, "stat is unportable - " /* mingw does not support symlinks, therefore it does not have lstat. But without links, stat does just fine. */ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -508,7 +508,7 @@ index ad4da17fa4..523873e39f 100644 _GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *restrict name, struct stat *restrict buf)); diff --git a/lib/unlink.c b/lib/unlink.c -index d77d26298e..6359e1c9fb 100644 +index ca656e3999..871ef71ea6 100644 --- a/lib/unlink.c +++ b/lib/unlink.c @@ -93,6 +93,22 @@ rpl_unlink (char const *name) @@ -535,7 +535,7 @@ index d77d26298e..6359e1c9fb 100644 return result; } diff --git a/lib/utime.c b/lib/utime.c -index 3cf1840feb..79e4ce3320 100644 +index 3535764a2f..b62f1de34d 100644 --- a/lib/utime.c +++ b/lib/utime.c @@ -96,6 +96,7 @@ _gl_utimens_windows (const char *name, struct timespec ts[2]) @@ -547,10 +547,10 @@ index 3cf1840feb..79e4ce3320 100644 in case as different) makes sense only when applied to *all* filesystem operations. */ diff --git a/lib/utimens.c b/lib/utimens.c -index faa197e6cb..1a25964744 100644 +index 3c81b5c349..ea35d172f5 100644 --- a/lib/utimens.c +++ b/lib/utimens.c -@@ -639,7 +639,9 @@ lutimens (char const *file, struct timespec const timespec[2]) +@@ -672,7 +672,9 @@ lutimens (char const *file, struct timespec const timespec[2]) /* Out of luck for symlinks, but we still handle regular files. */ if (!(adjustment_needed || REPLACE_FUNC_STAT_FILE) && lstat (file, &st)) return -1; @@ -561,10 +561,10 @@ index faa197e6cb..1a25964744 100644 errno = ENOSYS; return -1; diff --git a/m4/symlink.m4 b/m4/symlink.m4 -index 52d6c115ca..2b235cd4b4 100644 +index e56c96e6e0..349c169e1d 100644 --- a/m4/symlink.m4 +++ b/m4/symlink.m4 -@@ -17,7 +17,17 @@ AC_DEFUN([gl_FUNC_SYMLINK], +@@ -19,7 +19,17 @@ AC_DEFUN([gl_FUNC_SYMLINK], dnl that compilation can proceed with fewer ifdefs. On FreeBSD 7.2, AIX 7.1, dnl and Solaris 9, we want to fix a bug with trailing slash handling. if test $ac_cv_func_symlink = no; then @@ -584,7 +584,7 @@ index 52d6c115ca..2b235cd4b4 100644 AC_CACHE_CHECK([whether symlink handles trailing slash correctly], [gl_cv_func_symlink_works], diff --git a/tests/test-readlinkat.c b/tests/test-readlinkat.c -index 5a18fa3642..9b723a2d5e 100644 +index 5451972c79..6e17ddcde9 100644 --- a/tests/test-readlinkat.c +++ b/tests/test-readlinkat.c @@ -79,7 +79,7 @@ main (void) diff --git a/patches/patches_GNULIB_WINDOW_PATH_FIXES.patch b/patches/patches_GNULIB_WINDOW_PATH_FIXES.patch index 2997378..ada59c6 100644 --- a/patches/patches_GNULIB_WINDOW_PATH_FIXES.patch +++ b/patches/patches_GNULIB_WINDOW_PATH_FIXES.patch @@ -1,5 +1,5 @@ diff --git a/lib/argp-help.c b/lib/argp-help.c -index e5baee2ca8..d3970e4f4e 100644 +index 193fd384b7..397157da7d 100644 --- a/lib/argp-help.c +++ b/lib/argp-help.c @@ -47,7 +47,7 @@ @@ -11,7 +11,7 @@ index e5baee2ca8..d3970e4f4e 100644 #include "argp.h" #include "argp-fmtstream.h" #include "argp-namefrob.h" -@@ -1828,7 +1828,7 @@ char * +@@ -1833,7 +1833,7 @@ char * __argp_short_program_name (void) { # if HAVE_DECL_PROGRAM_INVOCATION_NAME @@ -21,7 +21,7 @@ index e5baee2ca8..d3970e4f4e 100644 # else /* FIXME: What now? Miles suggests that it is better to use NULL, diff --git a/lib/basename.c b/lib/basename.c -index 21fab1efad..a52738c101 100644 +index c5a6bdc9d5..c330723c9b 100644 --- a/lib/basename.c +++ b/lib/basename.c @@ -22,6 +22,7 @@ @@ -42,7 +42,7 @@ index 21fab1efad..a52738c101 100644 /* Finally, copy the basename. */ diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c -index e701297d84..b6d56fb443 100644 +index efd79ceebb..7a4ae6e265 100644 --- a/lib/canonicalize-lgpl.c +++ b/lib/canonicalize-lgpl.c @@ -242,12 +242,12 @@ realpath_stk (const char *name, char *resolved, struct realpath_bufs *bufs) @@ -84,941 +84,62 @@ index e701297d84..b6d56fb443 100644 } /* Install the new prefix to be in effect hereafter. */ diff --git a/lib/canonicalize.c b/lib/canonicalize.c -index d73ee2c894..e83e66b307 100644 +index 2572b40558..46224b63c6 100644 --- a/lib/canonicalize.c +++ b/lib/canonicalize.c -@@ -1,469 +1,463 @@ --/* Return the canonical absolute name of a given file. -- Copyright (C) 1996-2023 Free Software Foundation, Inc. -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . */ -- --#include -- --#include "canonicalize.h" -- --#include --#include --#include --#include --#include -- --#include --#include --#include --#include -- --#include "attribute.h" --#include "file-set.h" --#include "hash-triple.h" --#include "xalloc.h" -- --#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT --# define DOUBLE_SLASH_IS_DISTINCT_ROOT false --#endif -- +@@ -45,11 +45,6 @@ + # define DOUBLE_SLASH_IS_DISTINCT_ROOT false + #endif + -#if ISSLASH ('\\') -# define SLASHES "/\\" -#else -# define SLASHES "/" -#endif -- --/* Avoid false GCC warning "'end_idx' may be used uninitialized". */ -+/* Return the canonical absolute name of a given file. -+ Copyright (C) 1996-2023 Free Software Foundation, Inc. -+ -+ This program is free software: you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation, either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include -+ -+#include "canonicalize.h" -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+ -+#include "attribute.h" -+#include "file-set.h" -+#include "hash-triple.h" -+#include "xalloc.h" -+ -+#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT -+# define DOUBLE_SLASH_IS_DISTINCT_ROOT false -+#endif -+ -+ -+/* Avoid false GCC warning "'end_idx' may be used uninitialized". */ - #if __GNUC__ + (__GNUC_MINOR__ >= 7) > 4 - # pragma GCC diagnostic ignored "-Wmaybe-uninitialized" - #endif -- --/* Return true if FILE's existence can be shown, false (setting errno) -- otherwise. Follow symbolic links. */ --static bool --file_accessible (char const *file) --{ --# if HAVE_FACCESSAT -- return faccessat (AT_FDCWD, file, F_OK, AT_EACCESS) == 0; --# else -- struct stat st; -- return stat (file, &st) == 0 || errno == EOVERFLOW; --# endif --} -- --/* True if concatenating END as a suffix to a file name means that the -- code needs to check that the file name is that of a searchable -- directory, since the canonicalize_filename_mode_stk code won't -- check this later anyway when it checks an ordinary file name -- component within END. END must either be empty, or start with a -- slash. */ -- --static bool _GL_ATTRIBUTE_PURE --suffix_requires_dir_check (char const *end) --{ -- /* If END does not start with a slash, the suffix is OK. */ -- while (ISSLASH (*end)) -- { -- /* Two or more slashes act like a single slash. */ -- do -- end++; -- while (ISSLASH (*end)); -- -- switch (*end++) -- { -- default: return false; /* An ordinary file name component is OK. */ -- case '\0': return true; /* Trailing "/" is trouble. */ -- case '.': break; /* Possibly "." or "..". */ -- } -- /* Trailing "/.", or "/.." even if not trailing, is trouble. */ -- if (!*end || (*end == '.' && (!end[1] || ISSLASH (end[1])))) -- return true; -- } -- -- return false; --} -- --/* Append this to a file name to test whether it is a searchable directory. -- On POSIX platforms "/" suffices, but "/./" is sometimes needed on -- macOS 10.13 , and should also work on -- platforms like AIX 7.2 that need at least "/.". */ -- --#ifdef LSTAT_FOLLOWS_SLASHED_SYMLINK --static char const dir_suffix[] = "/"; --#else --static char const dir_suffix[] = "/./"; --#endif -- --/* Return true if DIR is a searchable dir, false (setting errno) otherwise. -- DIREND points to the NUL byte at the end of the DIR string. -- Store garbage into DIREND[0 .. strlen (dir_suffix)]. */ -- --static bool --dir_check (char *dir, char *dirend) --{ -- strcpy (dirend, dir_suffix); -- return file_accessible (dir); --} -- --#if !((HAVE_CANONICALIZE_FILE_NAME && FUNC_REALPATH_WORKS) \ -- || GNULIB_CANONICALIZE_LGPL) --/* Return the canonical absolute name of file NAME. A canonical name -- does not contain any ".", ".." components nor any repeated file name -- separators ('/') or symlinks. All components must exist. -- The result is malloc'd. */ -- --char * --canonicalize_file_name (const char *name) --{ -- return canonicalize_filename_mode (name, CAN_EXISTING); --} --#endif /* !HAVE_CANONICALIZE_FILE_NAME */ -- --static bool --multiple_bits_set (canonicalize_mode_t i) --{ -- return (i & (i - 1)) != 0; --} -- --/* Return true if we've already seen the triple, . -- If *HT is not initialized, initialize it. */ --static bool --seen_triple (Hash_table **ht, char const *filename, struct stat const *st) --{ -- if (*ht == NULL) -- { -- idx_t initial_capacity = 7; -- *ht = hash_initialize (initial_capacity, -- NULL, -- triple_hash, -- triple_compare_ino_str, -- triple_free); -- if (*ht == NULL) -- xalloc_die (); -- } -- -- if (seen_file (*ht, filename, st)) -- return true; -- -- record_file (*ht, filename, st); -- return false; --} -- --/* Scratch buffers used by canonicalize_filename_mode_stk and managed -- by __realpath. */ --struct realpath_bufs --{ -- struct scratch_buffer rname; -- struct scratch_buffer extra; -- struct scratch_buffer link; --}; -- --static char * --canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode, -- struct realpath_bufs *bufs) --{ -- char *dest; -- char const *start; -- char const *end; -- Hash_table *ht = NULL; -- bool logical = (can_mode & CAN_NOLINKS) != 0; -- int num_links = 0; -- -- canonicalize_mode_t can_exist = can_mode & CAN_MODE_MASK; -- if (multiple_bits_set (can_exist)) -- { -- errno = EINVAL; -- return NULL; -- } -- -- if (name == NULL) -- { -- errno = EINVAL; -- return NULL; -- } -- -- if (name[0] == '\0') -- { -- errno = ENOENT; -- return NULL; -- } -- -- char *rname = bufs->rname.data; -- bool end_in_extra_buffer = false; -- bool failed = true; -- -- /* This is always zero for Posix hosts, but can be 2 for MS-Windows -- and MS-DOS X:/foo/bar file names. */ -- idx_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name); -- -- if (!IS_ABSOLUTE_FILE_NAME (name)) -- { -- while (!getcwd (bufs->rname.data, bufs->rname.length)) -- { -- switch (errno) -- { -- case ERANGE: -- if (scratch_buffer_grow (&bufs->rname)) -- break; -- FALLTHROUGH; -- case ENOMEM: -- xalloc_die (); -- -- default: -- dest = rname; -- goto error; -- } -- rname = bufs->rname.data; -- } -- dest = rawmemchr (rname, '\0'); -- start = name; -- prefix_len = FILE_SYSTEM_PREFIX_LEN (rname); -- } -- else -- { -- dest = mempcpy (rname, name, prefix_len); + + /* Avoid false GCC warning "'end_idx' may be used uninitialized". */ + #if _GL_GNUC_PREREQ (4, 7) +@@ -240,13 +235,13 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode, + else + { + dest = mempcpy (rname, name, prefix_len); - *dest++ = '/'; -- if (DOUBLE_SLASH_IS_DISTINCT_ROOT) -- { -- if (prefix_len == 0 /* implies ISSLASH (name[0]) */ -- && ISSLASH (name[1]) && !ISSLASH (name[2])) -- { -- *dest++ = '/'; --#if defined _WIN32 && !defined __CYGWIN__ -- /* For UNC file names '\\server\path\to\file', extend the prefix -- to include the server: '\\server\'. */ -- { -- idx_t i; -- for (i = 2; name[i] != '\0' && !ISSLASH (name[i]); ) -- i++; -- if (name[i] != '\0' /* implies ISSLASH (name[i]) */ -- && i + 1 < bufs->rname.length) -- { -- prefix_len = i; -- memcpy (dest, name + 2, i - 2 + 1); -- dest += i - 2 + 1; -- } -- else -- { -- /* Either name = '\\server'; this is an invalid file name. -- Or name = '\\server\...' and server is more than -- bufs->rname.length - 4 bytes long. In either -- case, stop the UNC processing. */ -- } -- } --#endif -- } -- *dest = '\0'; -- } -- start = name + prefix_len; -- } -- -- for ( ; *start; start = end) -- { -- /* Skip sequence of multiple file name separators. */ -- while (ISSLASH (*start)) -- ++start; -- -- /* Find end of component. */ -- for (end = start; *end && !ISSLASH (*end); ++end) -- /* Nothing. */; -- -- /* Length of this file name component; it can be zero if a file -- name ends in '/'. */ -- idx_t startlen = end - start; -- -- if (startlen == 0) -- break; -- else if (startlen == 1 && start[0] == '.') -- /* nothing */; -- else if (startlen == 2 && start[0] == '.' && start[1] == '.') -- { -- /* Back up to previous component, ignore if at root already. */ -- if (dest > rname + prefix_len + 1) -- for (--dest; dest > rname && !ISSLASH (dest[-1]); --dest) -- continue; -- if (DOUBLE_SLASH_IS_DISTINCT_ROOT -- && dest == rname + 1 && !prefix_len -- && ISSLASH (*dest) && !ISSLASH (dest[1])) -- dest++; -- } -- else -- { -- if (!ISSLASH (dest[-1])) -- *dest++ = '/'; -- -- while (rname + bufs->rname.length - dest -- < startlen + sizeof dir_suffix) -- { -- idx_t dest_offset = dest - rname; -- if (!scratch_buffer_grow_preserve (&bufs->rname)) -- xalloc_die (); -- rname = bufs->rname.data; -- dest = rname + dest_offset; -- } -- -- dest = mempcpy (dest, start, startlen); -- *dest = '\0'; -- -- char *buf; -- ssize_t n = -1; -- if (!logical) -- { -- while (true) -- { -- buf = bufs->link.data; -- idx_t bufsize = bufs->link.length; -- n = readlink (rname, buf, bufsize - 1); -- if (n < bufsize - 1) -- break; -- if (!scratch_buffer_grow (&bufs->link)) -- xalloc_die (); -- } -- } -- if (0 <= n) -- { -- /* A physical traversal and RNAME is a symbolic link. */ -- -- if (num_links < 20) -- num_links++; -- else if (*start) -- { -- /* Enough symlinks have been seen that it is time to -- worry about being in a symlink cycle. -- Get the device and inode of the parent directory, as -- pre-2017 POSIX says this info is not reliable for -- symlinks. */ -- struct stat st; -- dest[- startlen] = '\0'; -- if (stat (*rname ? rname : ".", &st) != 0) -- goto error; -- dest[- startlen] = *start; -- -- /* Detect loops. We cannot use the cycle-check module here, -- since it's possible to encounter the same parent -- directory more than once in a given traversal. However, -- encountering the same (parentdir, START) pair twice does -- indicate a loop. */ -- if (seen_triple (&ht, start, &st)) -- { -- if (can_exist == CAN_MISSING) -- continue; -- errno = ELOOP; -- goto error; -- } -- } -- -- buf[n] = '\0'; -- -- char *extra_buf = bufs->extra.data; -- idx_t end_idx; -- if (end_in_extra_buffer) -- end_idx = end - extra_buf; -- size_t len = strlen (end); -- if (INT_ADD_OVERFLOW (len, n)) -- xalloc_die (); -- while (bufs->extra.length <= len + n) -- { -- if (!scratch_buffer_grow_preserve (&bufs->extra)) -- xalloc_die (); -- extra_buf = bufs->extra.data; -- } -- if (end_in_extra_buffer) -- end = extra_buf + end_idx; -- -- /* Careful here, end may be a pointer into extra_buf... */ -- memmove (&extra_buf[n], end, len + 1); -- name = end = memcpy (extra_buf, buf, n); -- end_in_extra_buffer = true; -- -- if (IS_ABSOLUTE_FILE_NAME (buf)) -- { -- idx_t pfxlen = FILE_SYSTEM_PREFIX_LEN (buf); -- -- dest = mempcpy (rname, buf, pfxlen); -- *dest++ = '/'; /* It's an absolute symlink */ -- if (DOUBLE_SLASH_IS_DISTINCT_ROOT) -- { -- if (ISSLASH (buf[1]) && !ISSLASH (buf[2]) && !pfxlen) -- *dest++ = '/'; -- *dest = '\0'; -- } -- /* Install the new prefix to be in effect hereafter. */ -- prefix_len = pfxlen; -- } -- else -- { -- /* Back up to previous component, ignore if at root -- already: */ -- if (dest > rname + prefix_len + 1) -- for (--dest; dest > rname && !ISSLASH (dest[-1]); --dest) -- continue; -- if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1 -- && ISSLASH (*dest) && !ISSLASH (dest[1]) && !prefix_len) -- dest++; -- } -- } -- else if (! (can_exist == CAN_MISSING -- || (suffix_requires_dir_check (end) -- ? dir_check (rname, dest) -- : !logical -- ? errno == EINVAL -- : *end || file_accessible (rname)) -- || (can_exist == CAN_ALL_BUT_LAST -- && errno == ENOENT -- && !end[strspn (end, SLASHES)]))) -- goto error; -- } -- } -- if (dest > rname + prefix_len + 1 && ISSLASH (dest[-1])) -- --dest; -- if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1 && !prefix_len -- && ISSLASH (*dest) && !ISSLASH (dest[1])) -- dest++; -- failed = false; -- --error: -- if (ht) -- hash_free (ht); -- -- if (failed) -- return NULL; -- -- *dest++ = '\0'; -- char *result = malloc (dest - rname); -- if (!result) -- xalloc_die (); -- return memcpy (result, rname, dest - rname); --} -- --/* Return the canonical absolute name of file NAME, while treating -- missing elements according to CAN_MODE. A canonical name -- does not contain any ".", ".." components nor any repeated file name -- separators ('/') or, depending on other CAN_MODE flags, symlinks. -- Whether components must exist or not depends on canonicalize mode. -- The result is malloc'd. */ -- --char * --canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) --{ -- struct realpath_bufs bufs; -- scratch_buffer_init (&bufs.rname); -- scratch_buffer_init (&bufs.extra); -- scratch_buffer_init (&bufs.link); -- char *result = canonicalize_filename_mode_stk (name, can_mode, &bufs); -- scratch_buffer_free (&bufs.link); -- scratch_buffer_free (&bufs.extra); -- scratch_buffer_free (&bufs.rname); -- return result; --} -+/* Return true if FILE's existence can be shown, false (setting errno) -+ otherwise. Follow symbolic links. */ -+static bool -+file_accessible (char const *file) -+{ -+# if HAVE_FACCESSAT -+ return faccessat (AT_FDCWD, file, F_OK, AT_EACCESS) == 0; -+# else -+ struct stat st; -+ return stat (file, &st) == 0 || errno == EOVERFLOW; -+# endif -+} -+ -+/* True if concatenating END as a suffix to a file name means that the -+ code needs to check that the file name is that of a searchable -+ directory, since the canonicalize_filename_mode_stk code won't -+ check this later anyway when it checks an ordinary file name -+ component within END. END must either be empty, or start with a -+ slash. */ -+ -+static bool _GL_ATTRIBUTE_PURE -+suffix_requires_dir_check (char const *end) -+{ -+ /* If END does not start with a slash, the suffix is OK. */ -+ while (ISSLASH (*end)) -+ { -+ /* Two or more slashes act like a single slash. */ -+ do -+ end++; -+ while (ISSLASH (*end)); -+ -+ switch (*end++) -+ { -+ default: return false; /* An ordinary file name component is OK. */ -+ case '\0': return true; /* Trailing "/" is trouble. */ -+ case '.': break; /* Possibly "." or "..". */ -+ } -+ /* Trailing "/.", or "/.." even if not trailing, is trouble. */ -+ if (!*end || (*end == '.' && (!end[1] || ISSLASH (end[1])))) -+ return true; -+ } -+ -+ return false; -+} -+ -+/* Append this to a file name to test whether it is a searchable directory. -+ On POSIX platforms "/" suffices, but "/./" is sometimes needed on -+ macOS 10.13 , and should also work on -+ platforms like AIX 7.2 that need at least "/.". */ -+ -+#ifdef LSTAT_FOLLOWS_SLASHED_SYMLINK -+static char const dir_suffix[] = "/"; -+#else -+static char const dir_suffix[] = "/./"; -+#endif -+ -+/* Return true if DIR is a searchable dir, false (setting errno) otherwise. -+ DIREND points to the NUL byte at the end of the DIR string. -+ Store garbage into DIREND[0 .. strlen (dir_suffix)]. */ -+ -+static bool -+dir_check (char *dir, char *dirend) -+{ -+ strcpy (dirend, dir_suffix); -+ return file_accessible (dir); -+} -+ -+#if !((HAVE_CANONICALIZE_FILE_NAME && FUNC_REALPATH_WORKS) \ -+ || GNULIB_CANONICALIZE_LGPL) -+/* Return the canonical absolute name of file NAME. A canonical name -+ does not contain any ".", ".." components nor any repeated file name -+ separators ('/') or symlinks. All components must exist. -+ The result is malloc'd. */ -+ -+char * -+canonicalize_file_name (const char *name) -+{ -+ return canonicalize_filename_mode (name, CAN_EXISTING); -+} -+#endif /* !HAVE_CANONICALIZE_FILE_NAME */ -+ -+static bool -+multiple_bits_set (canonicalize_mode_t i) -+{ -+ return (i & (i - 1)) != 0; -+} -+ -+/* Return true if we've already seen the triple, . -+ If *HT is not initialized, initialize it. */ -+static bool -+seen_triple (Hash_table **ht, char const *filename, struct stat const *st) -+{ -+ if (*ht == NULL) -+ { -+ idx_t initial_capacity = 7; -+ *ht = hash_initialize (initial_capacity, -+ NULL, -+ triple_hash, -+ triple_compare_ino_str, -+ triple_free); -+ if (*ht == NULL) -+ xalloc_die (); -+ } -+ -+ if (seen_file (*ht, filename, st)) -+ return true; -+ -+ record_file (*ht, filename, st); -+ return false; -+} -+ -+/* Scratch buffers used by canonicalize_filename_mode_stk and managed -+ by __realpath. */ -+struct realpath_bufs -+{ -+ struct scratch_buffer rname; -+ struct scratch_buffer extra; -+ struct scratch_buffer link; -+}; -+ -+static char * -+canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode, -+ struct realpath_bufs *bufs) -+{ -+ char *dest; -+ char const *start; -+ char const *end; -+ Hash_table *ht = NULL; -+ bool logical = (can_mode & CAN_NOLINKS) != 0; -+ int num_links = 0; -+ -+ canonicalize_mode_t can_exist = can_mode & CAN_MODE_MASK; -+ if (multiple_bits_set (can_exist)) -+ { -+ errno = EINVAL; -+ return NULL; -+ } -+ -+ if (name == NULL) -+ { -+ errno = EINVAL; -+ return NULL; -+ } -+ -+ if (name[0] == '\0') -+ { -+ errno = ENOENT; -+ return NULL; -+ } -+ -+ char *rname = bufs->rname.data; -+ bool end_in_extra_buffer = false; -+ bool failed = true; -+ -+ /* This is always zero for Posix hosts, but can be 2 for MS-Windows -+ and MS-DOS X:/foo/bar file names. */ -+ idx_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name); -+ -+ if (!IS_ABSOLUTE_FILE_NAME (name)) -+ { -+ while (!getcwd (bufs->rname.data, bufs->rname.length)) -+ { -+ switch (errno) -+ { -+ case ERANGE: -+ if (scratch_buffer_grow (&bufs->rname)) -+ break; -+ FALLTHROUGH; -+ case ENOMEM: -+ xalloc_die (); -+ -+ default: -+ dest = rname; -+ goto error; -+ } -+ rname = bufs->rname.data; -+ } -+ dest = rawmemchr (rname, '\0'); -+ start = name; -+ prefix_len = FILE_SYSTEM_PREFIX_LEN (rname); -+ } -+ else -+ { -+ dest = mempcpy (rname, name, prefix_len); + *dest++ = DIR_SEPARATOR; -+ if (DOUBLE_SLASH_IS_DISTINCT_ROOT) -+ { -+ if (prefix_len == 0 /* implies ISSLASH (name[0]) */ -+ && ISSLASH (name[1]) && !ISSLASH (name[2])) -+ { + if (DOUBLE_SLASH_IS_DISTINCT_ROOT) + { + if (prefix_len == 0 /* implies ISSLASH (name[0]) */ + && ISSLASH (name[1]) && !ISSLASH (name[2])) + { +- *dest++ = '/'; + *dest++ = DIR_SEPARATOR; -+#if defined _WIN32 && !defined __CYGWIN__ -+ /* For UNC file names '\\server\path\to\file', extend the prefix -+ to include the server: '\\server\'. */ -+ { -+ idx_t i; -+ for (i = 2; name[i] != '\0' && !ISSLASH (name[i]); ) -+ i++; -+ if (name[i] != '\0' /* implies ISSLASH (name[i]) */ -+ && i + 1 < bufs->rname.length) -+ { -+ prefix_len = i; -+ memcpy (dest, name + 2, i - 2 + 1); -+ dest += i - 2 + 1; -+ } -+ else -+ { -+ /* Either name = '\\server'; this is an invalid file name. -+ Or name = '\\server\...' and server is more than -+ bufs->rname.length - 4 bytes long. In either -+ case, stop the UNC processing. */ -+ } -+ } -+#endif -+ } -+ *dest = '\0'; -+ } -+ start = name + prefix_len; -+ } -+ -+ for ( ; *start; start = end) -+ { -+ /* Skip sequence of multiple file name separators. */ -+ while (ISSLASH (*start)) -+ ++start; -+ -+ /* Find end of component. */ -+ for (end = start; *end && !ISSLASH (*end); ++end) -+ /* Nothing. */; -+ -+ /* Length of this file name component; it can be zero if a file -+ name ends in '/'. */ -+ idx_t startlen = end - start; -+ -+ if (startlen == 0) -+ break; -+ else if (startlen == 1 && start[0] == '.') -+ /* nothing */; -+ else if (startlen == 2 && start[0] == '.' && start[1] == '.') -+ { -+ /* Back up to previous component, ignore if at root already. */ -+ if (dest > rname + prefix_len + 1) -+ for (--dest; dest > rname && !ISSLASH (dest[-1]); --dest) -+ continue; -+ if (DOUBLE_SLASH_IS_DISTINCT_ROOT -+ && dest == rname + 1 && !prefix_len -+ && ISSLASH (*dest) && !ISSLASH (dest[1])) -+ dest++; -+ } -+ else -+ { -+ if (!ISSLASH (dest[-1])) + #if defined _WIN32 && !defined __CYGWIN__ + /* For UNC file names '\\server\path\to\file', extend the prefix + to include the server: '\\server\'. */ +@@ -308,7 +303,7 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode, + else + { + if (!ISSLASH (dest[-1])) +- *dest++ = '/'; + *dest++ = DIR_SEPARATOR; -+ -+ while (rname + bufs->rname.length - dest -+ < startlen + sizeof dir_suffix) -+ { -+ idx_t dest_offset = dest - rname; -+ if (!scratch_buffer_grow_preserve (&bufs->rname)) -+ xalloc_die (); -+ rname = bufs->rname.data; -+ dest = rname + dest_offset; -+ } -+ -+ dest = mempcpy (dest, start, startlen); -+ *dest = '\0'; -+ -+ char *buf; -+ ssize_t n = -1; -+ if (!logical) -+ { -+ while (true) -+ { -+ buf = bufs->link.data; -+ idx_t bufsize = bufs->link.length; -+ n = readlink (rname, buf, bufsize - 1); -+ if (n < bufsize - 1) -+ break; -+ if (!scratch_buffer_grow (&bufs->link)) -+ xalloc_die (); -+ } -+ } -+ if (0 <= n) -+ { -+ /* A physical traversal and RNAME is a symbolic link. */ -+ -+ if (num_links < 20) -+ num_links++; -+ else if (*start) -+ { -+ /* Enough symlinks have been seen that it is time to -+ worry about being in a symlink cycle. -+ Get the device and inode of the parent directory, as -+ pre-2017 POSIX says this info is not reliable for -+ symlinks. */ -+ struct stat st; -+ dest[- startlen] = '\0'; -+ if (stat (*rname ? rname : ".", &st) != 0) -+ goto error; -+ dest[- startlen] = *start; -+ -+ /* Detect loops. We cannot use the cycle-check module here, -+ since it's possible to encounter the same parent -+ directory more than once in a given traversal. However, -+ encountering the same (parentdir, START) pair twice does -+ indicate a loop. */ -+ if (seen_triple (&ht, start, &st)) -+ { -+ if (can_exist == CAN_MISSING) -+ continue; -+ errno = ELOOP; -+ goto error; -+ } -+ } -+ -+ buf[n] = '\0'; -+ -+ char *extra_buf = bufs->extra.data; -+ idx_t end_idx; -+ if (end_in_extra_buffer) -+ end_idx = end - extra_buf; -+ size_t len = strlen (end); -+ if (INT_ADD_OVERFLOW (len, n)) -+ xalloc_die (); -+ while (bufs->extra.length <= len + n) -+ { -+ if (!scratch_buffer_grow_preserve (&bufs->extra)) -+ xalloc_die (); -+ extra_buf = bufs->extra.data; -+ } -+ if (end_in_extra_buffer) -+ end = extra_buf + end_idx; -+ -+ /* Careful here, end may be a pointer into extra_buf... */ -+ memmove (&extra_buf[n], end, len + 1); -+ name = end = memcpy (extra_buf, buf, n); -+ end_in_extra_buffer = true; -+ -+ if (IS_ABSOLUTE_FILE_NAME (buf)) -+ { -+ idx_t pfxlen = FILE_SYSTEM_PREFIX_LEN (buf); -+ -+ dest = mempcpy (rname, buf, pfxlen); + + while (rname + bufs->rname.length - dest + < startlen + sizeof dir_suffix) +@@ -399,11 +394,11 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode, + idx_t pfxlen = FILE_SYSTEM_PREFIX_LEN (buf); + + dest = mempcpy (rname, buf, pfxlen); +- *dest++ = '/'; /* It's an absolute symlink */ + *dest++ = DIR_SEPARATOR; /* It's an absolute symlink */ -+ if (DOUBLE_SLASH_IS_DISTINCT_ROOT) -+ { -+ if (ISSLASH (buf[1]) && !ISSLASH (buf[2]) && !pfxlen) + if (DOUBLE_SLASH_IS_DISTINCT_ROOT) + { + if (ISSLASH (buf[1]) && !ISSLASH (buf[2]) && !pfxlen) +- *dest++ = '/'; + *dest++ = DIR_SEPARATOR; -+ *dest = '\0'; -+ } -+ /* Install the new prefix to be in effect hereafter. */ -+ prefix_len = pfxlen; -+ } -+ else -+ { -+ /* Back up to previous component, ignore if at root -+ already: */ -+ if (dest > rname + prefix_len + 1) -+ for (--dest; dest > rname && !ISSLASH (dest[-1]); --dest) -+ continue; -+ if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1 -+ && ISSLASH (*dest) && !ISSLASH (dest[1]) && !prefix_len) -+ dest++; -+ } -+ } -+ else if (! (can_exist == CAN_MISSING -+ || (suffix_requires_dir_check (end) -+ ? dir_check (rname, dest) -+ : !logical -+ ? errno == EINVAL -+ : *end || file_accessible (rname)) -+ || (can_exist == CAN_ALL_BUT_LAST -+ && errno == ENOENT -+ && !end[strspn (end, SLASHES)]))) -+ goto error; -+ } -+ } -+ if (dest > rname + prefix_len + 1 && ISSLASH (dest[-1])) -+ --dest; -+ if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1 && !prefix_len -+ && ISSLASH (*dest) && !ISSLASH (dest[1])) -+ dest++; -+ failed = false; -+ -+error: -+ if (ht) -+ hash_free (ht); -+ -+ if (failed) -+ return NULL; -+ -+ *dest++ = '\0'; -+ char *result = malloc (dest - rname); -+ if (!result) -+ xalloc_die (); -+ return memcpy (result, rname, dest - rname); -+} -+ -+/* Return the canonical absolute name of file NAME, while treating -+ missing elements according to CAN_MODE. A canonical name -+ does not contain any ".", ".." components nor any repeated file name -+ separators ('/') or, depending on other CAN_MODE flags, symlinks. -+ Whether components must exist or not depends on canonicalize mode. -+ The result is malloc'd. */ -+ -+char * -+canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) -+{ -+ struct realpath_bufs bufs; -+ scratch_buffer_init (&bufs.rname); -+ scratch_buffer_init (&bufs.extra); -+ scratch_buffer_init (&bufs.link); -+ char *result = canonicalize_filename_mode_stk (name, can_mode, &bufs); -+ scratch_buffer_free (&bufs.link); -+ scratch_buffer_free (&bufs.extra); -+ scratch_buffer_free (&bufs.rname); -+ return result; -+} + *dest = '\0'; + } + /* Install the new prefix to be in effect hereafter. */ diff --git a/lib/chdir-long.c b/lib/chdir-long.c -index 8a25538b3f..eb32ff685c 100644 +index 6160025113..370a7adbcb 100644 --- a/lib/chdir-long.c +++ b/lib/chdir-long.c @@ -25,7 +25,7 @@ @@ -1086,7 +207,7 @@ index 8a25538b3f..eb32ff685c 100644 goto Fail; diff --git a/lib/chmod.c b/lib/chmod.c -index 40088c8a5b..50d3a9726c 100644 +index 827c7f9b26..a8255bd872 100644 --- a/lib/chmod.c +++ b/lib/chmod.c @@ -22,6 +22,7 @@ @@ -1107,7 +228,7 @@ index 40088c8a5b..50d3a9726c 100644 struct stat st; if (lstat (filename, &st) < 0) diff --git a/lib/chown.c b/lib/chown.c -index d735818afd..31c60e975f 100644 +index 398f8c1855..41db83dc04 100644 --- a/lib/chown.c +++ b/lib/chown.c @@ -27,6 +27,7 @@ @@ -1118,7 +239,7 @@ index d735818afd..31c60e975f 100644 #if !HAVE_CHOWN -@@ -122,7 +123,7 @@ rpl_chown (const char *file, uid_t uid, gid_t gid) +@@ -113,7 +114,7 @@ rpl_chown (const char *file, uid_t uid, gid_t gid) if (!stat_valid) { size_t len = strlen (file); @@ -1128,7 +249,7 @@ index d735818afd..31c60e975f 100644 } # endif diff --git a/lib/concat-filename.c b/lib/concat-filename.c -index 62842a69cb..4124b2ffd1 100644 +index b46ff1b520..1722a22291 100644 --- a/lib/concat-filename.c +++ b/lib/concat-filename.c @@ -64,7 +64,7 @@ concatenated_filename (const char *directory, const char *filename, @@ -1141,10 +262,10 @@ index 62842a69cb..4124b2ffd1 100644 p = stpcpy (p, filename); if (suffix != NULL) diff --git a/lib/creat.c b/lib/creat.c -index dad7b2da45..94a8823f96 100644 +index 81626f9164..6c7d8e1f2f 100644 --- a/lib/creat.c +++ b/lib/creat.c -@@ -43,6 +43,7 @@ orig_creat (const char *filename, mode_t mode) +@@ -47,6 +47,7 @@ orig_creat (const char *filename, mode_t mode) #include #include #include @@ -1152,7 +273,7 @@ index dad7b2da45..94a8823f96 100644 int creat (const char *filename, mode_t mode) -@@ -63,7 +64,7 @@ creat (const char *filename, mode_t mode) +@@ -67,7 +68,7 @@ creat (const char *filename, mode_t mode) creat() must fail since creat() cannot create directories. */ { size_t len = strlen (filename); @@ -1162,7 +283,7 @@ index dad7b2da45..94a8823f96 100644 errno = EISDIR; return -1; diff --git a/lib/dirname.h b/lib/dirname.h -index 0344f1c44c..65a2675ae9 100644 +index 33935ba937..aa203785e4 100644 --- a/lib/dirname.h +++ b/lib/dirname.h @@ -30,7 +30,7 @@ @@ -1175,10 +296,10 @@ index 0344f1c44c..65a2675ae9 100644 #ifdef __cplusplus diff --git a/lib/exclude.c b/lib/exclude.c -index 15f238e09c..4cf9d64fc1 100644 +index 81549fa8fc..51ce296f09 100644 --- a/lib/exclude.c +++ b/lib/exclude.c -@@ -338,7 +338,7 @@ fnmatch_no_wildcards (char const *pattern, char const *f, int options) +@@ -337,7 +337,7 @@ fnmatch_no_wildcards (char const *pattern, char const *f, int options) if (! r) { r = f[patlen]; @@ -1187,28 +308,28 @@ index 15f238e09c..4cf9d64fc1 100644 r = 0; } return r; -@@ -355,9 +355,9 @@ fnmatch_no_wildcards (char const *pattern, char const *f, int options) +@@ -353,9 +353,9 @@ fnmatch_no_wildcards (char const *pattern, char const *f, int options) + char *fcopy = xstrdup (f); - char *p; int r; -- for (p = fcopy; ; *p++ = '/') -+ for (p = fcopy; ; *p++ = DIR_SEPARATOR) +- for (char *p = fcopy; ; *p++ = '/') ++ for (char *p = fcopy; ; *p++ = DIR_SEPARATOR) { - p = strchr (p, '/'); + p = strpbrk(p, SLASHES); if (p) *p = '\0'; r = mbscasecmp (pattern, fcopy); -@@ -381,7 +381,7 @@ exclude_fnmatch (char const *pattern, char const *f, int options) +@@ -378,7 +378,7 @@ exclude_fnmatch (char const *pattern, char const *f, int options) if (! (options & EXCLUDE_ANCHORED)) - for (p = f; *p && ! matched; p++) + for (char const *p = f; *p && ! matched; p++) - if (*p == '/' && p[1] != '/') + if ( ISSLASH(*p) && ! ISSLASH(p[1])) - matched = ((*matcher) (pattern, p + 1, options) == 0); + matched = matcher (pattern, p + 1, options) == 0; return matched; -@@ -434,7 +434,7 @@ file_name_matches (struct exclude_segment const *seg, char const *f, +@@ -429,7 +429,7 @@ file_name_matches (struct exclude_segment const *seg, char const *f, return true; if (options & FNM_LEADING_DIR) { @@ -1216,8 +337,8 @@ index 15f238e09c..4cf9d64fc1 100644 + char *p = LAST_SLASH_IN_PATH(buffer); if (p) { - *p = 0; -@@ -446,7 +446,7 @@ file_name_matches (struct exclude_segment const *seg, char const *f, + *p = '\0'; +@@ -441,7 +441,7 @@ file_name_matches (struct exclude_segment const *seg, char const *f, if (!(options & EXCLUDE_ANCHORED)) { @@ -1227,7 +348,7 @@ index 15f238e09c..4cf9d64fc1 100644 f++; } diff --git a/lib/faccessat.c b/lib/faccessat.c -index ac8977cfd6..1dbda1b178 100644 +index 6eed1b642a..98d4639986 100644 --- a/lib/faccessat.c +++ b/lib/faccessat.c @@ -30,6 +30,8 @@ @@ -1239,17 +360,26 @@ index ac8977cfd6..1dbda1b178 100644 #undef _GL_INCLUDING_UNISTD_H #if HAVE_FACCESSAT -@@ -59,7 +61,7 @@ rpl_faccessat (int fd, char const *file, int mode, int flag) +@@ -44,7 +46,7 @@ orig_faccessat (int fd, char const *name, int mode, int flag) + /* Write "unistd.h" here, not , otherwise OSF/1 5.1 DTK cc + eliminates this include because of the preliminary #include + above. */ +-# include "unistd.h" ++#include "unistd.h" + #else + # include + #endif +@@ -63,7 +65,7 @@ rpl_faccessat (int fd, char const *file, int mode, int flag) { int result = orig_faccessat (fd, file, mode, flag); -- if (result == 0 && file[strlen (file) - 1] == '/') -+ if (result == 0 && ISSLASH(file[strlen (file) - 1]) ) +- if (file[strlen (file) - 1] == '/') ++ if ( ISSLASH(file[strlen (file) - 1]) ) { struct stat st; - result = fstatat (fd, file, &st, 0); + int ret = fstatat (fd, file, &st, 0); diff --git a/lib/fchownat.c b/lib/fchownat.c -index c8a016088f..72438b53cf 100644 +index 61902d1d98..f49db5ee3e 100644 --- a/lib/fchownat.c +++ b/lib/fchownat.c @@ -31,6 +31,7 @@ @@ -1270,7 +400,7 @@ index c8a016088f..72438b53cf 100644 if (fstatat (fd, file, &st, 0)) return -1; diff --git a/lib/filename.h b/lib/filename.h -index a2400a9dfe..97cab128a3 100644 +index 4f0f0fbc3c..07b2214673 100644 --- a/lib/filename.h +++ b/lib/filename.h @@ -57,8 +57,12 @@ extern "C" { @@ -1327,7 +457,7 @@ index a2400a9dfe..97cab128a3 100644 /* Deprecated macros. For backward compatibility with old users of the diff --git a/lib/filenamecat-lgpl.c b/lib/filenamecat-lgpl.c -index 6d7ed8481d..3936a7f4ed 100644 +index dc6d3468c8..197c1e0eaf 100644 --- a/lib/filenamecat-lgpl.c +++ b/lib/filenamecat-lgpl.c @@ -56,7 +56,7 @@ mfile_name_concat (char const *dir, char const *base, char **base_in_result) @@ -1340,7 +470,7 @@ index 6d7ed8481d..3936a7f4ed 100644 else if (ISSLASH (*base)) { diff --git a/lib/findprog-in.c b/lib/findprog-in.c -index c0768c29e2..69b95dac62 100644 +index 5c71c309ee..ae359876e8 100644 --- a/lib/findprog-in.c +++ b/lib/findprog-in.c @@ -30,13 +30,7 @@ @@ -1359,7 +489,7 @@ index c0768c29e2..69b95dac62 100644 /* Separator in PATH like lists of pathnames. */ #if (defined _WIN32 && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__ diff --git a/lib/fnmatch_loop.c b/lib/fnmatch_loop.c -index 42e84b80cf..e76b4f8710 100644 +index 4e6e0865e9..aadaead8b2 100644 --- a/lib/fnmatch_loop.c +++ b/lib/fnmatch_loop.c @@ -18,6 +18,7 @@ @@ -1470,7 +600,7 @@ index 42e84b80cf..e76b4f8710 100644 NULL, alloca_used) == 0)) /* This is successful. */ diff --git a/lib/fopen.c b/lib/fopen.c -index e1e4cdbd23..4f5a7f35f9 100644 +index d3b57a987a..946fc91836 100644 --- a/lib/fopen.c +++ b/lib/fopen.c @@ -24,6 +24,7 @@ @@ -1481,7 +611,7 @@ index e1e4cdbd23..4f5a7f35f9 100644 #undef _GL_ALREADY_INCLUDING_STDIO_H static FILE * -@@ -163,7 +164,7 @@ rpl_fopen (const char *filename, const char *mode) +@@ -167,7 +168,7 @@ rpl_fopen (const char *filename, const char *mode) fopen() must fail since the file does not contain a '.' directory. */ { size_t len = strlen (filename); @@ -1491,7 +621,7 @@ index e1e4cdbd23..4f5a7f35f9 100644 int fd; struct stat statbuf; diff --git a/lib/fstatat.c b/lib/fstatat.c -index 372965ef5f..d5d11accac 100644 +index 470ef336cf..2381040128 100644 --- a/lib/fstatat.c +++ b/lib/fstatat.c @@ -26,6 +26,7 @@ @@ -1521,7 +651,7 @@ index 372965ef5f..d5d11accac 100644 errno = ENOTDIR; return -1; diff --git a/lib/fts.c b/lib/fts.c -index faeb4b20a5..526be1600f 100644 +index 92306bc72f..324464c6c2 100644 --- a/lib/fts.c +++ b/lib/fts.c @@ -67,7 +67,7 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; @@ -1590,7 +720,7 @@ index faeb4b20a5..526be1600f 100644 /* GCC, you're too verbose. */ cp = NULL; diff --git a/lib/getcwd.c b/lib/getcwd.c -index 28f69133a8..8e381d18af 100644 +index 214950a144..29e30eeefd 100644 --- a/lib/getcwd.c +++ b/lib/getcwd.c @@ -30,7 +30,7 @@ @@ -1639,10 +769,10 @@ index 28f69133a8..8e381d18af 100644 #if ! HAVE_OPENAT_SUPPORT if (dotlist != dots) diff --git a/lib/glob.c b/lib/glob.c -index af0694eec4..c6bdb5940a 100644 +index dc1a915c05..c9c001dd8f 100644 --- a/lib/glob.c +++ b/lib/glob.c -@@ -49,6 +49,7 @@ +@@ -50,6 +50,7 @@ #include #include #include @@ -1650,7 +780,7 @@ index af0694eec4..c6bdb5940a 100644 #ifdef _LIBC # undef strdup -@@ -322,7 +323,7 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), +@@ -308,7 +309,7 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), /* POSIX requires all slashes to be matched. This means that with a trailing slash we must match only directories. */ @@ -1659,7 +789,7 @@ index af0694eec4..c6bdb5940a 100644 flags |= GLOB_ONLYDIR; if (!(flags & GLOB_DOOFFS)) -@@ -486,7 +487,7 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), +@@ -472,7 +473,7 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), oldcount = pglob->gl_pathc + pglob->gl_offs; /* Find the filename. */ @@ -1668,7 +798,7 @@ index af0694eec4..c6bdb5940a 100644 #if defined __MSDOS__ || defined WINDOWS32 /* The case of "d:pattern". Since ':' is not allowed in -@@ -574,7 +575,7 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), +@@ -560,7 +561,7 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), bool drive_root = (dirlen > 1 && (dirname[dirlen - 1] == ':' || (dirlen > 2 && dirname[dirlen - 2] == ':' @@ -1677,7 +807,7 @@ index af0694eec4..c6bdb5940a 100644 #else bool drive_root = false; #endif -@@ -583,7 +584,7 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), +@@ -569,7 +570,7 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), /* "pattern/". Expand "pattern", appending slashes. */ { int orig_flags = flags; @@ -1686,7 +816,7 @@ index af0694eec4..c6bdb5940a 100644 { /* "pattern\\/". Remove the final backslash if it hasn't been quoted. */ -@@ -615,9 +616,9 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), +@@ -601,9 +602,9 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~') { @@ -1699,7 +829,7 @@ index af0694eec4..c6bdb5940a 100644 { /* Look up home directory. */ char *home_dir = getenv ("HOME"); -@@ -750,7 +751,7 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), +@@ -736,7 +737,7 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), #ifndef WINDOWS32 /* Recognize ~user as a shorthand for the specified user's home directory. */ @@ -1708,7 +838,7 @@ index af0694eec4..c6bdb5940a 100644 char *user_name; int malloc_user_name = 0; char *unescape = NULL; -@@ -937,7 +938,7 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), +@@ -923,7 +924,7 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), if (pglob->gl_pathv[newcount] == NULL) goto nospace; p = mempcpy (pglob->gl_pathv[newcount], dirname, dirlen); @@ -1717,7 +847,7 @@ index af0694eec4..c6bdb5940a 100644 p[1] = '\0'; if (__glibc_unlikely (malloc_dirname)) free (dirname); -@@ -1228,9 +1229,9 @@ prefix_array (const char *dirname, char **array, size_t n) +@@ -1214,9 +1215,9 @@ prefix_array (const char *dirname, char **array, size_t n) { size_t i; size_t dirlen = strlen (dirname); @@ -1729,7 +859,7 @@ index af0694eec4..c6bdb5940a 100644 /* DIRNAME is just "/", so normal prepending would get us "//foo". We want "/foo" instead, so don't prepend any chars from DIRNAME. */ dirlen = 0; -@@ -1238,7 +1239,7 @@ prefix_array (const char *dirname, char **array, size_t n) +@@ -1224,7 +1225,7 @@ prefix_array (const char *dirname, char **array, size_t n) #if defined __MSDOS__ || defined WINDOWS32 if (dirlen > 1) { @@ -1738,7 +868,7 @@ index af0694eec4..c6bdb5940a 100644 /* DIRNAME is "d:/". Don't prepend the slash from DIRNAME. */ --dirlen; else if (dirname[dirlen - 1] == ':') -@@ -1399,8 +1400,8 @@ glob_in_dir (const char *pattern, const char *directory, int flags, +@@ -1385,8 +1386,8 @@ glob_in_dir (const char *pattern, const char *directory, int flags, && !scratch_buffer_set_array_size (&s, need, 1)) goto memory_error; char *p = mempcpy (s.data, directory, dirlen); @@ -1750,7 +880,7 @@ index af0694eec4..c6bdb5940a 100644 if (! is_dir (s.data, flags, pglob)) continue; diff --git a/lib/lchmod.c b/lib/lchmod.c -index b2d1b8bfde..b2baf00db2 100644 +index 8056f0b197..093c04372d 100644 --- a/lib/lchmod.c +++ b/lib/lchmod.c @@ -29,6 +29,7 @@ @@ -1771,7 +901,7 @@ index b2d1b8bfde..b2baf00db2 100644 struct stat st; if (lstat (file, &st) < 0) diff --git a/lib/lchown.c b/lib/lchown.c -index 19a68c052b..2d5e3f3f13 100644 +index 03836bcb3b..49fca6cb4c 100644 --- a/lib/lchown.c +++ b/lib/lchown.c @@ -25,6 +25,7 @@ @@ -1792,7 +922,7 @@ index 19a68c052b..2d5e3f3f13 100644 } # endif diff --git a/lib/link.c b/lib/link.c -index 2c81e2f2e3..3aacd91d00 100644 +index 97aa6d52c2..feb514a911 100644 --- a/lib/link.c +++ b/lib/link.c @@ -23,6 +23,7 @@ @@ -1844,7 +974,7 @@ index 2c81e2f2e3..3aacd91d00 100644 { *p = '\0'; diff --git a/lib/linkat.c b/lib/linkat.c -index 3d1ee3962f..ec3f3a483c 100644 +index 7ce1f81feb..6651e5aac5 100644 --- a/lib/linkat.c +++ b/lib/linkat.c @@ -32,6 +32,7 @@ @@ -1867,7 +997,7 @@ index 3d1ee3962f..ec3f3a483c 100644 /* Let linkat() decide whether hard-linking directories is legal. If fstatat() fails, then linkat() should fail for the same reason; diff --git a/lib/lstat.c b/lib/lstat.c -index 00a4ce2ab8..20747ea6f7 100644 +index 7c09957e20..3d3b532953 100644 --- a/lib/lstat.c +++ b/lib/lstat.c @@ -22,7 +22,7 @@ @@ -1889,7 +1019,7 @@ index 00a4ce2ab8..20747ea6f7 100644 else { diff --git a/lib/mkfifo.c b/lib/mkfifo.c -index 5ad81030e8..18b5eb3e05 100644 +index 5fc089646c..06c119a487 100644 --- a/lib/mkfifo.c +++ b/lib/mkfifo.c @@ -22,6 +22,7 @@ @@ -1910,7 +1040,7 @@ index 5ad81030e8..18b5eb3e05 100644 struct stat st; if (stat (name, &st) == 0 || errno == EOVERFLOW) diff --git a/lib/mkfifoat.c b/lib/mkfifoat.c -index 23243e8cf8..fbd1e78654 100644 +index 7bb031babb..de0b64a434 100644 --- a/lib/mkfifoat.c +++ b/lib/mkfifoat.c @@ -22,6 +22,7 @@ @@ -1931,7 +1061,7 @@ index 23243e8cf8..fbd1e78654 100644 struct stat st; diff --git a/lib/mknodat.c b/lib/mknodat.c -index 3ed38e159c..1d28dc29a7 100644 +index a31450abab..d99521eb21 100644 --- a/lib/mknodat.c +++ b/lib/mknodat.c @@ -22,6 +22,7 @@ @@ -1952,7 +1082,7 @@ index 3ed38e159c..1d28dc29a7 100644 struct stat st; diff --git a/lib/mountlist.c b/lib/mountlist.c -index 8b06e7b7ee..b7b2ba96fc 100644 +index 06300d6b73..c8ad9bd11f 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -30,7 +30,7 @@ @@ -1974,7 +1104,7 @@ index 8b06e7b7ee..b7b2ba96fc 100644 } diff --git a/lib/open.c b/lib/open.c -index 7ec8fdc35d..092e0cd1a4 100644 +index e690c9ea77..ffc8600b46 100644 --- a/lib/open.c +++ b/lib/open.c @@ -21,7 +21,7 @@ @@ -2012,7 +1142,7 @@ index 7ec8fdc35d..092e0cd1a4 100644 } /* Specification. */ -@@ -119,7 +131,7 @@ open (const char *filename, int flags, ...) +@@ -123,7 +135,7 @@ open (const char *filename, int flags, ...) || (flags & O_ACCMODE) == O_WRONLY) { size_t len = strlen (filename); @@ -2021,7 +1151,7 @@ index 7ec8fdc35d..092e0cd1a4 100644 { errno = EISDIR; return -1; -@@ -186,7 +198,7 @@ open (const char *filename, int flags, ...) +@@ -190,7 +202,7 @@ open (const char *filename, int flags, ...) { /* We know len is positive, since open did not fail with ENOENT. */ size_t len = strlen (filename); @@ -2031,7 +1161,7 @@ index 7ec8fdc35d..092e0cd1a4 100644 struct stat statbuf; diff --git a/lib/openat-proc.c b/lib/openat-proc.c -index 88f70be4f5..3c543def02 100644 +index 7ccb734f42..278c8898ee 100644 --- a/lib/openat-proc.c +++ b/lib/openat-proc.c @@ -38,6 +38,7 @@ @@ -2052,10 +1182,10 @@ index 88f70be4f5..3c543def02 100644 #endif diff --git a/lib/openat.c b/lib/openat.c -index f28b10e138..b62e1c9c6c 100644 +index 609b03d627..ad9954d778 100644 --- a/lib/openat.c +++ b/lib/openat.c -@@ -104,7 +104,7 @@ rpl_openat (int dfd, char const *filename, int flags, ...) +@@ -99,7 +99,7 @@ rpl_openat (int dfd, char const *filename, int flags, ...) || (flags & O_ACCMODE) == O_WRONLY) { size_t len = strlen (filename); @@ -2064,7 +1194,7 @@ index f28b10e138..b62e1c9c6c 100644 { errno = EISDIR; return -1; -@@ -147,7 +147,7 @@ rpl_openat (int dfd, char const *filename, int flags, ...) +@@ -149,7 +149,7 @@ rpl_openat (int dfd, char const *filename, int flags, ...) { /* We know len is positive, since open did not fail with ENOENT. */ size_t len = strlen (filename); @@ -2074,7 +1204,7 @@ index f28b10e138..b62e1c9c6c 100644 struct stat statbuf; diff --git a/lib/progname.c b/lib/progname.c -index ed928e04e9..4ada400f56 100644 +index db17f5b208..e6a441a204 100644 --- a/lib/progname.c +++ b/lib/progname.c @@ -21,7 +21,7 @@ @@ -2096,7 +1226,7 @@ index ed928e04e9..4ada400f56 100644 if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0) { diff --git a/lib/progreloc.c b/lib/progreloc.c -index 30b1f759b6..b89413c7b1 100644 +index 9f49ed16ff..875edef9ea 100644 --- a/lib/progreloc.c +++ b/lib/progreloc.c @@ -50,6 +50,7 @@ @@ -2161,7 +1291,7 @@ index 30b1f759b6..b89413c7b1 100644 } if (maybe_executable (concat_name)) diff --git a/lib/readlinkat.c b/lib/readlinkat.c -index 7738ba8bfd..58bc4ddfcf 100644 +index f4d64c0d13..f7816c02a5 100644 --- a/lib/readlinkat.c +++ b/lib/readlinkat.c @@ -20,7 +20,7 @@ @@ -2183,7 +1313,7 @@ index 7738ba8bfd..58bc4ddfcf 100644 /* Even if FILE without the slash is a symlink to a directory, both lstat() and stat() must resolve the trailing slash to diff --git a/lib/relocatable.c b/lib/relocatable.c -index ac12c6da39..0ab43497be 100644 +index 365c085825..a2ce7ceae9 100644 --- a/lib/relocatable.c +++ b/lib/relocatable.c @@ -25,7 +25,7 @@ @@ -2233,7 +1363,7 @@ index ac12c6da39..0ab43497be 100644 size_t size; int len; diff --git a/lib/rename.c b/lib/rename.c -index aa3afd8768..4f2ddd6854 100644 +index b6c93db474..eb8cc6fe25 100644 --- a/lib/rename.c +++ b/lib/rename.c @@ -320,8 +320,8 @@ rpl_rename (char const *src, char const *dst) @@ -2257,10 +1387,10 @@ index aa3afd8768..4f2ddd6854 100644 rename_errno = EINVAL; goto out; diff --git a/lib/renameatu.c b/lib/renameatu.c -index 939e58965f..400c673309 100644 +index 437fc8f71a..533c7e0e59 100644 --- a/lib/renameatu.c +++ b/lib/renameatu.c -@@ -155,8 +155,8 @@ renameatu (int fd1, char const *src, int fd2, char const *dst, +@@ -163,8 +163,8 @@ renameatu (int fd1, char const *src, int fd2, char const *dst, if (!src_len || !dst_len) return renameat2ish (fd1, src, fd2, dst, flags); @@ -2272,7 +1402,7 @@ index 939e58965f..400c673309 100644 return renameat2ish (fd1, src, fd2, dst, flags); diff --git a/lib/spawni.c b/lib/spawni.c -index 84d1fb27f6..a79311384f 100644 +index 211394bb9f..dae8502070 100644 --- a/lib/spawni.c +++ b/lib/spawni.c @@ -1028,7 +1028,7 @@ __spawni (pid_t *pid, const char *file, @@ -2294,7 +1424,7 @@ index 84d1fb27f6..a79311384f 100644 p = path; do diff --git a/lib/symlink.c b/lib/symlink.c -index b5009ae835..1ebaeafaa8 100644 +index 6ba83666e1..3ab4bd431b 100644 --- a/lib/symlink.c +++ b/lib/symlink.c @@ -19,6 +19,7 @@ @@ -2315,7 +1445,7 @@ index b5009ae835..1ebaeafaa8 100644 struct stat st; if (lstat (name, &st) == 0 || errno == EOVERFLOW) diff --git a/lib/symlinkat.c b/lib/symlinkat.c -index 11eda8289a..1aface185f 100644 +index 920001a6fa..2c101271fc 100644 --- a/lib/symlinkat.c +++ b/lib/symlinkat.c @@ -26,7 +26,7 @@ @@ -2337,7 +1467,7 @@ index 11eda8289a..1aface185f 100644 struct stat st; if (fstatat (fd, name, &st, AT_SYMLINK_NOFOLLOW) == 0 diff --git a/lib/tmpdir.c b/lib/tmpdir.c -index 9c96a6972c..fe1d5a57b5 100644 +index dd43fe22c1..7e740c99a2 100644 --- a/lib/tmpdir.c +++ b/lib/tmpdir.c @@ -21,7 +21,7 @@ diff --git a/patches/patches_GNULIB_WIN_FSUSAGE_FIXES.patch b/patches/patches_GNULIB_WIN_FSUSAGE_FIXES.patch index d00cd3e..bde5d50 100644 --- a/patches/patches_GNULIB_WIN_FSUSAGE_FIXES.patch +++ b/patches/patches_GNULIB_WIN_FSUSAGE_FIXES.patch @@ -1,5 +1,5 @@ diff --git a/lib/fsusage.c b/lib/fsusage.c -index f6f4b1c35f..d30dd3f9fb 100644 +index 97d0eef7aa..cd7a7da4c9 100644 --- a/lib/fsusage.c +++ b/lib/fsusage.c @@ -22,8 +22,7 @@ @@ -105,13 +105,13 @@ index f6f4b1c35f..d30dd3f9fb 100644 return 0; } diff --git a/lib/fsusage.h b/lib/fsusage.h -index 9630b04e00..24cddb7e76 100644 +index da87859060..080c8642ac 100644 --- a/lib/fsusage.h +++ b/lib/fsusage.h @@ -22,6 +22,17 @@ - # define FSUSAGE_H_ + #define FSUSAGE_H_ - # include + #include +# include +#ifdef _WIN32 +# include @@ -124,9 +124,9 @@ index 9630b04e00..24cddb7e76 100644 +# endif +#endif - struct fs_usage - { -@@ -32,8 +43,14 @@ struct fs_usage + #ifdef __cplusplus + extern "C" { +@@ -37,6 +48,13 @@ struct fs_usage bool fsu_bavail_top_bit_set; /* 1 if fsu_bavail represents a value < 0. */ uintmax_t fsu_files; /* Total file nodes. */ uintmax_t fsu_ffree; /* Free file nodes. */ @@ -138,12 +138,10 @@ index 9630b04e00..24cddb7e76 100644 + fsword fsu_fs_type; +#endif }; -- - int get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp); - #endif + int get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp); diff --git a/lib/mountlist.c b/lib/mountlist.c -index 8b06e7b7ee..f7272bbdd7 100644 +index 06300d6b73..db8b79f307 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -187,6 +187,10 @@ diff --git a/patches/repo_coreutils.patch b/patches/repo_coreutils.patch index 0a0a1e7..2974ac6 100644 --- a/patches/repo_coreutils.patch +++ b/patches/repo_coreutils.patch @@ -462,7 +462,7 @@ index 31a48f114..28e62a905 100644 + const char* const values[] = {strip_program,name, NULL}; + + -+ status = execute(strip_program,strip_program,values, NULL, false, false,false,false, true, false, NULL); ++ status = execute(strip_program,strip_program,values, NULL, NULL, false, false,false,false, true, false, NULL); + if (! WIFEXITED (status) || WEXITSTATUS (status)) + error (0, 0, _("strip process terminated abnormally")); + else diff --git a/patches/repo_findutils.patch b/patches/repo_findutils.patch index e7fd474..a90e942 100644 --- a/patches/repo_findutils.patch +++ b/patches/repo_findutils.patch @@ -1,8 +1,8 @@ diff --git a/find/exec.c b/find/exec.c -index c9cda8af..822532b3 100644 +index 1f6bc83d..7a1a2073 100644 --- a/find/exec.c +++ b/find/exec.c -@@ -309,10 +309,49 @@ launch (struct buildcmd_control *ctl, void *usercontext, int argc, char **argv) +@@ -307,10 +307,49 @@ launch (struct buildcmd_control *ctl, void *usercontext, int argc, char **argv) if (first_time) { first_time = 0; @@ -10,8 +10,6 @@ index c9cda8af..822532b3 100644 signal (SIGCHLD, SIG_DFL); +#endif } -- -- child_pid = fork (); +#ifdef _WIN32 + if (bc_args_exceed_testing_limit (argv)) + errno = E2BIG; @@ -23,7 +21,7 @@ index c9cda8af..822532b3 100644 + { + complain_about_leaky_fds (); + } -+ errno = execute(argv[0],argv[0],argv,NULL,false,false,false,false,true,false,NULL); ++ errno = execute(argv[0],argv[0],argv,NULL,NULL,false,false,false,false,true,false,NULL); + dup2(fd_stdin,STDIN_FILENO);//restore stdin + close(fd_stdin); + } @@ -46,19 +44,20 @@ index c9cda8af..822532b3 100644 + } + }else + return 1; /* OK */ -+ + +- child_pid = fork (); + +#else + child_pid= fork (); +#endif if (child_pid == -1) - die (EXIT_FAILURE, errno, _("cannot fork")); + error (EXIT_FAILURE, errno, _("cannot fork")); if (child_pid == 0) diff --git a/find/fstype.c b/find/fstype.c -index 47f1ff71..5fcf626a 100644 +index a7ca25df..42cbe5ed 100644 --- a/find/fstype.c +++ b/find/fstype.c -@@ -113,6 +113,7 @@ in_afs (char *path) +@@ -109,6 +109,7 @@ in_afs (char *path) static struct mount_entry * get_file_system_list (bool need_fs_type) { @@ -66,7 +65,7 @@ index 47f1ff71..5fcf626a 100644 /* Local cache for the mount list. */ static struct mount_entry *mount_list = NULL; -@@ -130,6 +131,9 @@ get_file_system_list (bool need_fs_type) +@@ -126,6 +127,9 @@ get_file_system_list (bool need_fs_type) has_fstype = need_fs_type; } return mount_list; @@ -76,7 +75,7 @@ index 47f1ff71..5fcf626a 100644 } /* Return a static string naming the type of file system that the file PATH, -@@ -160,6 +164,7 @@ filesystem_type (const struct stat *statp, const char *path) +@@ -156,6 +160,7 @@ filesystem_type (const struct stat *statp, const char *path) bool is_used_fs_type(const char *name) { @@ -84,15 +83,15 @@ index 47f1ff71..5fcf626a 100644 if (0 == strcmp("afs", name)) { /* I guess AFS may not appear in /etc/mtab (or equivalent) but still be in use, -@@ -183,6 +188,7 @@ is_used_fs_type(const char *name) - return true; - } +@@ -179,6 +184,7 @@ is_used_fs_type(const char *name) + return true; + } } +#endif return false; } -@@ -274,6 +280,7 @@ file_system_type_uncached (const struct stat *statp, const char *path, +@@ -270,6 +276,7 @@ file_system_type_uncached (const struct stat *statp, const char *path, dev_t * get_mounted_devices (size_t *n) { @@ -100,7 +99,7 @@ index 47f1ff71..5fcf626a 100644 size_t alloc_size = 0u; size_t used = 0u; struct mount_entry *entries, *entry; -@@ -311,4 +318,7 @@ get_mounted_devices (size_t *n) +@@ -307,4 +314,7 @@ get_mounted_devices (size_t *n) *n = used; } return result; @@ -109,7 +108,7 @@ index 47f1ff71..5fcf626a 100644 +#endif } diff --git a/find/parser.c b/find/parser.c -index 78c3f969..e8eb8226 100644 +index 1b389b3c..76ec600d 100644 --- a/find/parser.c +++ b/find/parser.c @@ -23,9 +23,12 @@ @@ -126,15 +125,15 @@ index 78c3f969..e8eb8226 100644 #include #include #include -@@ -1134,6 +1137,7 @@ parse_gid (const struct parser_table* entry, char **argv, int *arg_ptr) +@@ -1139,6 +1142,7 @@ parse_gid (const struct parser_table* entry, char **argv, int *arg_ptr) static bool parse_group (const struct parser_table* entry, char **argv, int *arg_ptr) { + #ifndef _WIN32 const char *groupname; - const int saved_argc = *arg_ptr; -@@ -1193,6 +1197,9 @@ parse_group (const struct parser_table* entry, char **argv, int *arg_ptr) + if (collect_arg (argv, arg_ptr, &groupname)) +@@ -1170,6 +1174,9 @@ parse_group (const struct parser_table* entry, char **argv, int *arg_ptr) return true; } return false; @@ -144,7 +143,7 @@ index 78c3f969..e8eb8226 100644 } static bool -@@ -2442,6 +2449,7 @@ parse_used (const struct parser_table* entry, char **argv, int *arg_ptr) +@@ -2380,6 +2387,7 @@ parse_used (const struct parser_table* entry, char **argv, int *arg_ptr) static bool parse_user (const struct parser_table* entry, char **argv, int *arg_ptr) { @@ -152,7 +151,7 @@ index 78c3f969..e8eb8226 100644 const char *username; if (collect_arg (argv, arg_ptr, &username)) -@@ -2488,6 +2496,9 @@ parse_user (const struct parser_table* entry, char **argv, int *arg_ptr) +@@ -2411,6 +2419,9 @@ parse_user (const struct parser_table* entry, char **argv, int *arg_ptr) return true; } return false; @@ -163,7 +162,7 @@ index 78c3f969..e8eb8226 100644 static bool diff --git a/find/pred.c b/find/pred.c -index b5a642b4..ce02c54f 100644 +index 6c792423..1cff7c6c 100644 --- a/find/pred.c +++ b/find/pred.c @@ -24,9 +24,14 @@ @@ -182,7 +181,7 @@ index b5a642b4..ce02c54f 100644 #include #include #include -@@ -671,17 +676,25 @@ pred_newerXY (const char *pathname, struct stat *stat_buf, struct predicate *pre +@@ -669,17 +674,25 @@ pred_newerXY (const char *pathname, struct stat *stat_buf, struct predicate *pre bool pred_nogroup (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr) { @@ -209,7 +208,7 @@ index b5a642b4..ce02c54f 100644 diff --git a/find/print.c b/find/print.c -index b04bfef8..108c5010 100644 +index 465e9ec6..8c92e028 100644 --- a/find/print.c +++ b/find/print.c @@ -22,9 +22,12 @@ @@ -226,7 +225,7 @@ index b04bfef8..108c5010 100644 #include #include #include -@@ -933,6 +936,7 @@ do_fprintf (struct format_val *dest, +@@ -931,6 +934,7 @@ do_fprintf (struct format_val *dest, checked_print_quoted (dest, segment->text, filesystem_type (stat_buf, pathname)); break; case 'g': /* group name */ @@ -234,7 +233,7 @@ index b04bfef8..108c5010 100644 /* trusted */ /* (well, the actual group is selected by the user but * its name was selected by the system administrator) -@@ -949,13 +953,16 @@ do_fprintf (struct format_val *dest, +@@ -947,13 +951,16 @@ do_fprintf (struct format_val *dest, } } FALLTHROUGH; /*...sometimes, so 'G' case.*/ @@ -252,7 +251,7 @@ index b04bfef8..108c5010 100644 case 'h': /* leading directories part of path */ /* sanitised */ { -@@ -1141,6 +1148,7 @@ do_fprintf (struct format_val *dest, +@@ -1139,6 +1146,7 @@ do_fprintf (struct format_val *dest, break; case 'u': /* user name */ @@ -260,7 +259,7 @@ index b04bfef8..108c5010 100644 /* trusted */ /* (well, the actual user is selected by the user on systems * where chown is not restricted, but the user name was -@@ -1158,12 +1166,14 @@ do_fprintf (struct format_val *dest, +@@ -1156,12 +1164,14 @@ do_fprintf (struct format_val *dest, } } FALLTHROUGH; /* .. to case U */ @@ -277,10 +276,10 @@ index b04bfef8..108c5010 100644 /* %Y: type of file system entry like `ls -l`: diff --git a/find/util.c b/find/util.c -index e2a2c244..ff81e577 100644 +index a1736807..936772ca 100644 --- a/find/util.c +++ b/find/util.c -@@ -198,8 +198,8 @@ Tests (N can be +N or -N or N):\n\ +@@ -196,8 +196,8 @@ Tests (N can be +N or -N or N):\n\ Actions:\n\ -delete -print0 -printf FORMAT -fprintf FILE FORMAT -print \n\ -fprint0 FILE -fprint FILE -ls -fls FILE -prune -quit\n\ @@ -292,7 +291,7 @@ index e2a2c244..ff81e577 100644 HTL (_("\n\ Other common options:\n")); diff --git a/lib/buildcmd.c b/lib/buildcmd.c -index 9412b230..8e337087 100644 +index b648c2bf..66791084 100644 --- a/lib/buildcmd.c +++ b/lib/buildcmd.c @@ -24,8 +24,13 @@ @@ -311,7 +310,7 @@ index 9412b230..8e337087 100644 #include #include diff --git a/lib/fdleak.c b/lib/fdleak.c -index 87ece559..93b680b6 100644 +index f79b3424..fcba379f 100644 --- a/lib/fdleak.c +++ b/lib/fdleak.c @@ -31,7 +31,9 @@ @@ -325,7 +324,7 @@ index 87ece559..93b680b6 100644 /* gnulib headers. */ #include "cloexec.h" #include "dirent--.h" -@@ -114,9 +116,10 @@ get_max_fd (void) +@@ -113,9 +115,10 @@ get_max_fd (void) open_max = get_proc_max_fd (); if (open_max >= 0) return open_max; @@ -334,11 +333,11 @@ index 87ece559..93b680b6 100644 open_max = sysconf (_SC_OPEN_MAX); if (open_max == -1) +#endif - open_max = _POSIX_OPEN_MAX; /* underestimate */ + open_max = _POSIX_OPEN_MAX; /* underestimate */ /* We assume if RLIMIT_NOFILE is defined, all the related macros are, too. */ diff --git a/lib/listfile.c b/lib/listfile.c -index 3f0397b5..2d61931b 100644 +index f98c22c7..8d34cfe5 100644 --- a/lib/listfile.c +++ b/lib/listfile.c @@ -21,8 +21,10 @@ @@ -353,10 +352,10 @@ index 3f0397b5..2d61931b 100644 #include #include diff --git a/lib/regextype.c b/lib/regextype.c -index 9c3c7788..98dc5611 100644 +index 2f090892..df9415f5 100644 --- a/lib/regextype.c +++ b/lib/regextype.c -@@ -49,15 +49,15 @@ static struct tagRegexTypeMap regex_map[] = +@@ -48,15 +48,15 @@ static struct tagRegexTypeMap regex_map[] = { { "findutils-default", CONTEXT_FINDUTILS, RE_SYNTAX_EMACS|RE_DOT_NEWLINE }, { "ed", CONTEXT_GENERIC, RE_SYNTAX_ED }, @@ -382,7 +381,7 @@ index 9c3c7788..98dc5611 100644 { "sed", CONTEXT_GENERIC, RE_SYNTAX_SED }, /* ,{ "posix-common", CONTEXT_GENERIC, _RE_SYNTAX_POSIX_COMMON } */ diff --git a/lib/regextype.h b/lib/regextype.h -index 382dcc88..012f65d5 100644 +index 2127ad4d..80c9b9c9 100644 --- a/lib/regextype.h +++ b/lib/regextype.h @@ -29,7 +29,7 @@ int get_regex_type(const char *s); @@ -395,7 +394,7 @@ index 382dcc88..012f65d5 100644 diff --git a/locate/locate.c b/locate/locate.c -index a7f5eb75..d8310fc7 100644 +index 31459e9e..229d910b 100644 --- a/locate/locate.c +++ b/locate/locate.c @@ -66,7 +66,9 @@ @@ -408,7 +407,7 @@ index a7f5eb75..d8310fc7 100644 #include #include #include -@@ -1418,6 +1420,7 @@ static struct option const longopts[] = +@@ -1414,6 +1416,7 @@ static struct option const longopts[] = static int drop_privs (void) { @@ -416,9 +415,9 @@ index a7f5eb75..d8310fc7 100644 const char * what = "failed"; const uid_t orig_euid = geteuid (); const uid_t uid = getuid (); -@@ -1493,7 +1496,11 @@ drop_privs (void) - die (EXIT_FAILURE, errno, "%s", - quotearg_n_style (0, locale_quoting_style, what)); +@@ -1489,7 +1492,11 @@ drop_privs (void) + error (EXIT_FAILURE, errno, "%s", + quotearg_n_style (0, locale_quoting_style, what)); abort (); + #ifndef _WIN32 kill (0, SIGKILL); @@ -428,7 +427,7 @@ index a7f5eb75..d8310fc7 100644 _exit (1); /*NOTREACHED*/ /* ... we hope. */ -@@ -1501,6 +1508,7 @@ drop_privs (void) +@@ -1497,6 +1504,7 @@ drop_privs (void) { /* deliberate infinite loop */ } @@ -436,7 +435,7 @@ index a7f5eb75..d8310fc7 100644 } static int -@@ -1514,11 +1522,13 @@ opendb (const char *name) +@@ -1510,11 +1518,13 @@ opendb (const char *name) if (fd >= 0) { /* Make sure it won't survive an exec */ @@ -451,7 +450,7 @@ index a7f5eb75..d8310fc7 100644 return fd; } diff --git a/xargs/xargs.c b/xargs/xargs.c -index 96e8897f..5dee96ab 100644 +index c1963b19..5255f41f 100644 --- a/xargs/xargs.c +++ b/xargs/xargs.c @@ -46,10 +46,14 @@ @@ -469,7 +468,7 @@ index 96e8897f..5dee96ab 100644 /* gnulib headers. */ #include "closein.h" -@@ -816,7 +820,9 @@ main (int argc, char **argv) +@@ -822,7 +826,9 @@ main (int argc, char **argv) bc_state.argbuf = xmalloc (bc_ctl.arg_max + 1); /* Make sure to listen for the kids. */ @@ -479,7 +478,7 @@ index 96e8897f..5dee96ab 100644 if (!bc_ctl.replace_pat) { -@@ -1233,7 +1239,11 @@ prep_child_for_exec (void) +@@ -1243,7 +1249,11 @@ prep_child_for_exec (void) if (!keep_stdin || open_tty) { int fd; @@ -491,7 +490,7 @@ index 96e8897f..5dee96ab 100644 close (0); if ((fd = open (inputfile, O_RDONLY)) < 0) -@@ -1278,7 +1288,11 @@ static int +@@ -1288,7 +1298,11 @@ static int xargs_do_exec (struct buildcmd_control *ctl, void *usercontext, int argc, char **argv) { pid_t child; @@ -503,20 +502,20 @@ index 96e8897f..5dee96ab 100644 int buf; size_t r; -@@ -1309,7 +1323,8 @@ xargs_do_exec (struct buildcmd_control *ctl, void *usercontext, int argc, char * - ./xargs -P 200 -n 20 sh -c 'echo "$@"; sleep $((1 + $RANDOM % 5))' sleeper +@@ -1319,7 +1333,8 @@ xargs_do_exec (struct buildcmd_control *ctl, void *usercontext, int argc, char * + ./xargs -P 200 -n 20 sh -c 'echo "$@"; sleep $((1 + $RANDOM % 5))' sleeper */ wait_for_proc (false, 0u); - + child=0; +#ifndef _WIN32 if (pipe (fd)) - die (EXIT_FAILURE, errno, _("could not create pipe before fork")); + error (EXIT_FAILURE, errno, _("could not create pipe before fork")); fcntl (fd[1], F_SETFD, FD_CLOEXEC); -@@ -1318,7 +1333,36 @@ xargs_do_exec (struct buildcmd_control *ctl, void *usercontext, int argc, char * +@@ -1328,7 +1343,36 @@ xargs_do_exec (struct buildcmd_control *ctl, void *usercontext, int argc, char * try again. */ while ((child = fork ()) < 0 && errno == EAGAIN && procs_executing) - wait_for_proc (false, 1u); + wait_for_proc (false, 1u); +#else + //this code likely would work for all platforms + @@ -525,7 +524,7 @@ index 96e8897f..5dee96ab 100644 + else{ + int fd_stdin = dup(STDIN_FILENO);//backup stdin incase prep changes it + prep_child_for_exec(); -+ errno = execute(argv[0],argv[0],argv,NULL,false,false,false,false,true,false,NULL); ++ errno = execute(argv[0],argv[0],argv,NULL,NULL,false,false,false,false,true,false,NULL); + dup2(fd_stdin,STDIN_FILENO);//restore stdin + close(fd_stdin); + } @@ -548,18 +547,9 @@ index 96e8897f..5dee96ab 100644 +#endif switch (child) - { - case -1: -@@ -1368,7 +1412,7 @@ xargs_do_exec (struct buildcmd_control *ctl, void *usercontext, int argc, char * - default: - { - /* Parent */ -- close (fd[1]); -+ close (fd[1]); //closing the write end - } - - } /* switch (child) */ -@@ -1462,6 +1506,10 @@ static unsigned int + { + case -1: +@@ -1472,6 +1516,10 @@ static unsigned int add_proc (pid_t pid) { unsigned int i, j; @@ -570,17 +560,17 @@ index 96e8897f..5dee96ab 100644 /* Find an empty slot. */ for (i = 0; i < pids_alloc && pids[i]; i++) -@@ -1496,6 +1544,7 @@ static void +@@ -1506,6 +1554,7 @@ static void wait_for_proc (bool all, unsigned int minreap) { unsigned int reaped = 0; -+#ifndef _WIN32 ++#ifndef _WIN32 + int deferred_exit_status = 0; while (procs_executing) - { -@@ -1590,6 +1639,7 @@ wait_for_proc (bool all, unsigned int minreap) - if (WEXITSTATUS (status) != 0) - child_error = XARGS_EXIT_CLIENT_EXIT_NONZERO; +@@ -1628,6 +1677,7 @@ wait_for_proc (bool all, unsigned int minreap) + child_error = deferred_exit_status > child_error ? deferred_exit_status : child_error; + exit (child_error); } +#endif }