changeset 31603:23520a50d74d stable

maint: Review C++ files for style and coding conventions. * __ftp__.cc (F__ftp_cwd__, F__ftp_mget__), __isprimelarge__.cc (F__isprimelarge__, F__pollardrho__), debug.cc (Fdbclear), file-io.cc (Ftempdir): Don't bother to define nargin if it is used only once in function. Instead, just call args.length () for the one instance. * data.cc (fill_matrix): Eliminate useless break statement after error() which throws exception. * qr.cc (Fqr), __ode15__.cc (IDA::integrate, IDA::event, IDA::interpolate, IDA::outputfun): Use true or false rather than 0 or 1 when assigning to bool variables. maint: Review C++ files for style and coding conventions.
author Rik <rik@octave.org>
date Wed, 30 Nov 2022 20:27:16 -0800
parents 132547cc1ab2
children 9ecc95d840ca e88a07dec498
files libinterp/corefcn/__ftp__.cc libinterp/corefcn/__isprimelarge__.cc libinterp/corefcn/data.cc libinterp/corefcn/debug.cc libinterp/corefcn/file-io.cc libinterp/corefcn/qr.cc libinterp/dldfcn/__ode15__.cc
diffstat 7 files changed, 12 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/__ftp__.cc	Thu Dec 01 15:00:07 2022 -0500
+++ b/libinterp/corefcn/__ftp__.cc	Wed Nov 30 20:27:16 2022 -0800
@@ -102,10 +102,8 @@
 Undocumented internal function
 @end deftypefn */)
 {
-  int nargin = args.length ();
-
   std::string path = "";
-  if (nargin > 1)
+  if (args.length () > 1)
     path = args(1).xstring_value ("__ftp_cwd__: PATH must be a string");
 
   url_handle_manager& uhm = interp.get_url_handle_manager ();
@@ -415,13 +413,11 @@
 Undocumented internal function
 @end deftypefn */)
 {
-  int nargin = args.length ();
-
   std::string file = args(1).xstring_value ("__ftp_mget__: PATTERN must be a string");
 
   std::string target;
 
-  if (nargin == 3 && ! args(2).isempty ())
+  if (args.length () == 3 && ! args(2).isempty ())
     target = args(2).xstring_value ("__ftp_mget__: TARGET must be a string")
              + sys::file_ops::dir_sep_str ();
 
--- a/libinterp/corefcn/__isprimelarge__.cc	Thu Dec 01 15:00:07 2022 -0500
+++ b/libinterp/corefcn/__isprimelarge__.cc	Wed Nov 30 20:27:16 2022 -0800
@@ -155,8 +155,7 @@
 @seealso{isprime, factor}
 @end deftypefn */)
 {
-  int nargin = args.length ();
-  if (nargin != 1)
+  if (args.length () != 1)
     print_usage ();
 
   // This function is intended for internal use by isprime.m,
@@ -260,8 +259,7 @@
 @seealso{isprime, factor}
 @end deftypefn */)
 {
-  int nargin = args.length ();
-  if (nargin != 1)
+  if (args.length () != 1)
     print_usage ();
 
   octave_uint64 inp = args(0).xuint64_scalar_value
--- a/libinterp/corefcn/data.cc	Thu Dec 01 15:00:07 2022 -0500
+++ b/libinterp/corefcn/data.cc	Wed Nov 30 20:27:16 2022 -0800
@@ -4189,7 +4189,6 @@
         default:
           // FIXME: It shouldn't be possible to ever reach this.
           error ("%s: invalid class name for sparse", fcn);
-          break;
         }
 
       return retval;
--- a/libinterp/corefcn/debug.cc	Thu Dec 01 15:00:07 2022 -0500
+++ b/libinterp/corefcn/debug.cc	Wed Nov 30 20:27:16 2022 -0800
@@ -302,8 +302,6 @@
   octave::bp_table::bp_lines lines;
   std::string dummy;             // "if" condition -- only used for dbstop
 
-  int nargin = args.length ();
-
   octave::tree_evaluator& tw = interp.get_evaluator ();
 
   octave::bp_table& bptab = tw.get_bp_table ();
@@ -311,7 +309,7 @@
   bptab.parse_dbfunction_params ("dbclear", args, symbol_name, class_name,
                                  lines, dummy);
 
-  if (nargin == 1 && symbol_name == "all")
+  if (args.length () == 1 && symbol_name == "all")
     {
       bptab.remove_all_breakpoints ();
       bptab.dbclear_all_signals ();
--- a/libinterp/corefcn/file-io.cc	Thu Dec 01 15:00:07 2022 -0500
+++ b/libinterp/corefcn/file-io.cc	Wed Nov 30 20:27:16 2022 -0800
@@ -2903,9 +2903,7 @@
 @seealso{P_tmpdir, tempname, mkstemp, tmpfile}
 @end deftypefn */)
 {
-  int nargin = args.length ();
-
-  if (nargin > 0)
+  if (args.length () > 0)
     print_usage ();
 
   std::string tmpdir = sys::env::get_temp_directory ();
--- a/libinterp/corefcn/qr.cc	Thu Dec 01 15:00:07 2022 -0500
+++ b/libinterp/corefcn/qr.cc	Wed Nov 30 20:27:16 2022 -0800
@@ -321,8 +321,8 @@
 
   bool economy = false;
   bool is_cmplx = false;
-  bool have_b = 0;
-  bool vector_p = 0;
+  bool have_b = false;
+  bool vector_p = false;
 
   if (arg.iscomplex ())
     is_cmplx = true;
--- a/libinterp/dldfcn/__ode15__.cc	Thu Dec 01 15:00:07 2022 -0500
+++ b/libinterp/dldfcn/__ode15__.cc	Wed Nov 30 20:27:16 2022 -0800
@@ -633,7 +633,7 @@
     ColumnVector ie, te, oldval, oldisterminal, olddir;
     Matrix output, ye;
     octave_idx_type cont = 0, temp = 0;
-    bool status = 0;
+    bool status = false;
     std::string string = "";
     ColumnVector yold = y;
 
@@ -800,7 +800,7 @@
               ColumnVector& yold,
               const octave_idx_type num_event_args)
   {
-    bool status = 0;
+    bool status = false;
 
     octave_value_list args;
     if (num_event_args == 2)
@@ -915,7 +915,7 @@
                     const octave_idx_type num_event_args)
   {
     realtype h = 0, tcur = 0;
-    bool status = 0;
+    bool status = false;
 
     N_Vector dky = N_VNew_Serial (m_num OCTAVE_SUNCONTEXT);
 
@@ -978,7 +978,7 @@
                   realtype tend, ColumnVector& outputsel,
                   const std::string& flag)
   {
-    bool status = 0;
+    bool status = false;
 
     octave_value_list output;
     output(2) = flag;