[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: filesep extension
From: |
Jaroslav Hajek |
Subject: |
Re: filesep extension |
Date: |
Tue, 11 Nov 2008 18:42:29 +0100 |
On Tue, Nov 11, 2008 at 5:31 PM, John W. Eaton <address@hidden> wrote:
> On 11-Nov-2008, Michael Goffioul wrote:
>
> | I noticed a problem in fileparts tests: some tests uses forward slash,
> | while fileparts uses filesep, which is the backward slash under Windows.
> | This makes most tests to fail.
> |
> | To solve that, I thought about extending filesep behavior and make it
> | return all file separators when 'all' is given as argument. See the attached
> | changeset (OK to apply?). However, now I'd like to modify fileparts.m,
> | but I'm not sure about the most efficient way to implement find_last_of
> | functionality in ocave. Any idea?
>
> See also this thread:
>
>
> https://www-old.cae.wisc.edu/pipermail/octave-maintainers/2008-October/009169.html
>
> I think your patch is also OK.
>
> I'm not sure what to suggest for the best scripting language
> equivalent for find_last_of. A regular expression? That doesn't seem
> like a great solution and would be a bit messy in the current case
> because \ is special in a regular expression. For example, you need
> something like
>
> regexp ('/foo/bar\baz', '[\\/][^\\/]*$')
>
> Do we need a new function, or can someone think of a good way to do
> this with functions we currently have?
>
What about implementing this using find (), with similar input &
output arguments?
Say, like this:
function varargout = strchr (str, chars, varargin)
if (nargin < 2 || ! ischar (str) || ! ischar (chars))
print_usage ();
endif
f = false (1, 256);
f(chars) = true;
varargout = cell (1, nargout);
[varargout{:}] = find (reshape (f(str), size (str)), varargin{:});
endfunction
Two notes:
1. I think the function name should start with "str"
2. Note that this currently doesn't work with nargout = 0 due to a
strange indexing bug.
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
- filesep extension, Michael Goffioul, 2008/11/11
- filesep extension, John W. Eaton, 2008/11/11
- Re: filesep extension,
Jaroslav Hajek <=
- Re: filesep extension, Michael Goffioul, 2008/11/12
- Re: filesep extension, Jaroslav Hajek, 2008/11/12
- Re: filesep extension, Michael Goffioul, 2008/11/12
- Re: filesep extension, Jaroslav Hajek, 2008/11/12
- Re: filesep extension, Søren Hauberg, 2008/11/12