Mercurial > hg > octave-lojdl
changeset 8044:faf0abc5fd51
handle errors in calls to help, type, and which
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 20 Aug 2008 15:14:54 -0400 |
parents | 30d15ab0ce01 |
children | 24701aa75ecb |
files | src/ChangeLog src/help.cc |
diffstat | 2 files changed, 52 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2008-08-20 John W. Eaton <jwe@octave.org> + + * help.cc (builtin_help): Go to next symbol name on error. + (do_type, do_which): Omit separate path search for files. + (help_from_symbol_table): Only insert Texinfo markup if it looks + like the help message is already in Texinfo. + 2008-08-19 David Bateman <dbateman@free.fr> * load-path.cc (load-path::do_find_dir (const std:string&) const)):
--- a/src/help.cc +++ b/src/help.cc @@ -979,7 +979,17 @@ { if (h.length () > 0) { - h += "\n\n@noindent\n" + symbol_table::help_for_dispatch (nm); + std::string dispatch_help = symbol_table::help_for_dispatch (nm); + + if (! dispatch_help.empty ()) + { + size_t pos = 0; + + std::string pfx = looks_like_texinfo (h, pos) + ? std::string ("\n\n@noindent\n") : std::string ("\n\n"); + + h += pfx + dispatch_help; + } display_help_text (os, h); @@ -1094,9 +1104,23 @@ if (help_from_symbol_table (octave_stdout, argv[i], symbol_found)) continue; + if (error_state) + { + octave_stdout << "\n"; + error_state = 0; + continue; + } + if (help_from_file (octave_stdout, argv[i], symbol_found)) continue; + if (error_state) + { + octave_stdout << "\n"; + error_state = 0; + continue; + } + if (symbol_found) octave_stdout << "\nhelp: `" << argv[i] << "' is not documented\n"; @@ -1104,7 +1128,7 @@ octave_stdout << "\nhelp: `" << argv[i] << "' not found\n"; } - + additional_help_message (octave_stdout); } @@ -1203,10 +1227,12 @@ os << name << " is a built-in function" << std::endl; else if (fcn->is_dld_function () || fcn->is_mex_function ()) os << name - << " is a dyanmically loaded function from the file\n" + << " is a dyanmically loaded function from the file\n" << fn << std::endl; else if (pr_orig_txt && ! fn.empty ()) - display_file (os, name, fn, "function", pr_type_info, quiet); + display_file (os, name, fn, + val.is_user_script () ? "script" : "function", + pr_type_info, quiet); else { if (pr_type_info && ! quiet) @@ -1218,7 +1244,11 @@ if (fn.empty ()) os << " is a command-line function:\n\n"; else - os << " is a function defined from the file\n" + os << " is a " + << (val.is_user_script () + ? std::string ("script") + : std::string ("function")) + << " defined from the file\n" << fn << ":\n\n"; } } @@ -1229,15 +1259,6 @@ } } } - else - { - std::string fn = fcn_file_in_path (name); - - if (! fn.empty ()) - display_file (os, name, fn, "script", pr_type_info, quiet); - else - error ("type: `%s' undefined", name.c_str ()); - } } } @@ -1313,6 +1334,8 @@ std::string do_which (const std::string& name) { + std::string retval; + octave_value val = symbol_table::find_function (name); if (val.is_defined ()) @@ -1323,14 +1346,14 @@ { std::string fn = fcn->fcn_file_name (); - return fn.empty () + retval = fn.empty () ? (fcn->is_user_function () ? "command-line function" : "built-in function") : fn; } } - return fcn_file_in_path (name); + return retval; } static void @@ -1356,21 +1379,14 @@ desc = "is a built-in function"; } else - desc = "is the function from the file " + desc; + desc = "is the " + + (val.is_user_script () + ? std::string ("script") : std::string ("function")) + + " from the file " + desc; } + + os << "which: `" << name << "' " << desc << std::endl; } - - if (desc.empty ()) - { - std::string fn = fcn_file_in_path (name); - - if (! fn.empty ()) - desc = "is the script file " + fn; - else - desc = "is undefined"; - } - - os << "which: `" << name << "' " << desc << std::endl; } DEFCMD (which, args, nargout,