diff libinterp/corefcn/tril.cc @ 20812:d9ca869ca124

maint: Clean-up more instances of print_usage(). * mk-opts.pl: Fix script that generates *-opt.cc files to put print_usage() first. * __ilu__.cc (F__ilutp__): Don't declare and initialize multiple comma separated variables. * __lin_interpn__.cc (F__lin_interpn__): Eliminate extra spaces in if conditional. * dasrt.cc (Fdasrt): Declare variables only as needed, in this case, after input validation has succeeded. * file-io.cc (Frewind): Declare variables after input validation succeeds. * file-io.cc (Ftempname): Rename variable len to nargin to match rest of code. * gammainc.cc (Fgammainc): Put nargin checking first in function. * hex2num.cc (Fhex2num, Fnum2hex): Declare "octave_value retval;" first in function to match rest of Octave code base. * load-path.cc (Frmpath): Re-phrase comment. * lu.cc (Flu): Declare variables after input validation succeeds. Use space after ! operator. * lu.cc (Fluupdate): Place octave_value_list declaration first in function. Declare variables after input validation succeeds. * matrix_type.cc (Fmatrix_type): Place octave_value declaration first in function. * tril.cc (do_trilu): Move nargin checking higher in function. * utils.cc (Fdir_in_loadpath): Declare variables after input validation succeeds. * __glpk__.cc (F__glpk__): Rename variable nrhs to nargin to match rest of code base. * __magick_read__.cc (F__magick_ping__, F__magick_formats__): Add newline to space out code for readability. * __osmesa_print__.cc (F__osmesa_print__): Use DeMorgan's Law to simplify nargin validation. * audiodevinfo.cc (F__recorder_record__): Correct indentation. * chol.cc (Fcholinsert, Fcholdelete, Fcholshift): Place octave_value_list declaration first in function. * dmperm.cc (Fdmperm, Fsprank): Place octave_value_list declaration first in function. * qr.cc (Fqrupdate, Fqrinsert, Fqrdelete, Fqrshift): Place octave_value_list declaration first in function. * lex.ll (Fiskeyword): Rewrite function to use modern syntax. Add BIST tests for special words "get", "set". Add BIST tests for input validation.
author Rik <rik@octave.org>
date Sat, 05 Dec 2015 15:59:22 -0800
parents fb128aafc322
children 35241c4b696c
line wrap: on
line diff
--- a/libinterp/corefcn/tril.cc	Sat Dec 05 15:10:49 2015 -0800
+++ b/libinterp/corefcn/tril.cc	Sat Dec 05 15:59:22 2015 -0800
@@ -189,24 +189,25 @@
 do_trilu (const std::string& name,
           const octave_value_list& args)
 {
-  bool lower = name == "tril";
+  bool lower = (name == "tril");
 
   octave_value retval;
   int nargin = args.length ();
   octave_idx_type k = 0;
   bool pack = false;
+
   if (nargin >= 2 && args(nargin-1).is_string ())
     {
       pack = args(nargin-1).string_value () == "pack";
       nargin--;
     }
 
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
   if (nargin == 2)
     k = args(1).int_value (true);
 
-  if (nargin < 1 || nargin > 2)
-    print_usage ();
-
   octave_value arg = args(0);
 
   dim_vector dims = arg.dims ();