changeset 2294:46839fa1fcf3

[project @ 1996-06-13 09:12:58 by jwe]
author jwe
date Thu, 13 Jun 1996 09:12:58 +0000
parents a015ab4392c2
children 95d9259a9915
files src/variables.cc
diffstat 1 files changed, 43 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/variables.cc	Thu Jun 13 08:52:18 1996 +0000
+++ b/src/variables.cc	Thu Jun 13 09:12:58 1996 +0000
@@ -149,6 +149,24 @@
   return (sr && sr->is_text_function ());
 }
 
+// Is this a mapper function?
+
+bool
+is_builtin_function_name (const string& s)
+{
+  symbol_record *sr = global_sym_tab->lookup (s);
+  return (sr && sr->is_builtin_function ());
+}
+
+// Is this a mapper function?
+
+bool
+is_mapper_function_name (const string& s)
+{
+  symbol_record *sr = global_sym_tab->lookup (s);
+  return (sr && sr->is_mapper_function ());
+}
+
 // Is this function globally in this scope?
 
 bool
@@ -1016,35 +1034,40 @@
   return status;
 }
 
-DEFUN_TEXT (document, args, ,
-  "document symbol string ...\n\
+DEFUN (document, args, ,
+  "document (NAME, STRING)\n\
 \n\
 Associate a cryptic message with a variable name.")
 {
-  octave_value_list retval;
-
-  int argc = args.length () + 1;
+  octave_value retval;
 
-  string_vector argv = args.make_argv ("document");
+  int nargin = args.length ();
 
-  if (error_state)
-    return retval;
-
-  if (argc == 3)
+  if (nargin == 2)
     {
-      string name = argv[1];
-      string help = argv[2];
+      string name = args(0).string_value ();
 
-      if (is_builtin_variable (name))
-	error ("sorry, can't redefine help for builtin variables");
-      else
+      if (! error_state)
 	{
-	  symbol_record *sym_rec = curr_sym_tab->lookup (name, 0);
+	  string help = args(1).string_value ();
 
-	  if (sym_rec)
-	    sym_rec->document (help);
-	  else
-	    error ("document: no such symbol `%s'", name.c_str ());
+	  if (! error_state)
+	    {
+	      if (is_builtin_variable (name)
+		  || is_text_function_name (name)
+		  || is_mapper_function_name (name)
+		  || is_builtin_function_name (name))
+		error ("document: can't redefine help for built-in variables and functions");
+	      else
+		{
+		  symbol_record *sym_rec = curr_sym_tab->lookup (name, 0);
+
+		  if (sym_rec)
+		    sym_rec->document (help);
+		  else
+		    error ("document: no such symbol `%s'", name.c_str ());
+		}
+	    }
 	}
     }
   else