Mercurial > hg > octave-nkf
changeset 18060:427412d40f1a
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.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 03 Dec 2013 10:49:01 -0800 |
parents | b675665ce328 |
children | 832ecfda1d3c |
files | scripts/miscellaneous/what.m |
diffstat | 1 files changed, 12 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/miscellaneous/what.m +++ b/scripts/miscellaneous/what.m @@ -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"))