changeset 19370:3a905b642408

savepath.m: Fix failing BIST test * savepath.m: Check that the path to save is not empty before attempting to save it.
author Rik <rik@octave.org>
date Thu, 20 Nov 2014 08:51:41 -0800
parents bb8d3f17248d
children d47e50953abc
files scripts/path/savepath.m
diffstat 1 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/path/savepath.m	Thu Nov 20 08:08:35 2014 -0800
+++ b/scripts/path/savepath.m	Thu Nov 20 08:51:41 2014 -0800
@@ -136,12 +136,17 @@
       path_to_save = path_to_preserve(sort (n));
       ## Remove pwd
       path_to_save(strcmp (path_to_save, ["." pathsep])) = [];
-      n = ones (size (path_to_save));
-      for m = 1:numel (path_to_save)
-        n(m) = find (strcmp (path_to_save{m}, path_to_preserve));
-      endfor
-      path_to_save_begin = path_to_save(n <= n_middle);
-      path_to_save_end   = path_to_save(n > n_middle);
+      if (! isempty (path_to_save))
+        n = ones (numel (path_to_save), 1);
+        for m = 1:numel (path_to_save)
+          n(m) = find (strcmp (path_to_save{m}, path_to_preserve));
+        endfor
+        path_to_save_begin = path_to_save(n <= n_middle);
+        path_to_save_end   = path_to_save(n > n_middle);
+      else
+        path_to_save_begin = {};
+        path_to_save_end   = {};
+      endif
     else
       path_to_save_begin = path_to_preserve;
       path_to_save_end   = {};