From 50126f2049a03d2910412572c98bafbc26f3db31 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 24 Jul 2019 11:28:48 -0700 Subject: [PATCH] Port double-slash test to z/OS * admin/merge-gnulib (GNULIB_MODULES): Add double-slash-root. Emacs was already using this Gnulib module indirectly, so this is merely noting that there is now a direct dependency. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * src/fileio.c (search_embedded_absfilename): Use DOUBLE_SLASH_IS_DISTINCT_ROOT instead of (WINDOWSNT || CYGWIN). Simplify. --- admin/merge-gnulib | 2 +- lib/gnulib.mk.in | 1 + m4/gnulib-comp.m4 | 2 ++ src/fileio.c | 22 ++++++++++------------ 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/admin/merge-gnulib b/admin/merge-gnulib index 42e9c0c8645..50b0c762a8f 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib @@ -31,7 +31,7 @@ GNULIB_MODULES=' careadlinkat close-stream copy-file-range count-leading-zeros count-one-bits count-trailing-zeros crypto/md5-buffer crypto/sha1-buffer crypto/sha256-buffer crypto/sha512-buffer - d-type diffseq dosname dtoastr dtotimespec dup2 + d-type diffseq dosname double-slash-root dtoastr dtotimespec dup2 environ execinfo explicit_bzero faccessat fcntl fcntl-h fdopendir filemode filevercmp flexmember fpieee fstatat fsusage fsync diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index 85fdbd2df6f..79580e931ab 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -86,6 +86,7 @@ # d-type \ # diffseq \ # dosname \ +# double-slash-root \ # dtoastr \ # dtotimespec \ # dup2 \ diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index d6b2009123d..77563edc84d 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -70,6 +70,7 @@ AC_DEFUN([gl_EARLY], # Code from module dirent: # Code from module dirfd: # Code from module dosname: + # Code from module double-slash-root: # Code from module dtoastr: # Code from module dtotimespec: # Code from module dup2: @@ -227,6 +228,7 @@ AC_DEFUN([gl_INIT], gl_SHA512 gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE gl_DIRENT_H + gl_DOUBLE_SLASH_ROOT gl_FUNC_DUP2 if test $HAVE_DUP2 = 0 || test $REPLACE_DUP2 = 1; then AC_LIBOBJ([dup2]) diff --git a/src/fileio.c b/src/fileio.c index 4c7625cad4a..e4269b96a37 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -1778,20 +1778,18 @@ get_homedir (void) static char * search_embedded_absfilename (char *nm, char *endp) { - char *p, *s; - - for (p = nm + 1; p < endp; p++) + char *p = nm + 1; +#ifdef DOUBLE_SLASH_IS_DISTINCT_ROOT + p += (IS_DIRECTORY_SEP (p[-1]) && IS_DIRECTORY_SEP (p[0]) + && !IS_DIRECTORY_SEP (p[1])); +#endif + for (; p < endp; p++) { - if (IS_DIRECTORY_SEP (p[-1]) - && file_name_absolute_p (p) -#if defined (WINDOWSNT) || defined (CYGWIN) - /* // at start of file name is meaningful in Apollo, - WindowsNT and Cygwin systems. */ - && !(IS_DIRECTORY_SEP (p[0]) && p - 1 == nm) -#endif /* not (WINDOWSNT || CYGWIN) */ - ) + if (IS_DIRECTORY_SEP (p[-1]) && file_name_absolute_p (p)) { - for (s = p; *s && !IS_DIRECTORY_SEP (*s); s++); + char *s; + for (s = p; *s && !IS_DIRECTORY_SEP (*s); s++) + continue; if (p[0] == '~' && s > p + 1) /* We've got "/~something/". */ { USE_SAFE_ALLOCA; -- 2.39.2