# HG changeset patch # User jwe # Date 834657178 0 # Node ID 46839fa1fcf3e12d2d1a1bacc4c7f473af57033a # Parent a015ab4392c2736085c05953b417670833041b0d [project @ 1996-06-13 09:12:58 by jwe] diff -r a015ab4392c2 -r 46839fa1fcf3 src/variables.cc --- 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