changeset 11215:8b2a47a99701

help: print message if function not found
author John W. Eaton <jwe@octave.org>
date Tue, 09 Nov 2010 14:52:28 -0500
parents 7f19b2b6e093
children 5036b0ff9597
files scripts/ChangeLog scripts/help/help.m scripts/miscellaneous/unimplemented.m
diffstat 3 files changed, 30 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Tue Nov 09 11:32:30 2010 -0800
+++ b/scripts/ChangeLog	Tue Nov 09 14:52:28 2010 -0500
@@ -1,3 +1,10 @@
+2010-11-09  John W. Eaton  <jwe@octave.org>
+
+	* help/help.m: Call missing_function_hook with output argument
+	and print message here.
+	* miscellaneous/unimplemented.m: Return message if nargout > 0.
+	Fixes bug #31597.
+
 2010-11-08  Ben Abbott <bpabbott@mac.com>
 
 	* plot/__go_draw_axes__.m: Check for z/y/zdata before converting
--- a/scripts/help/help.m	Tue Nov 09 11:32:30 2010 -0800
+++ b/scripts/help/help.m	Tue Nov 09 14:52:28 2010 -0500
@@ -129,7 +129,13 @@
   if (found)
     puts (__additional_help_message__ ());
   else
-    feval (missing_function_hook, name);
+    msg = feval (missing_function_hook, name);
+
+    if (isempty (msg))
+      msg = sprintf ("`%s' not found", name);
+    endif
+
+    error ("help: %s\n", msg);
   endif
 
 endfunction
--- a/scripts/miscellaneous/unimplemented.m	Tue Nov 09 11:32:30 2010 -0800
+++ b/scripts/miscellaneous/unimplemented.m	Tue Nov 09 14:52:28 2010 -0500
@@ -22,12 +22,14 @@
 ## Undocumented internal function.
 ## @end deftypefn
 
-function unimplemented (fcn)
+function txt = unimplemented (fcn)
+
+  is_matlab_function = true;
 
   ## Some smarter cases, add more as needed.
   switch (fcn)
 
-  case "quad2d"
+    case "quad2d"
     txt = ["quad2d is not implemented.  Consider using dblquad."];
 
   case "gsvd"
@@ -47,21 +49,23 @@
   
   otherwise
     if (ismember (fcn, missing_functions ()))
-
-      ## The default case.
-
-      txt = sprintf ("The %s function is not yet implemented in Octave.", fcn);
-
+      txt = sprintf ("the `%s' function is not yet implemented in Octave", fcn);
     else
-      return;
+      is_matlab_function = false;
+      txt = "";
     endif
   endswitch
 
-  txt = [txt, "\n\n@noindent\nPlease read ",...
-  "@url{http://www.octave.org/missing.html} ",...
-  "to find out how you can help with contributing missing functionality."];
+  if (is_matlab_function)
+    txt = [txt, "\n\n@noindent\nPlease read ",...
+           "@url{http://www.octave.org/missing.html} to learn how ",...
+           "you can contribute missing functionality."];
+    txt = __makeinfo__ (txt);
+  endif
 
-  warning ("Octave:missing-function",["\n", __makeinfo__(txt)]);
+  if (nargout == 0)
+    warning ("Octave:missing-function", "%s", txt);
+  endif
 
 endfunction