diff libinterp/corefcn/input.cc @ 20939:b17fda023ca6

maint: Use new C++ archetype in more files. Place input validation first in files. Move declaration of retval down in function to be closer to point of usage. Eliminate else clause after if () error. Use "return ovl()" where it makes sense. * find.cc, gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, givens.cc, graphics.cc, help.cc, hess.cc, hex2num.cc, input.cc, kron.cc, load-path.cc, load-save.cc, lookup.cc, mappers.cc, matrix_type.cc, mgorth.cc, nproc.cc, ordschur.cc, pager.cc, pinv.cc, pr-output.cc, profiler.cc, psi.cc, quad.cc, rcond.cc, regexp.cc, schur.cc, sighandlers.cc, sparse.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symtab.cc, syscalls.cc, sysdep.cc, time.cc, toplev.cc, tril.cc, tsearch.cc, typecast.cc, urlwrite.cc, utils.cc, variables.cc, __delaunayn__.cc, __eigs__.cc, __glpk__.cc, __magick_read__.cc, __osmesa_print__.cc, __voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc, chol.cc, colamd.cc, dmperm.cc, fftw.cc, qr.cc, symbfact.cc, symrcm.cc, ov-bool-mat.cc, ov-cell.cc, ov-class.cc, ov-classdef.cc, ov-fcn-handle.cc, ov-fcn-inline.cc, ov-flt-re-mat.cc, ov-java.cc, ov-null-mat.cc, ov-oncleanup.cc, ov-re-mat.cc, ov-struct.cc, ov-typeinfo.cc, ov-usr-fcn.cc, ov.cc, octave.cc: Use new C++ archetype in more files.
author Rik <rik@octave.org>
date Fri, 18 Dec 2015 15:37:22 -0800
parents 1142cf6abc0d
children 48b2ad5ee801
line wrap: on
line diff
--- a/libinterp/corefcn/input.cc	Fri Dec 18 16:22:53 2015 -0500
+++ b/libinterp/corefcn/input.cc	Fri Dec 18 15:37:22 2015 -0800
@@ -913,8 +913,6 @@
 @seealso{dbstop, dbcont, dbquit}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   if (args.length () > 1)
     print_usage ();
 
@@ -933,7 +931,7 @@
 
   do_keyboard (args);
 
-  return retval;
+  return octave_value_list ();
 }
 
 DEFUN (echo, args, ,
@@ -969,7 +967,7 @@
 {
   octave_value_list retval;
 
-  string_vector argv = args.make_argv ("echo");
+  string_vector argv = args.make_argv ("");
 
   switch (args.length ())
     {
@@ -985,7 +983,7 @@
 
     case 1:
       {
-        std::string arg = argv[1];
+        std::string arg = argv[0];
 
         if (arg == "on")
           Vecho_executing_commands = ECHO_SCRIPTS;
@@ -998,14 +996,14 @@
 
     case 2:
       {
-        std::string arg = argv[1];
+        std::string arg = argv[0];
 
-        if (arg == "on" && argv[2] == "all")
+        if (arg == "on" && argv[1] == "all")
           {
             int tmp = (ECHO_SCRIPTS | ECHO_FUNCTIONS);
             Vecho_executing_commands = tmp;
           }
-        else if (arg == "off" && argv[2] == "all")
+        else if (arg == "off" && argv[1] == "all")
           Vecho_executing_commands = ECHO_OFF;
         else
           print_usage ();
@@ -1017,7 +1015,7 @@
       break;
     }
 
-  return retval;
+  return octave_value_list ();
 }
 
 /*
@@ -1047,7 +1045,7 @@
 %!   echo_executing_commands (state);
 %! end_unwind_protect
 
-%!#test  # FIXME: Uncommend when ug #45209 is fixed
+%!#test  # FIXME: This passes, but produces a lot of onscreen output
 %! state = echo_executing_commands ();
 %! unwind_protect
 %!   echo ("on", "all");
@@ -1087,11 +1085,11 @@
 a feature, not a bug.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   if (args.length () != 1)
     print_usage ();
 
+  octave_value retval;
+
   std::string hint = args(0).string_value ();
 
   int n = 32;
@@ -1173,8 +1171,6 @@
 @seealso{readline_re_read_init_file}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin > 1)
@@ -1189,7 +1185,7 @@
       command_editor::read_init_file (file);
     }
 
-  return retval;
+  return octave_value_list ();
 }
 
 DEFUN (readline_re_read_init_file, args, ,
@@ -1202,14 +1198,12 @@
 @seealso{readline_read_init_file}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   if (args.length () != 0)
     print_usage ();
 
   command_editor::re_read_init_file ();
 
-  return retval;
+  return octave_value_list ();
 }
 
 static int
@@ -1273,8 +1267,6 @@
 @seealso{add_input_event_hook}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2)
@@ -1296,7 +1288,7 @@
   if (input_event_hook_functions.empty ())
     command_editor::remove_event_hook (internal_input_event_hook_fcn);
 
-  return retval;
+  return octave_value_list ();
 }
 
 DEFUN (PS1, args, nargout,
@@ -1442,8 +1434,6 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin > 1)
@@ -1454,7 +1444,7 @@
   else
     Vdrawnow_requested = args(0).bool_value ();
 
-  return retval;
+  return octave_value_list ();
 }
 
 DEFUN (__gud_mode__, args, ,
@@ -1463,19 +1453,19 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
   if (nargin > 1)
     print_usage ();
 
+  octave_value_list retval;
+
   if (nargin == 0)
-    retval = Vgud_mode;
+    retval = ovl (Vgud_mode);
   else
     Vgud_mode = args(0).bool_value ();
 
-  return retval;
+  return retval; 
 }
 
 DEFUN (filemarker, args, nargout,