# HG changeset patch # User John W. Eaton # Date 1233785192 18000 # Node ID 2a49c32d43228358677d817d4052023fea2b74e7 # Parent d7128ae51e44f4f5547e7481f3f5e3cb9f4a34ad allow help to work with files containing only comments diff -r d7128ae51e44 -r 2a49c32d4322 scripts/ChangeLog --- a/scripts/ChangeLog Wed Feb 04 15:53:24 2009 -0500 +++ b/scripts/ChangeLog Wed Feb 04 17:06:32 2009 -0500 @@ -1,3 +1,7 @@ +2009-02-04 John W. Eaton + + * help/which.m: Still print something sensible if type is empty. + 2009-02-04 Soren Hauberg Thomas Treichl diff -r d7128ae51e44 -r 2a49c32d4322 scripts/help/which.m --- a/scripts/help/which.m Wed Feb 04 15:53:24 2009 -0500 +++ b/scripts/help/which.m Wed Feb 04 17:06:32 2009 -0500 @@ -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 diff -r d7128ae51e44 -r 2a49c32d4322 src/ChangeLog --- a/src/ChangeLog Wed Feb 04 15:53:24 2009 -0500 +++ b/src/ChangeLog Wed Feb 04 17:06:32 2009 -0500 @@ -1,5 +1,9 @@ 2009-02-04 John W. Eaton + * 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 diff -r d7128ae51e44 -r 2a49c32d4322 src/help.cc --- a/src/help.cc Wed Feb 04 15:53:24 2009 -0500 +++ b/src/help.cc Wed Feb 04 17:06:32 2009 -0500 @@ -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; }