seperate multiple filenames by non-space character in pkg.m
Jaroslav Hajek
highegg at gmail.com
Fri Oct 10 04:20:12 CDT 2008
On Thu, Oct 2, 2008 at 9:02 PM, John W. Eaton <jwe at bevo.che.wisc.edu> wrote:
> On 2-Oct-2008, John W. Eaton wrote:
>
> | Shouldn't we also do the same thing for the .m files? Should we try
> | to avoid putting a trailing colon at the end of filenames?
> |
> | Or, instead of
> |
> | m = dir (fullfile (src, "*.m"));
> | oct = dir (fullfile (src, "*.oct"));
> | mex = dir (fullfile (src, "*.mex"));
> | archdependent = "";
> | archindependent = "";
> | filenames = "";
> | if (length (m) > 0)
> | filenames = sprintf (fullfile (src, "%s "), m.name);
> | endif
> | if (length (oct) > 0)
> | filenames = cstrcat (filenames, " ",
> | sprintf (fullfile (src, "%s "), oct.name));
> | endif
> | if (length (mex) > 0)
> | filenames = cstrcat (filenames, " ",
> | sprintf (fullfile (src, "%s "), mex.name));
> | endif
> | filenames = split_by (filenames, " ");
> |
> | maybe we could simplify all of this by doing something like
> |
> | m = dir (fullfile (src, "*.m"));
> | oct = dir (fullfile (src, "*.oct"));
> | mex = dir (fullfile (src, "*.mex"));
> |
> | ## FIXME -- we should not need the tests on size here, but there is
> | ## a bug in concatenation with { } when an expression like oct.name
> | ## produces nothing.
> |
> | if (isempty (m)) mnames = { }; else mnames = { m.name }; endif
> | if (isempty (oct)) octnames = { }; else octnames = { oct.name }; endif
> | if (isempty (mex)) mexnames = { }; else mexnames = { mex.name }; endif
> |
> | filenames = cellfun (@(x) fullfile (src, x), [mnames, octnames, mexnames],
> | "UniformOutput", false);
> |
> | Of course this could be further simplified if the bug is fixed, so I'll
> | take a look at doing that.
> |
> | Also, why are archdependent and archindependent even set in this
> | block? They appear to be set unconditionally just below.
>
> I checked in a bug fix so now things like
>
> x = dir ("nonexistent-file");
> {x.name}
>
> does the right thing and produces an empty cell array instead of a
> cell array containing an undefined value.
>
> Then I also checked in a fix for pkg.m as outlined above (but without
> the isempty checks).
>
I transplanted both of them to 3.0.x.
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
More information about the Bug-octave
mailing list