Mercurial > hg > octave-lyh
changeset 8672:2a49c32d4322
allow help to work with files containing only comments
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 04 Feb 2009 17:06:32 -0500 |
parents | d7128ae51e44 |
children | 9e0f0a7bf858 |
files | scripts/ChangeLog scripts/help/which.m src/ChangeLog src/help.cc |
diffstat | 4 files changed, 32 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2009-02-04 John W. Eaton <jwe@octave.org> + + * help/which.m: Still print something sensible if type is empty. + 2009-02-04 Soren Hauberg <hauberg@gmail.com> Thomas Treichl <Thomas.Treichl@gmx.net>
--- a/scripts/help/which.m +++ b/scripts/help/which.m @@ -31,11 +31,18 @@ if (nargout == 0) for i = 1:nargin if (isempty (m(i).file)) - printf ("`%s' is a %s function\n", - m(i).name, m(i).type); + if (! isempty (m(i).type)) + printf ("`%s' is a %s function\n", + m(i).name, m(i).type); + endif else - printf ("`%s' is a %s from the file %s\n", - m(i).name, m(i).type, m(i).file); + if (isempty (m(i).type)) + printf ("`%s' is the file %s\n", + m(i).name, m(i).file); + else + printf ("`%s' is a %s from the file %s\n", + m(i).name, m(i).type, m(i).file); + endif endif endfor else
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2009-02-04 John W. Eaton <jwe@octave.org> + * help.cc (do_which): If NAME is not in the symbol table, look for + a function file in the load path. + (raw_help_from_file): Unwind-protect and set reading_script_file. + * pt-loop.h, pt-loop.cc (evaluating_looping_command): Delete global variable and all uses. * parse.y, parse.h (evaluating_function_body): Delete global
--- a/src/help.cc +++ b/src/help.cc @@ -66,6 +66,7 @@ #include "symtab.h" #include "syswait.h" #include "toplev.h" +#include "unwind-prot.h" #include "utils.h" #include "variables.h" #include "version.h" @@ -652,8 +653,14 @@ { bool retval = false; + // FIXME -- this is a bit of a kluge... + unwind_protect_bool (reading_script_file); + reading_script_file = true; + h = get_help_from_file (nm, symbol_found, file); + unwind_protect::run (); + if (h.length () > 0) retval = true; @@ -816,6 +823,12 @@ ? std::string ("script") : std::string ("function"); } } + else + { + // We might find a file that contains only a doc string. + + file = load_path::find_fcn_file (name); + } return file; }