diff libinterp/octave-value/ov-fcn-handle.cc @ 20615:729a85dafba8

use new string_value method to handle value extraction errors * ov-class.cc, ov-classdef.cc, ov-fcn-handle.cc, ov-fcn-inline.cc, ov.cc, pt-idx.cc: Use new string_value method.
author John W. Eaton <jwe@octave.org>
date Thu, 08 Oct 2015 17:55:57 -0400
parents f90c8372b7ba
children f9c991dc5c1a
line wrap: on
line diff
--- a/libinterp/octave-value/ov-fcn-handle.cc	Thu Oct 08 18:15:56 2015 -0400
+++ b/libinterp/octave-value/ov-fcn-handle.cc	Thu Oct 08 17:55:57 2015 -0400
@@ -1859,23 +1859,19 @@
 
   if (nargin == 1 || nargin == 2)
     {
-      if (args(0).is_string ())
+      std::string nm = args(0).string_value ("str2func: FCN_NAME must be a string");
+
+      if (nm[0] == '@')
         {
-          std::string nm = args(0).string_value ();
-          if (nm[0] == '@')
-            {
-              int parse_status;
-              octave_value anon_fcn_handle =
-                eval_string (nm, true, parse_status);
+          int parse_status;
+          octave_value anon_fcn_handle =
+            eval_string (nm, true, parse_status);
 
-              if (parse_status == 0)
-                retval = anon_fcn_handle;
-            }
-          else
-            retval = make_fcn_handle (nm, nargin != 2);
+          if (parse_status == 0)
+            retval = anon_fcn_handle;
         }
       else
-        error ("str2func: FCN_NAME must be a string");
+        retval = make_fcn_handle (nm, nargin != 2);
     }
   else
     print_usage ();