Mercurial > octave
changeset 21878:67e51c889f34
Silence errors from __have_gnuplot__ when gnuplot_binary is not found
* __init_gnuplot__.cc (have_gnuplot_binary): Add more checks to silence
distracting error messages if gnuplot_binary.m is not found or if an
unexpected value is returned.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Sun, 12 Jun 2016 13:45:23 -0700 |
parents | dc0347131364 |
children | 1315aa0ca466 |
files | libinterp/dldfcn/__init_gnuplot__.cc |
diffstat | 1 files changed, 25 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/dldfcn/__init_gnuplot__.cc Sun Jun 12 13:31:56 2016 -0700 +++ b/libinterp/dldfcn/__init_gnuplot__.cc Sun Jun 12 13:45:23 2016 -0700 @@ -171,25 +171,38 @@ { const std::string exeext = octave::build_env::EXEEXT; const std::string path = octave::sys::env::getenv ("PATH"); + bool retval = false; - octave_value_list tmp = feval ("gnuplot_binary", octave_value_list ()); - std::string gnuplot_binary = tmp(0).string_value (); + try + { + octave_value_list tmp = feval ("gnuplot_binary", octave_value_list ()); - string_vector args (gnuplot_binary); - std::string gnuplot_path = search_path_for_file (path, args); + if (tmp(0).is_string ()) + { + std::string gnuplot_binary = tmp(0).string_value (); + + string_vector args (gnuplot_binary); + std::string gnuplot_path = search_path_for_file (path, args); + + octave::sys::file_stat fs (gnuplot_path); - octave::sys::file_stat fs (gnuplot_path); + if (! fs.exists () && ! exeext.empty ()) + { + args[0] += exeext; + + gnuplot_path = search_path_for_file (path, args); - if (! fs.exists () && ! exeext.empty ()) + fs = octave::sys::file_stat (gnuplot_path); + } + + retval = fs.exists (); + } + } + catch (octave_execution_exception&) { - args[0] += exeext; - - gnuplot_path = search_path_for_file (path, args); - - fs = octave::sys::file_stat (gnuplot_path); } - return fs.exists (); + return retval; } // Initialize the gnuplot graphics toolkit.