# HG changeset patch # User jwe # Date 811139534 0 # Node ID 6550c74777b95cabf050d98d7b902e0e3782596b # Parent 633199854158774ccbb6d7f3c8eb687603959b1a [project @ 1995-09-15 04:27:57 by jwe] diff --git a/src/data.cc b/src/data.cc --- a/src/data.cc +++ b/src/data.cc @@ -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\ diff --git a/src/dirfns.cc b/src/dirfns.cc --- a/src/dirfns.cc +++ b/src/dirfns.cc @@ -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