changeset 29210:e8819aa30715 stable

stat: Use "make_absolute" instead of "canonicalize_file_name" on Windows (bug #59706). * liboctave/system/file-stat.cc (file_stat::update_internal): Use "make_absolute" instead of "canonicalize_file_name" on Windows. Remove fallback for files including non-ASCII characters.
author Markus Mützel <markus.muetzel@gmx.de>
date Mon, 21 Dec 2020 11:29:35 +0100
parents 370b5ded5e6a
children 649920d8a5bf 45abff4199d8
files liboctave/system/file-stat.cc
diffstat 1 files changed, 4 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/system/file-stat.cc	Tue Dec 15 19:23:35 2020 +0100
+++ b/liboctave/system/file-stat.cc	Mon Dec 21 11:29:35 2020 +0100
@@ -38,6 +38,7 @@
 
 #if defined (OCTAVE_USE_WINDOWS_API)
 #  include "lo-regexp.h"
+#  include "oct-env.h"
 #endif
 
 namespace octave
@@ -194,12 +195,7 @@
           std::string full_file_name = sys::file_ops::tilde_expand (file_name);
 
 #if defined (OCTAVE_USE_WINDOWS_API)
-          std::string canon_file_name
-            = sys::canonicalize_file_name (full_file_name);
-
-          // Might have failed for files with non-ASCII characters in name
-          if (! canon_file_name.empty ())
-            full_file_name = canon_file_name;
+          full_file_name = sys::env::make_absolute (full_file_name);
 
           // Remove trailing slashes
           while (full_file_name.length () > 1
@@ -209,10 +205,10 @@
           // If path is a root (like "C:" or "\\SERVER\share"), add a
           // trailing backslash.
           // FIXME: Does this pattern match all possible UNC roots?
-          octave::regexp pat (R"(^\\\\[\w-]*\\[\w-]*$)");
+          regexp pat (R"(^\\\\[\w-]*\\[\w-]*$)");
           if ((full_file_name.length () == 2 && full_file_name[1] == ':')
               || pat.is_match (full_file_name))
-            full_file_name += "\\";
+            full_file_name += '\\';
 #endif
 
           const char *cname = full_file_name.c_str ();