changeset 30052:525c85e9f402

Allow file_in_path to look for files in UNC paths (bug #61080). * liboctave/util/kpse.cc: Do not remove double slash at start of path if it is a distinct root.
author Markus Mützel <markus.muetzel@gmx.de>
date Thu, 26 Aug 2021 15:06:56 +0200
parents 997cf870a963
children 0b67964031be
files liboctave/util/kpse.cc
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/util/kpse.cc	Thu Aug 26 11:07:56 2021 +0200
+++ b/liboctave/util/kpse.cc	Thu Aug 26 15:06:56 2021 +0200
@@ -346,6 +346,8 @@
               elt = elt.substr (1);
             }
         }
+#if (! defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \
+     && ! defined (DOUBLE_SLASH_IS_DISTINCT_ROOT))
       else
         {
           /* We never want to search the whole disk.  */
@@ -353,6 +355,7 @@
                  && IS_DIR_SEP (elt[0]) && IS_DIR_SEP (elt[1]))
             elt = elt.substr (1);
         }
+#endif
 
       /* Our caller (search), also tests first_search, and does
          the resetting.  */
@@ -423,9 +426,12 @@
 
       std::size_t home_len = home.length ();
 
+#if (! defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \
+     && ! defined (DOUBLE_SLASH_IS_DISTINCT_ROOT))
       /* handle leading // */
       if (home_len > 1 && IS_DIR_SEP (home[0]) && IS_DIR_SEP (home[1]))
         home = home.substr (1);
+#endif
 
       /* omit / after ~ */
       if (IS_DIR_SEP (home[home_len - 1]))
@@ -457,9 +463,12 @@
       if (home.empty ())
         home = ".";
 
+#  if (! defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \
+       && ! defined (DOUBLE_SLASH_IS_DISTINCT_ROOT))
       /* handle leading // */
       if (home.length () > 1 && IS_DIR_SEP (home[0]) && IS_DIR_SEP (home[1]))
         home = home.substr (1);
+#  endif
 
       /* If HOME ends in /, omit the / after ~user. */
       if (name.length () > c && IS_DIR_SEP (home.back ()))
@@ -590,6 +599,8 @@
               elt = elt.substr (1);
             }
         }
+#if (! defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \
+     && ! defined (DOUBLE_SLASH_IS_DISTINCT_ROOT))
       else
         {
           /* We never want to search the whole disk.  */
@@ -597,6 +608,7 @@
                  && IS_DIR_SEP (elt[0]) && IS_DIR_SEP (elt[1]))
             elt = elt.substr (1);
         }
+#endif
 
       /* We have to search one directory at a time.  */
       dir = kpse_element_dir (elt);
@@ -766,6 +778,8 @@
               elt = elt.substr (1);
             }
         }
+#if (! defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \
+     && ! defined (DOUBLE_SLASH_IS_DISTINCT_ROOT))
       else
         {
           /* We never want to search the whole disk.  */
@@ -773,6 +787,7 @@
                  && IS_DIR_SEP (elt[0]) && IS_DIR_SEP (elt[1]))
             elt = elt.substr (1);
         }
+#endif
 
       /* Search the disk for all dirs in the component specified.
          Be faster to check the database, but this is more reliable.  */