changeset 1402:6550c74777b9

[project @ 1995-09-15 04:27:57 by jwe]
author jwe
date Fri, 15 Sep 1995 04:32:14 +0000
parents 633199854158
children 69d15711b832
files src/data.cc src/dirfns.cc
diffstat 2 files changed, 49 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/data.cc	Fri Sep 15 04:15:27 1995 +0000
+++ b/src/data.cc	Fri Sep 15 04:32:14 1995 +0000
@@ -741,6 +741,41 @@
   return retval;
 }
 
+DEFUN ("struct_elements", Fstruct_elements, Sstruct_elements, 1, 1,
+  "struct_elements (S)\n\
+\n\
+Return a list of the names of the elements of the structure S.")
+{
+  Octave_object retval;
+
+  int nargin = args.length ();
+
+  if (nargin == 1)
+    {
+      if (args (0).is_map ())
+	{
+	  Octave_map m = args(0).map_value ();
+	  char **names = m.make_name_list ();
+	  Octave_str_obj list (m.length ());
+	  char **ptr = names;
+	  int i = 0;
+	  while (*ptr)
+	    {
+	      list(i++) = *ptr;
+	      delete [] *ptr++;
+	    }
+	  delete [] names;
+	  retval(0) = list;
+	}
+      else
+	gripe_wrong_type_arg ("struct_elements", args (0));
+    }
+  else
+    print_usage ("struct_elements");
+
+  return retval;
+}
+
 DEFUN ("struct_contains", Fstruct_contains, Sstruct_contains, 1, 2,
   "struct_contains (S, NAME)\n\
 \n\
--- a/src/dirfns.cc	Fri Sep 15 04:15:27 1995 +0000
+++ b/src/dirfns.cc	Fri Sep 15 04:32:14 1995 +0000
@@ -49,6 +49,7 @@
 #include "defun.h"
 #include "dirfns.h"
 #include "error.h"
+#include "gripes.h"
 #include "help.h"
 #include "oct-obj.h"
 #include "oct-str.h"
@@ -498,7 +499,7 @@
       if (error_state)
 	{
 	  status = -1;
-	  error ("readdir: string argument expected");
+	  gripe_wrong_type_arg ("readdir", args(0));
 	}
       else
 	{
@@ -573,7 +574,7 @@
       const char *dirname = args(0).string_value ();
 
       if (error_state)
-	error ("mkdir: string argument expected");
+	gripe_wrong_type_arg ("mkdir", args(0));
       else if (mkdir (dirname, 0777) < 0)
 	{
 	  status = -1;
@@ -604,7 +605,7 @@
       const char *dirname = args(0).string_value ();
 
       if (error_state)
-	error ("rmdir: string argument expected");
+	gripe_wrong_type_arg ("rmdir", args(0));
       else if (rmdir (dirname) < 0)
 	{
 	  status = -1;
@@ -633,14 +634,18 @@
   if (args.length () == 2)
     {
       const char *from = args(0).string_value ();
-      const char *to = args(1).string_value ();
-
       if (error_state)
-	error ("rename: string arguments expected");
-      else if (rename (from, to) < 0)
+	gripe_wrong_type_arg ("rename", args(0));
+      else
 	{
-	  status = -1;
-	  error ("%s", strerror (errno));
+	  const char *to = args(1).string_value ();
+	  if (error_state)
+	    gripe_wrong_type_arg ("rename", args(1));
+	  else if (rename (from, to) < 0)
+	    {
+	      status = -1;
+	      error ("%s", strerror (errno));
+	    }
 	}
     }
   else