changeset 27328:29e52bcc72af stable

dir.m: Fix occasionally returning incorrect folder field (bug #55448). * dir.m: Replace regexprep with regexp. If match fails, set tmpdir to '.' for current directory.
author Rik <rik@octave.org>
date Tue, 06 Aug 2019 21:13:40 -0700
parents 1582a6140275
children d5e24466835f 640ee0d531d0
files scripts/miscellaneous/dir.m
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/miscellaneous/dir.m	Mon Aug 05 17:15:57 2019 -0700
+++ b/scripts/miscellaneous/dir.m	Tue Aug 06 21:13:40 2019 -0700
@@ -134,7 +134,12 @@
             st = xst;
           endif
         endif
-        tmpdir = regexprep (fn, re, '$1');
+        [sts, tmpdir] = regexp (fn, re, "start", "tokens");
+        if (isempty (sts))
+          tmpdir = ".";
+        else
+          tmpdir = tmpdir{1}{1};
+        endif
         fn = regexprep (fn, re, '$2$3');
         info(i).name = fn;
         if (! strcmp (last_dir, tmpdir))