From bug-request at octave dot org Tue Apr 4 16:57:38 2006 Subject: Re: lookfor bug From: David Bateman To: "John W. Eaton" CC: Keith Goodman , octave bug mailing list Date: Tue, 04 Apr 2006 23:52:58 +0200 John W. Eaton wrote: > On 27-Mar-2006, Keith Goodman wrote: > > | What is going on here (noindent)? > | > | >> lookfor sum > | WIFCONTINUED Given STATUS from a call to `waitpid', return > | true if the child process was resumed by delivery of `SIGCONT'. > | builtin:cumsum Cumulative sum of elements along dimension DIM. > | builtin:sum Sum of elements along dimension DIM. > | builtin:sumsq Sum of squares of elements along dimension DIM. > | cumsum at noindent > | sum at noindent > | sumsq at noindent > > I did a little investigating and it seems that the code in the function > first_help_sentence in help.cc is not handling the help text for > overloaded functions correctly. It seems to be mistaking the > > at noindent > Overloaded function: > > as the beginning of the help text. I'm not sure of the fix as I don't > quite follow the intent of all the code in Flookfor and > first_help_sentence. > > jwe > > > John, Now that we have regexp and pcre in octave, perhaps this code can be vastly simplified. The intent of the first_help_sentence is to strip the leading function header lines with a few simple regexps, fine the first "." and join all the remaining text upto the first "." and call it the first sentence. However, the problem for this bug isn't in first_help_sentence, but rather in the fact the Fdispatch renames the function f in the symbol table to builtin:f and creates a new symbol in the symbol table with the name of the overloaded function, and adds the helpstring with you guessed it sr->document ("\n\n at noindent\nOverloaded function:\n"); In fact Flookfor should exclude should functions as they are only there as an entry point for the other overloaded functions. The easiest way to do that is to add a check on the class name like 'sr->class_name() != "overloaded function"'. I can't easily test the attached patch, but I think it should work to correct this problem.. I also cut and paste from a terminal window so I hope it applies correct. If not, hey its only one line to fix by hand... D. Index: src/help.cc =================================================================== RCS file: /usr/local/cvsroot/octave/src/help.cc,v retrieving revision 1.151 diff -c -r1.151 help.cc *** src/help.cc 15 Mar 2006 21:27:35 -0000 1.151 --- src/help.cc 4 Apr 2006 21:47:30 -0000 *************** *** 1651,1657 **** OCTAVE_QUIT; symbol_record *sr = lookup_by_name (name, 0); ! if (sr && sr->is_defined ()) { std::string h = sr->help (); --- 1651,1658 ---- OCTAVE_QUIT; symbol_record *sr = lookup_by_name (name, 0); ! if (sr && sr->is_defined () && ! sr->class_name() != "overloaded function") { std::string h = sr->help (); ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------