diff libinterp/corefcn/sysdep.cc @ 20617:ba2b07c13913

use new string_value method to handle value extraction errors * __dispatch__.cc, balance.cc, colloc.cc, conv2.cc, data.cc, debug.cc, graphics.cc, input.cc, matrix_type.cc, oct-hist.cc, schur.cc, spparms.cc, symtab.cc, sysdep.cc, toplev.cc, utils.cc: Use new string_value method.
author John W. Eaton <jwe@octave.org>
date Fri, 09 Oct 2015 10:06:39 -0400
parents f90c8372b7ba
children
line wrap: on
line diff
--- a/libinterp/corefcn/sysdep.cc	Thu Oct 08 19:00:51 2015 -0400
+++ b/libinterp/corefcn/sysdep.cc	Fri Oct 09 10:06:39 2015 -0400
@@ -195,27 +195,22 @@
 
   if (args.length () == 1)
     {
-      std::string file = args(0).string_value ();
+      std::string file = args(0).string_value ("__open_with_system_app__: argument must be a file name");
 
-      if (! error_state)
-        {
 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
-          HINSTANCE status = ShellExecute (0, 0, file.c_str (), 0, 0,
-                                           SW_SHOWNORMAL);
+      HINSTANCE status = ShellExecute (0, 0, file.c_str (), 0, 0,
+                                       SW_SHOWNORMAL);
 
-          // ShellExecute returns a value greater than 32 if successful.
-          retval = (reinterpret_cast<ptrdiff_t> (status) > 32);
+      // ShellExecute returns a value greater than 32 if successful.
+      retval = (reinterpret_cast<ptrdiff_t> (status) > 32);
 #else
-          octave_value_list tmp
-            = Fsystem (ovl ("xdg-open " + file + " 2> /dev/null",
-                            false, "async"),
-                       1);
+      octave_value_list tmp
+        = Fsystem (ovl ("xdg-open " + file + " 2> /dev/null",
+                        false, "async"),
+                   1);
 
-          retval = (tmp(0).double_value () == 0);
+      retval = (tmp(0).double_value () == 0);
 #endif
-        }
-      else
-        error ("__open_with_system_app__: argument must be a file name");
     }
   else
     print_usage ();
@@ -650,20 +645,13 @@
 
   if (nargin == 2 || nargin == 1)
     {
-      if (args(0).is_string ())
-        {
-          std::string var = args(0).string_value ();
-
-          std::string val = (nargin == 2
-                             ? args(1).string_value () : std::string ());
+      std::string var = args(0).string_value ("setenv: VAR must be a string");
 
-          if (! error_state)
-            octave_env::putenv (var, val);
-          else
-            error ("setenv: VALUE must be a string");
-        }
-      else
-        error ("setenv: VAR must be a string");
+      std::string val = (nargin == 2
+                         ? args(1).string_value ("setenv: VALUE must be a string")
+                         : std::string ());
+
+      octave_env::putenv (var, val);
     }
   else
     print_usage ();