changeset 19777:67f2c76f9f4d

Remove unnecessary checking of error_state after is_string validation. * data.cc (#NATIVE_REDUCTION, Fcumsum, Fprod, Fsum): Remove if (error_state) check. * debug.cc (Fdbstep): Remove if (error_state) check. * dlmread.cc (Fdlmread): Remove if (error_state) check. * graphics.cc (Fwaitfor): Remove if (error_state) check. * lu.cc (Flu): Remove if (error_state) check. * utils.cc (Ferrno): Remove if (error_state) check. * variables.cc (is_valid_function): Remove if (error_state) check. * fftw.cc (Ffftw): Remove if (error_state) check.
author Rik <rik@octave.org>
date Tue, 17 Feb 2015 17:34:48 -0800
parents 55a4173f1624
children 1687269e31e4
files libinterp/corefcn/data.cc libinterp/corefcn/debug.cc libinterp/corefcn/dlmread.cc libinterp/corefcn/graphics.cc libinterp/corefcn/lu.cc libinterp/corefcn/utils.cc libinterp/corefcn/variables.cc libinterp/dldfcn/fftw.cc
diffstat 8 files changed, 208 insertions(+), 239 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/data.cc	Tue Feb 17 16:24:30 2015 -0800
+++ b/libinterp/corefcn/data.cc	Tue Feb 17 17:34:48 2015 -0800
@@ -904,16 +904,13 @@
     { \
       std::string str = args(nargin - 1).string_value (); \
       \
-      if (! error_state) \
-        { \
-          if (str == "native") \
-            isnative = true; \
-          else if (str == "double") \
-            isdouble = true; \
-          else \
-            error ("sum: unrecognized string argument"); \
-          nargin --; \
-        } \
+      if (str == "native") \
+        isnative = true; \
+      else if (str == "double") \
+        isdouble = true; \
+      else \
+        error ("sum: unrecognized string argument"); \
+      nargin --; \
     } \
   \
   if (nargin == 1 || nargin == 2) \
@@ -1198,16 +1195,13 @@
     {
       std::string str = args(nargin - 1).string_value ();
 
-      if (! error_state)
-        {
-          if (str == "native")
-            isnative = true;
-          else if (str == "double")
-            isdouble = true;
-          else
-            error ("cumsum: unrecognized string argument");
-          nargin --;
-        }
+      if (str == "native")
+        isnative = true;
+      else if (str == "double")
+        isdouble = true;
+      else
+        error ("cumsum: unrecognized string argument");
+      nargin --;
     }
 
   if (error_state)
@@ -1499,16 +1493,13 @@
     {
       std::string str = args(nargin - 1).string_value ();
 
-      if (! error_state)
-        {
-          if (str == "native")
-            isnative = true;
-          else if (str == "double")
-            isdouble = true;
-          else
-            error ("prod: unrecognized type argument '%s'", str.c_str ());
-          nargin --;
-        }
+      if (str == "native")
+        isnative = true;
+      else if (str == "double")
+        isdouble = true;
+      else
+        error ("prod: unrecognized type argument '%s'", str.c_str ());
+      nargin --;
     }
 
   if (error_state)
@@ -2991,18 +2982,15 @@
     {
       std::string str = args(nargin - 1).string_value ();
 
-      if (! error_state)
-        {
-          if (str == "native")
-            isnative = true;
-          else if (str == "double")
-            isdouble = true;
-          else if (str == "extra")
-            isextra = true;
-          else
-            error ("sum: unrecognized type argument '%s'", str.c_str ());
-          nargin --;
-        }
+      if (str == "native")
+        isnative = true;
+      else if (str == "double")
+        isdouble = true;
+      else if (str == "extra")
+        isextra = true;
+      else
+        error ("sum: unrecognized type argument '%s'", str.c_str ());
+      nargin --;
     }
 
   if (error_state)
--- a/libinterp/corefcn/debug.cc	Tue Feb 17 16:24:30 2015 -0800
+++ b/libinterp/corefcn/debug.cc	Tue Feb 17 17:34:48 2015 -0800
@@ -1432,33 +1432,30 @@
             {
               std::string arg = args(0).string_value ();
 
-              if (! error_state)
+              if (arg == "in")
+                {
+                  Vdebugging = false;
+
+                  tree_evaluator::dbstep_flag = -1;
+                }
+              else if (arg == "out")
                 {
-                  if (arg == "in")
-                    {
-                      Vdebugging = false;
+                  Vdebugging = false;
 
-                      tree_evaluator::dbstep_flag = -1;
-                    }
-                  else if (arg == "out")
+                  tree_evaluator::dbstep_flag = -2;
+                }
+              else
+                {
+                  int n = atoi (arg.c_str ());
+
+                  if (n > 0)
                     {
                       Vdebugging = false;
 
-                      tree_evaluator::dbstep_flag = -2;
+                      tree_evaluator::dbstep_flag = n;
                     }
                   else
-                    {
-                      int n = atoi (arg.c_str ());
-
-                      if (n > 0)
-                        {
-                          Vdebugging = false;
-
-                          tree_evaluator::dbstep_flag = n;
-                        }
-                      else
-                        error ("dbstep: invalid argument");
-                    }
+                    error ("dbstep: invalid argument");
                 }
             }
           else
--- a/libinterp/corefcn/dlmread.cc	Tue Feb 17 16:24:30 2015 -0800
+++ b/libinterp/corefcn/dlmread.cc	Tue Feb 17 17:34:48 2015 -0800
@@ -214,8 +214,6 @@
     {
       // File name.
       std::string fname (args(0).string_value ());
-      if (error_state)
-        return retval;
 
       std::string tname = file_ops::tilde_expand (fname);
 
--- a/libinterp/corefcn/graphics.cc	Tue Feb 17 16:24:30 2015 -0800
+++ b/libinterp/corefcn/graphics.cc	Tue Feb 17 17:34:48 2015 -0800
@@ -11635,13 +11635,10 @@
                         {
                           caseless_str s = args(2).string_value ();
 
-                          if (! error_state)
-                            {
-                              if (s.compare ("timeout"))
-                                timeout_index = 2;
-                              else
-                                max_arg_index++;
-                            }
+                          if (s.compare ("timeout"))
+                            timeout_index = 2;
+                          else
+                            max_arg_index++;
                         }
                       else
                         max_arg_index++;
--- a/libinterp/corefcn/lu.cc	Tue Feb 17 16:24:30 2015 -0800
+++ b/libinterp/corefcn/lu.cc	Tue Feb 17 17:34:48 2015 -0800
@@ -162,13 +162,10 @@
         {
           std::string tmp = args(n++).string_value ();
 
-          if (! error_state)
-            {
-              if (tmp.compare ("vector") == 0)
-                vecout = true;
-              else
-                error ("lu: unrecognized string argument");
-            }
+          if (tmp.compare ("vector") == 0)
+            vecout = true;
+          else
+            error ("lu: unrecognized string argument");
         }
       else
         {
--- a/libinterp/corefcn/utils.cc	Tue Feb 17 16:24:30 2015 -0800
+++ b/libinterp/corefcn/utils.cc	Tue Feb 17 17:34:48 2015 -0800
@@ -1035,10 +1035,7 @@
         {
           std::string nm = args(0).string_value ();
 
-          if (! error_state)
-            retval = octave_errno::lookup (nm);
-          else
-            error ("errno: expecting string argument");
+          retval = octave_errno::lookup (nm);
         }
       else
         {
@@ -1047,7 +1044,7 @@
           if (! error_state)
             retval = octave_errno::set (val);
           else
-            error ("errno: expecting integer argument");
+            error ("errno: argument must be string or integer");
         }
     }
   else if (nargin == 0)
--- a/libinterp/corefcn/variables.cc	Tue Feb 17 16:24:30 2015 -0800
+++ b/libinterp/corefcn/variables.cc	Tue Feb 17 17:34:48 2015 -0800
@@ -128,10 +128,7 @@
     {
       fcn_name = arg.string_value ();
 
-      if (! error_state)
-        ans = is_valid_function (fcn_name, warn_for, warn);
-      else if (warn)
-        error ("%s: expecting function name as argument", warn_for.c_str ());
+      ans = is_valid_function (fcn_name, warn_for, warn);
     }
   else if (warn)
     error ("%s: expecting function name as argument", warn_for.c_str ());
--- a/libinterp/dldfcn/fftw.cc	Tue Feb 17 16:24:30 2015 -0800
+++ b/libinterp/dldfcn/fftw.cc	Tue Feb 17 17:34:48 2015 -0800
@@ -144,196 +144,194 @@
   if (args(0).is_string ())
     {
       std::string arg0 = args(0).string_value ();
-      if (!error_state)
+
+      if (arg0 == "planner")
         {
-          if (arg0 == "planner")
+          if (nargin == 2)  //planner setter
             {
-              if (nargin == 2)  //planner setter
+              if (args(1).is_string ())
                 {
-                  if (args(1).is_string ())
+                  // Use STL function to convert to lower case
+                  std::transform (arg0.begin (), arg0.end (), arg0.begin (),
+                                  tolower);
+                  std::string arg1 = args(1).string_value ();
+                  if (!error_state)
                     {
-                      // Use STL function to convert to lower case
-                      std::transform (arg0.begin (), arg0.end (), arg0.begin (),
-                                      tolower);
-                      std::string arg1 = args(1).string_value ();
+                      std::transform (arg1.begin (), arg1.end (),
+                                      arg1.begin (), tolower);
+                      octave_fftw_planner::FftwMethod meth
+                        = octave_fftw_planner::UNKNOWN;
+                      octave_float_fftw_planner::FftwMethod methf
+                        = octave_float_fftw_planner::UNKNOWN;
+
+                      if (arg1 == "estimate")
+                        {
+                          meth = octave_fftw_planner::ESTIMATE;
+                          methf = octave_float_fftw_planner::ESTIMATE;
+                        }
+                      else if (arg1 == "measure")
+                        {
+                          meth = octave_fftw_planner::MEASURE;
+                          methf = octave_float_fftw_planner::MEASURE;
+                        }
+                      else if (arg1 == "patient")
+                        {
+                          meth = octave_fftw_planner::PATIENT;
+                          methf = octave_float_fftw_planner::PATIENT;
+                        }
+                      else if (arg1 == "exhaustive")
+                        {
+                          meth = octave_fftw_planner::EXHAUSTIVE;
+                          methf = octave_float_fftw_planner::EXHAUSTIVE;
+                        }
+                      else if (arg1 == "hybrid")
+                        {
+                          meth = octave_fftw_planner::HYBRID;
+                          methf = octave_float_fftw_planner::HYBRID;
+                        }
+                      else
+                        error ("fftw: unrecognized planner METHOD");
+
                       if (!error_state)
                         {
-                          std::transform (arg1.begin (), arg1.end (),
-                                          arg1.begin (), tolower);
-                          octave_fftw_planner::FftwMethod meth
-                            = octave_fftw_planner::UNKNOWN;
-                          octave_float_fftw_planner::FftwMethod methf
-                            = octave_float_fftw_planner::UNKNOWN;
-
-                          if (arg1 == "estimate")
-                            {
-                              meth = octave_fftw_planner::ESTIMATE;
-                              methf = octave_float_fftw_planner::ESTIMATE;
-                            }
-                          else if (arg1 == "measure")
-                            {
-                              meth = octave_fftw_planner::MEASURE;
-                              methf = octave_float_fftw_planner::MEASURE;
-                            }
-                          else if (arg1 == "patient")
-                            {
-                              meth = octave_fftw_planner::PATIENT;
-                              methf = octave_float_fftw_planner::PATIENT;
-                            }
-                          else if (arg1 == "exhaustive")
-                            {
-                              meth = octave_fftw_planner::EXHAUSTIVE;
-                              methf = octave_float_fftw_planner::EXHAUSTIVE;
-                            }
-                          else if (arg1 == "hybrid")
-                            {
-                              meth = octave_fftw_planner::HYBRID;
-                              methf = octave_float_fftw_planner::HYBRID;
-                            }
-                          else
-                            error ("fftw: unrecognized planner METHOD");
-
-                          if (!error_state)
-                            {
-                              meth = octave_fftw_planner::method (meth);
-                              octave_float_fftw_planner::method (methf);
+                          meth = octave_fftw_planner::method (meth);
+                          octave_float_fftw_planner::method (methf);
 
-                              if (meth == octave_fftw_planner::MEASURE)
-                                retval = octave_value ("measure");
-                              else if (meth == octave_fftw_planner::PATIENT)
-                                retval = octave_value ("patient");
-                              else if (meth == octave_fftw_planner::EXHAUSTIVE)
-                                retval = octave_value ("exhaustive");
-                              else if (meth == octave_fftw_planner::HYBRID)
-                                retval = octave_value ("hybrid");
-                              else
-                                retval = octave_value ("estimate");
-                            }
-                        }
-                    }
-                  else
-                    error ("fftw: planner expects a string value as METHOD");
-                }
-              else //planner getter
-                {
-                  octave_fftw_planner::FftwMethod meth =
-                    octave_fftw_planner::method ();
-
-                  if (meth == octave_fftw_planner::MEASURE)
-                    retval = octave_value ("measure");
-                  else if (meth == octave_fftw_planner::PATIENT)
-                    retval = octave_value ("patient");
-                  else if (meth == octave_fftw_planner::EXHAUSTIVE)
-                    retval = octave_value ("exhaustive");
-                  else if (meth == octave_fftw_planner::HYBRID)
-                    retval = octave_value ("hybrid");
-                  else
-                    retval = octave_value ("estimate");
-                }
-            }
-          else if (arg0 == "dwisdom")
-            {
-              if (nargin == 2)  //dwisdom setter
-                {
-                  if (args(1).is_string ())
-                    {
-                      // Use STL function to convert to lower case
-                      std::transform (arg0.begin (), arg0.end (), arg0.begin (),
-                                      tolower);
-                      std::string arg1 = args(1).string_value ();
-                      if (!error_state)
-                        {
-                          char *str = fftw_export_wisdom_to_string ();
-
-                          if (arg1.length () < 1)
-                            fftw_forget_wisdom ();
-                          else if (! fftw_import_wisdom_from_string (arg1.c_str ()))
-                            error ("fftw: could not import supplied WISDOM");
-
-                          if (!error_state)
-                            retval = octave_value (std::string (str));
-
-                          free (str);
+                          if (meth == octave_fftw_planner::MEASURE)
+                            retval = octave_value ("measure");
+                          else if (meth == octave_fftw_planner::PATIENT)
+                            retval = octave_value ("patient");
+                          else if (meth == octave_fftw_planner::EXHAUSTIVE)
+                            retval = octave_value ("exhaustive");
+                          else if (meth == octave_fftw_planner::HYBRID)
+                            retval = octave_value ("hybrid");
+                          else
+                            retval = octave_value ("estimate");
                         }
                     }
                 }
-              else //dwisdom getter
-                {
-                  char *str = fftw_export_wisdom_to_string ();
-                  retval = octave_value (std::string (str));
-                  free (str);
-                }
+              else
+                error ("fftw: planner expects a string value as METHOD");
             }
-          else if (arg0 == "swisdom")
+          else //planner getter
             {
-              //swisdom uses fftwf_ functions (float), dwisdom fftw_ (real)
-              if (nargin == 2)  //swisdom setter
+              octave_fftw_planner::FftwMethod meth =
+                octave_fftw_planner::method ();
+
+              if (meth == octave_fftw_planner::MEASURE)
+                retval = octave_value ("measure");
+              else if (meth == octave_fftw_planner::PATIENT)
+                retval = octave_value ("patient");
+              else if (meth == octave_fftw_planner::EXHAUSTIVE)
+                retval = octave_value ("exhaustive");
+              else if (meth == octave_fftw_planner::HYBRID)
+                retval = octave_value ("hybrid");
+              else
+                retval = octave_value ("estimate");
+            }
+        }
+      else if (arg0 == "dwisdom")
+        {
+          if (nargin == 2)  //dwisdom setter
+            {
+              if (args(1).is_string ())
                 {
-                  if (args(1).is_string ())
+                  // Use STL function to convert to lower case
+                  std::transform (arg0.begin (), arg0.end (), arg0.begin (),
+                                  tolower);
+                  std::string arg1 = args(1).string_value ();
+                  if (!error_state)
                     {
-                      // Use STL function to convert to lower case
-                      std::transform (arg0.begin (), arg0.end (), arg0.begin (),
-                                      tolower);
-                      std::string arg1 = args(1).string_value ();
-                      if (!error_state)
-                        {
-                          char *str = fftwf_export_wisdom_to_string ();
+                      char *str = fftw_export_wisdom_to_string ();
 
-                          if (arg1.length () < 1)
-                            fftwf_forget_wisdom ();
-                          else if (! fftwf_import_wisdom_from_string (arg1.c_str ()))
-                            error ("fftw: could not import supplied WISDOM");
+                      if (arg1.length () < 1)
+                        fftw_forget_wisdom ();
+                      else if (! fftw_import_wisdom_from_string (arg1.c_str ()))
+                        error ("fftw: could not import supplied WISDOM");
 
-                          if (!error_state)
-                            retval = octave_value (std::string (str));
+                      if (!error_state)
+                        retval = octave_value (std::string (str));
 
-                          free (str);
-                        }
+                      free (str);
                     }
                 }
-              else //swisdom getter
+            }
+          else //dwisdom getter
+            {
+              char *str = fftw_export_wisdom_to_string ();
+              retval = octave_value (std::string (str));
+              free (str);
+            }
+        }
+      else if (arg0 == "swisdom")
+        {
+          //swisdom uses fftwf_ functions (float), dwisdom fftw_ (real)
+          if (nargin == 2)  //swisdom setter
+            {
+              if (args(1).is_string ())
                 {
-                  char *str = fftwf_export_wisdom_to_string ();
-                  retval = octave_value (std::string (str));
-                  free (str);
+                  // Use STL function to convert to lower case
+                  std::transform (arg0.begin (), arg0.end (), arg0.begin (),
+                                  tolower);
+                  std::string arg1 = args(1).string_value ();
+                  if (!error_state)
+                    {
+                      char *str = fftwf_export_wisdom_to_string ();
+
+                      if (arg1.length () < 1)
+                        fftwf_forget_wisdom ();
+                      else if (! fftwf_import_wisdom_from_string (arg1.c_str ()))
+                        error ("fftw: could not import supplied WISDOM");
+
+                      if (!error_state)
+                        retval = octave_value (std::string (str));
+
+                      free (str);
+                    }
                 }
             }
-          else if (arg0 == "threads")
+          else //swisdom getter
             {
-              if (nargin == 2)  //threads setter
+              char *str = fftwf_export_wisdom_to_string ();
+              retval = octave_value (std::string (str));
+              free (str);
+            }
+        }
+      else if (arg0 == "threads")
+        {
+          if (nargin == 2)  //threads setter
+            {
+              if (args(1).is_real_scalar ())
                 {
-                  if (args(1).is_real_scalar ())
+                  int nthreads = args(1).int_value();
+                  if (nthreads >= 1)
                     {
-                      int nthreads = args(1).int_value();
-                      if (nthreads >= 1)
-                        {
 #if defined (HAVE_FFTW3_THREADS)
-                          octave_fftw_planner::threads (nthreads);
+                      octave_fftw_planner::threads (nthreads);
 #else
-                          gripe_disabled_feature ("fftw", "multithreaded FFTW");
+                      gripe_disabled_feature ("fftw", "multithreaded FFTW");
 #endif
 #if defined (HAVE_FFTW3F_THREADS)
-                          octave_float_fftw_planner::threads (nthreads);
+                      octave_float_fftw_planner::threads (nthreads);
 #else
-                          gripe_disabled_feature ("fftw", "multithreaded FFTW");
+                      gripe_disabled_feature ("fftw", "multithreaded FFTW");
 #endif
-                        }
-                      else
-                        error ("fftw: number of threads must be >=1");
                     }
                   else
-                    error ("fftw: setting threads needs one integer argument");
+                    error ("fftw: number of threads must be >=1");
                 }
-              else //threads getter
+              else
+                error ("fftw: setting threads needs one integer argument");
+            }
+          else //threads getter
 #if defined (HAVE_FFTW3_THREADS)
-                retval = octave_value (octave_fftw_planner::threads());
+            retval = octave_value (octave_fftw_planner::threads());
 #else
-                retval = 1;
+            retval = 1;
 #endif
-            }
-          else
-            error ("fftw: unrecognized argument");
         }
+      else
+        error ("fftw: unrecognized argument");
     }
   else
     error ("fftw: unrecognized argument");