changeset 32174:6ad3035405a5 stable

fullfile.m: Return empty cell for input with empty cell (bug #64377). * scripts/miscellaneous/fullfile.m: Don't remove empty cells from input. Add test. Fix comment (filesep character on *nix is slash, not backslash).
author Markus Mützel <markus.muetzel@gmx.de>
date Mon, 03 Jul 2023 18:43:40 +0200
parents e8497a0fb249
children d8350580b981 134152cf1a3f
files scripts/miscellaneous/fullfile.m
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/miscellaneous/fullfile.m	Fri Jun 23 20:51:15 2023 +0200
+++ b/scripts/miscellaneous/fullfile.m	Mon Jul 03 18:43:40 2023 +0200
@@ -61,7 +61,7 @@
 function filename = fullfile (varargin)
 
   ## remove empty arguments
-  varargin(cellfun (@isempty, varargin)) = [];
+  varargin(cellfun (@(x) isempty (x) & ! iscell (x), varargin)) = [];
 
   if (isempty (varargin))
     ## return early for all empty or no input
@@ -157,12 +157,14 @@
 %!        {["folder1", fs, "sub", fs, "f1.m"], ...
 %!         ["folder2", fs, "sub", fs, "f2.m"]});
 
+%!assert <*64377> (fullfile ("x", {}), {})
+
 ## Windows specific - drive letters and file sep type
 %!testif ; ispc ()
 %! assert (fullfile ('\/\/\//A:/\/\', "x/", "/", "/", "y", "/", "/"), ...
 %!         ['A:\' xfsyfs]);
 
-## *nix specific - double backslash
+## *nix specific - double slash
 %!testif ; ! ispc ()
 %! assert (fullfile (fs, fs), fs);