changeset 28475:5a85e42a1be7 stable

Make gzip/bzip2 more Matlab compatible when directory is first argument (bug #58547). * gzip.cc (xzip): Strip source path from basename of source file.
author Rik <rik@octave.org>
date Sat, 13 Jun 2020 20:12:50 -0700
parents a6c89130cfaa
children 460dd19f6109 7f586be7282c
files libinterp/dldfcn/gzip.cc
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/dldfcn/gzip.cc	Sun Jun 14 11:17:33 2020 +0200
+++ b/libinterp/dldfcn/gzip.cc	Sat Jun 13 20:12:50 2020 -0700
@@ -556,7 +556,10 @@
     const std::function<std::string(const std::string&)> mk_dest_path
       = [&out_dir, &ext] (const std::string& source_path) -> std::string
       {
-        const std::string basename = sys::env::base_pathname (source_path);
+        // Strip any relative path (bug #58547)
+        size_t pos = source_path.find_last_of (sys::file_ops::dir_sep_str ());
+        const std::string basename =
+          (pos == std::string::npos ? source_path : source_path.substr (pos+1));
         return sys::file_ops::concat (out_dir, basename + ext);
       };