octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fileparts.m in octave (mingw and msvc)


From: John W. Eaton
Subject: Re: fileparts.m in octave (mingw and msvc)
Date: Tue, 27 Jan 2009 12:41:17 -0500

On 19-Jan-2009, Jaroslav Hajek wrote:

| On Mon, Jan 19, 2009 at 8:27 AM, Michael Goffioul
| <address@hidden> wrote:
| > On Mon, Jan 19, 2009 at 1:52 AM, Tatsuro MATSUOKA <address@hidden> wrote:
| >> OK. I agree with you.
| >> However, implementation of "filesep('all')" can not be done soon.
| >
| > Well, filesep('all') is already implemented in development branch.
| > It's just a matter of backporting. There was also some good proposals
| > for an efficient find_last_of implementation in
| > http://www.nabble.com/filesep-extension-td20441910.html#a20441910
| >
| > So I think everything is there to solve that problem elegantly.
| >
| > Michael.
| >
| 
| Humm.. I see that was my proposal ended by "I'll commit a changeset."
| About time to fullfill the promise, I guess... hopefully today.

I see you added strchr, so I decided to look at fileparts.  I think
the following change will work, but should we make strchr return 0 for
no match (similar to index/rindex) or an empty matrix like find?  If
it returns 0 for no match, the change to fileparts is simpler.

jwe

diff --git a/scripts/miscellaneous/fileparts.m 
b/scripts/miscellaneous/fileparts.m
--- a/scripts/miscellaneous/fileparts.m
+++ b/scripts/miscellaneous/fileparts.m
@@ -27,7 +27,10 @@
 
   if (nargin == 1)
     if (ischar (filename))
-      ds = rindex (filename, filesep);
+      ds = strchr (filename, filesep ("all"), 1, "last");
+      if (isempty (ds))
+       ds = 0;
+      endif
       es = rindex (filename, ".");
       ## These can be the same if they are both 0 (no dir or ext).
       if (es <= ds)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]