# HG changeset patch # User Markus Mützel # Date 1586241751 -7200 # Node ID 6ea1e96b69d43c1e3e8ec65146892dc3f4f16aec # Parent 5624fd0c5efb0f5f628260e1be53cbfa71c136f3 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. diff -r 5624fd0c5efb -r 6ea1e96b69d4 liboctave/system/file-ops.cc --- 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 ()))