Mercurial > hg > octave-lojdl
changeset 6243:7924a9086c08
[project @ 2007-01-17 21:47:50 by jwe]
author | jwe |
---|---|
date | Wed, 17 Jan 2007 21:47:51 +0000 |
parents | 64bad7c6a607 |
children | 8cab253171b6 |
files | src/ChangeLog src/help.cc src/help.h |
diffstat | 3 files changed, 117 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2007-01-17 John W. Eaton <jwe@octave.org> + + * help.cc (help_from_file, help_from_symbol_table, help_from_list): + Rewrite using raw_ versions. + +2007-01-17 David Bateman <dbateman@free.fr> + + * help.cc (raw_help, raw_help_from_file, + raw_help_from_symbol_table, raw_help_from_list): New functions. + * help.h (raw_help): Provide decl. + 2007-01-16 John W. Eaton <jwe@octave.org> * DLD-FUNCTIONS/__pchip_deriv__.cc: Fix dpchim decl for --enable-64.
--- a/src/help.cc +++ b/src/help.cc @@ -889,8 +889,8 @@ } static bool -help_from_list (std::ostream& os, const help_list *list, - const std::string& nm, int usage, bool& symbol_found) +raw_help_from_list (const help_list *list, const std::string& nm, + std::string& h, bool& symbol_found) { bool retval = false; @@ -902,21 +902,11 @@ { symbol_found = true; - std::string h = list->help; + h = list->help; if (h.length () > 0) - { - if (usage) - os << "\nusage: "; - else - os << "\n*** " << nm << ":\n\n"; + retval = true; - display_help_text (os, h); - - os << "\n"; - - retval = true; - } break; } list++; @@ -925,6 +915,34 @@ return retval;; } +static bool +help_from_list (std::ostream& os, const help_list *list, + const std::string& nm, int usage, bool& symbol_found) +{ + bool retval = false; + + std::string h; + + if (raw_help_from_list (list, nm, h, symbol_found)) + { + if (h.length () > 0) + { + if (usage) + os << "\nusage: "; + else + os << "\n*** " << nm << ":\n\n"; + + display_help_text (os, h); + + os << "\n"; + + retval = true; + } + } + + return retval; +} + std::string extract_help_from_dispatch (const std::string& nm) { @@ -981,8 +999,8 @@ } static bool -help_from_symbol_table (std::ostream& os, const std::string& nm, - bool& symbol_found) +raw_help_from_symbol_table (const std::string& nm, std::string& h, + std::string& w, bool& symbol_found) { bool retval = false; @@ -992,18 +1010,41 @@ { symbol_found = true; - std::string h = sym_rec->help (); + h = sym_rec->help (); + + if (h.length () > 0) + { + w = sym_rec->which (); + + retval = true; + } + } + return retval; +} + +static bool +help_from_symbol_table (std::ostream& os, const std::string& nm, + bool& symbol_found) +{ + bool retval = false; + + std::string h; + std::string w; + + if (raw_help_from_symbol_table (nm, h, w, symbol_found)) + { if (h.length () > 0) { h = extract_help_from_dispatch (nm) + h; + display_help_text (os, h); - if (! Vsuppress_verbose_help_message) - { - sym_rec->which (os); - os << "\n"; - } + + if (w.length () > 0 && ! Vsuppress_verbose_help_message) + os << w << "\n"; + os << "\n"; + retval = true; } } @@ -1012,25 +1053,59 @@ } static bool +raw_help_from_file (const std::string& nm, std::string& h, + std::string& file, bool& symbol_found) +{ + bool retval = false; + + h = get_help_from_file (nm, symbol_found, file); + + if (h.length () > 0) + retval = true; + + return retval; +} + +static bool help_from_file (std::ostream& os, const std::string& nm, bool& symbol_found) { bool retval = false; + std::string h; std::string file; - std::string h = get_help_from_file (nm, symbol_found, file); - - if (h.length () > 0) + if (raw_help_from_file (nm, h, file, symbol_found)) { - os << nm << " is the file " << file << "\n\n"; - display_help_text (os, h); - os << "\n"; - retval = true; + if (h.length () > 0) + { + os << nm << " is the file " << file << "\n\n"; + + display_help_text (os, h); + + os << "\n"; + + retval = true; + } } return retval; } +std::string +raw_help (const std::string& nm, bool &symbol_found) +{ + std::string h; + std::string w; + std::string f; + + (raw_help_from_list (operator_help (), nm, h, symbol_found) + || raw_help_from_list (keyword_help (), nm, h, symbol_found) + || raw_help_from_symbol_table (nm, h, w, symbol_found) + || raw_help_from_file (nm, h, f, symbol_found)); + + return h; +} + static void builtin_help (int argc, const string_vector& argv) {