# HG changeset patch # User Philip Nienhuis # Date 1426622207 -3600 # Node ID 8c20fb6caa16e09c5d0eb1052254e1c1220b2393 # Parent e75a0fe1eee203838738704dd4ba75b7f745ba43 Fix XFAIL with tar and unpack tests (bug #44007, bug #43979). * tar.m: On Windows, convert full Windows path name to msys style. * unpack.m: ditto, and use make_absolute_filename rather than canonicalize_file_name. * private/__w2mpth__.m: New function, converts Windows style path to msys style. diff -r e75a0fe1eee2 -r 8c20fb6caa16 scripts/miscellaneous/private/__w2mpth__.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/miscellaneous/private/__w2mpth__.m Tue Mar 17 20:56:47 2015 +0100 @@ -0,0 +1,71 @@ +## Copyright (C) 2015 Philip Nienhuis +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{mingwpath} =} __w2mpth__ (@var{winpath}) +## Convert a Windows-style relative or full path name to MinGW style. +## +## @strong{Caution:} __w2mpth__ does not check the validity of the path. +## +## Examples: +## +## @example +## @group +## mpth = __w2mpth ('D:\full\path\to\file.dat') +## @result{} '/D/full/path/to/file.dat' +## @end group +## @end example +## +## @example +## @group +## mpth = __w2mpth ('relative\path\to\file.dat') +## @result{} 'relative/path/to/file.dat' +## @end group +## @end example +## +## @end deftypefn + +## Author: Philip Nienhuis +## Created: 2015-01-16 + +function mingwpath = __w2mpth__ (winpath) + + ## Check for platform + if (! ispc) + error ("__m2wpath__ should only be called on Windows platforms\n"); + endif + + ## Replace backslash file separators by forward slashes + mingwpath = strrep (winpath, '\', '/'); + ## Also treat drive letter but beware of relative filenames + mingwpath = regexprep (mingwpath, '^([a-zA-Z]):', '/$1'); + +endfunction + + +## Use single quote strings for winpaths to cope with backslashes. +%!test +%! if (ispc) +%! assert (__w2mpth__ ('file.fil'), 'file.fil'); +%! assert (__w2mpth__ ('\file.fil'), '/file.fil'); +%! assert (__w2mpth__ ('G:\file.fil'), '/G/file.fil'); +%! assert (__w2mpth__ ('r:\subdir\file.fil'), '/r/subdir/file.fil'); +%! assert (__w2mpth__ ('relative\path\to\file.dat'), +%! 'relative/path/to/file.dat') +%! endif + diff -r e75a0fe1eee2 -r 8c20fb6caa16 scripts/miscellaneous/tar.m --- a/scripts/miscellaneous/tar.m Mon Mar 16 11:51:35 2015 -0700 +++ b/scripts/miscellaneous/tar.m Tue Mar 17 20:56:47 2015 +0100 @@ -55,6 +55,11 @@ tarfile = make_absolute_filename (tarfile); + if (ispc) + ## Change tarfile into a mingw style acceptable for tar + tarfile = __w2mpth__ (tarfile); + endif + cmd = sprintf ("tar cvf %s -C %s %s", tarfile, rootdir, sprintf (" %s", files{:})); diff -r e75a0fe1eee2 -r 8c20fb6caa16 scripts/miscellaneous/unpack.m --- a/scripts/miscellaneous/unpack.m Mon Mar 16 11:51:35 2015 -0700 +++ b/scripts/miscellaneous/unpack.m Tue Mar 17 20:56:47 2015 +0100 @@ -190,6 +190,11 @@ nodotext = ext(ext != '.'); endif + if (ispc && strcmp (nodotext, "tar")) + ## Change file pathname into a mingw style acceptable for tar + file = __w2mpth__ (file); + endif + if (isfield (commandlist, tolower (nodotext))) [commandv, commandq, parsefcn, move] = deal (commandlist.(nodotext){:}); origdir = pwd (); @@ -198,8 +203,8 @@ else startdir = origdir; endif - cstartdir = canonicalize_file_name (startdir); - cenddir = canonicalize_file_name (dir); + cstartdir = make_absolute_filename (startdir); + cenddir = make_absolute_filename (dir); needmove = move && ! strcmp (cstartdir, cenddir); if (nargout > 0 || needmove) command = commandv;