changeset 6145:14906c2745e3

[project @ 2006-11-08 20:33:51 by jwe]
author jwe
date Wed, 08 Nov 2006 20:34:01 +0000
parents e8868fde0fc5
children 1a6d826e92b5
files liboctave/ChangeLog liboctave/dir-ops.cc scripts/ChangeLog scripts/strings/strcat.m
diffstat 4 files changed, 33 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Tue Nov 07 20:52:19 2006 +0000
+++ b/liboctave/ChangeLog	Wed Nov 08 20:34:01 2006 +0000
@@ -1,3 +1,7 @@
+2006-11-08  John W. Eaton  <jwe@octave.org>
+
+	* dir-ops.cc (dir_entry::read): Avoid rewinddir.
+
 2006-11-06  John W. Eaton  <jwe@octave.org>
 
 	* Array.cc (assignN): Exit early if invalid indices are found.
--- a/liboctave/dir-ops.cc	Tue Nov 07 20:52:19 2006 +0000
+++ b/liboctave/dir-ops.cc	Wed Nov 08 20:34:01 2006 +0000
@@ -70,6 +70,10 @@
 string_vector
 dir_entry::read (void)
 {
+  static octave_idx_type grow_size = 100;
+
+  octave_idx_type len = 0;
+
   string_vector dirlist;
 
   if (ok ())
@@ -79,21 +83,24 @@
       struct dirent *dir_ent;
 
       while ((dir_ent = readdir (static_cast<DIR *> (dir))))
-	count++;
-
-      rewinddir (static_cast<DIR *> (dir));
-
-      dirlist.resize (count);
+	{
+	  if (dir_ent)
+	    {
+	      if (count >= len)
+		{
+		  len += grow_size;
+		  dirlist.resize (len);
+		}
 
-      for (int i = 0; i < count; i++)
-	{
-	  dir_ent = readdir (static_cast<DIR *> (dir));
+	      dirlist[count] = dir_ent->d_name;
 
-	  if (dir_ent)
-	    dirlist[i] = dir_ent->d_name;
+	      count++;
+	    }
 	  else
 	    break;
 	}
+
+      dirlist.resize (count);
     }
 
   return dirlist;
--- a/scripts/ChangeLog	Tue Nov 07 20:52:19 2006 +0000
+++ b/scripts/ChangeLog	Wed Nov 08 20:34:01 2006 +0000
@@ -1,3 +1,8 @@
+2006-11-08  John W. Eaton  <jwe@octave.org>
+
+	* strings/strcat.m: Disable Octave:empty-list-elements warning
+	whle concatenating args.
+
 2006-11-07  John W. Eaton  <jwe@octave.org>
 
 	* startup/main-rcfile: Conditionally set PAGER_FLAGS.
--- a/scripts/strings/strcat.m	Tue Nov 07 20:52:19 2006 +0000
+++ b/scripts/strings/strcat.m	Wed Nov 08 20:34:01 2006 +0000
@@ -41,7 +41,13 @@
     error ("strcat: all arguments must be strings");
   endif
 
-  st = [varargin{:}];
+  unwind_protect
+    tmp = warning ("query", "Octave:empty-list-elements");
+    warning ("off", "Octave:empty-list-elements");
+    st = [varargin{:}];
+  unwind_protect_cleanup
+    warning (tmp.state, "Octave:empty-list-elements");
+  end_unwind_protect
 
 endfunction