# HG changeset patch # User Rik # Date 1386096541 28800 # Node ID 427412d40f1aaab8f71e846d3d81c80e6afb9600 # Parent b675665ce328b8ecb292d4f8516f5a6049a7ab5c what.m: Workaround file separator issues in code (bug #40726). * what.m: Check for both flavors of file separator at end of input dir name and remove if found. diff -r b675665ce328 -r 427412d40f1a scripts/miscellaneous/what.m --- a/scripts/miscellaneous/what.m Tue Dec 03 10:45:20 2013 -0800 +++ b/scripts/miscellaneous/what.m Tue Dec 03 10:49:01 2013 -0800 @@ -30,17 +30,19 @@ if (nargin == 0) d = pwd (); - elseif (isempty (strfind (d, filesep ()))) - ## Find the appropriate directory on the path. - p = strtrim (ostrsplit (path (), pathsep ())); - d = p{find (cellfun (@(x) ! isempty (strfind (x, d)), p))(end)}; else - [status, msg, msgid] = fileattrib (d); - if (status != 1) - error ("what: could not find the file or path %s", d); - else - d = msg.Name; + dtmp = canonicalize_file_name (d); + if (isempty (dtmp)) + ## Search for directory name in path + if (d(end) == '/' || d(end) == '\') + d(end) = []; + endif + dtmp = find_dir_in_path (d); + if (isempty (dtmp)) + error ("what: could not find the directory %s", d); + endif endif + d = dtmp; endif files = dir (d); @@ -60,7 +62,7 @@ continue; else ## Ignore mdl and p files - [dummy, f, e] = fileparts (n); + [~, f, e] = fileparts (n); if (strcmp (e, ".m")) w.m{end+1} = n; elseif (strcmp (e, ".oct"))