changeset 28191:6ea1e96b69d4 stable

canonicalize_file_name: Fix for non-existent file on Windows (bug #58118). * file-ops.cc (canonicalize_file_name): Use temporary variable for operations on a copy of the static input string in if-block for UNC paths.
author Markus Mützel <markus.muetzel@gmx.de>
date Tue, 07 Apr 2020 08:42:31 +0200
parents 5624fd0c5efb
children 450fe5371acd 56c209ff0a08
files liboctave/system/file-ops.cc
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/system/file-ops.cc	Thu Mar 12 20:45:47 2020 +0100
+++ b/liboctave/system/file-ops.cc	Tue Apr 07 08:42:31 2020 +0200
@@ -718,12 +718,12 @@
       if (retval.empty ())
         {
           // For UNC paths, take the input as is.
-          // Also translate forward slashes.
-          retval = name;
-          std::replace (retval.begin (), retval.end (), '/', '\\');
-          if (retval.compare (0, 2, "\\\\") == 0)
+          // Also translate forward slashes to backslashes.
+          std::string name_backsl = name;
+          std::replace (name_backsl.begin (), name_backsl.end (), '/', '\\');
+          if (name_backsl.compare (0, 2, "\\\\") == 0)
             {
-              w_tmp = u8_to_wstring (retval);
+              w_tmp = u8_to_wstring (name_backsl);
               strip_marker = false;
               wchar_t canon_path[MAX_PATH];
               if (PathCanonicalizeW (canon_path, w_tmp.c_str ()))