changeset 28053:b70b9eaaf751

Actually canonicalize UNC paths (bug #57439). * file-ops.cc (canonicalize_file_name): Call PathCanonicalizeW on UNC paths. * configure.ac: Add check for shlwapi library.
author Markus Mützel <markus.muetzel@gmx.de>
date Sun, 09 Feb 2020 21:38:36 +0100
parents 118606de9359
children 372f42f122bd
files configure.ac liboctave/system/file-ops.cc
diffstat 2 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Fri Oct 25 19:00:03 2019 +0200
+++ b/configure.ac	Sun Feb 09 21:38:36 2020 +0100
@@ -1267,6 +1267,16 @@
   ;;
 esac
 
+## Windows-specific module used for canonical UNC paths
+case $host_os in
+  msdosmsvc | mingw*)
+    AC_CHECK_HEADERS([shlwapi.h],
+      [LIBS="-lshlwapi $LIBS"],
+      [AC_MSG_ERROR([Missing SHLWAPI required to build for Windows target.])],
+      [#include <windows.h>])
+  ;;
+esac
+
 ## Cygwin kluge for getrusage.
 AC_CHECK_FUNCS([getrusage])
 case $host_os in
--- a/liboctave/system/file-ops.cc	Fri Oct 25 19:00:03 2019 +0200
+++ b/liboctave/system/file-ops.cc	Sun Feb 09 21:38:36 2020 +0100
@@ -37,6 +37,7 @@
 #endif
 #if defined (OCTAVE_USE_WINDOWS_API)
 #  include <windows.h>
+#  include <shlwapi.h>
 #endif
 
 #include <vector>
@@ -723,6 +724,9 @@
             {
               w_tmp = u8_to_wstring (retval);
               strip_marker = false;
+              wchar_t canon_path[MAX_PATH];
+              if (PathCanonicalizeW (canon_path, w_tmp.c_str ()))
+                w_tmp = std::wstring (canon_path);
             }
         }
       else