Mercurial > octave
changeset 22421:d6c1da692e59
Backed out changeset 08aa03dfb00e
This changeset can cause trouble like this:
>> gnuplot_binary("/usr/bin/gnuplot")
error: '__gnuplot_has_feature__' undefined near line 49 column 5
error: called from
gnuplot_binary at line 49 column 5
if Octave is running in a build tree that is separate from the source
tree. The problem happens because gnuplot_binary.m is generated and
so is stored in the build tree. But the private functions like
__gnuplot_has_feature__ are in the source tree. Since the private
directory where __gnuplot_has_feature__ is located is not a
subdirectory of the directory where gnuplot_binary is located, Octave
doesn't find it.
I also noticed another problem due to this changeset. The test executes
gnuplot_binary ("X")
and that now ends up calling __gnuplot_version__ which attempts to
execute the command "X --version". On many systems, "X" is the X11
server. So then I see errors about the X server failing to start
properly and Octave hangs.
It also seems bad that "gnuplot_binary (new_prog)" will now call
gnuplot_binary recursively. It currently works because the persistent
value that stores the program name is set before calling
__gnuplot_version__, but that seems a bit fragile.
I'm also wondering how important it is to be able to change the
gnuplot binary during a single Octave session. Is this something that
comes up frequently?
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 01 Sep 2016 23:55:09 -0400 |
parents | e5ae26e50374 |
children | 0abb58c3b117 |
files | scripts/plot/util/gnuplot_binary.in.m scripts/plot/util/private/__gnuplot_has_feature__.m scripts/plot/util/private/__gnuplot_version__.m |
diffstat | 3 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/util/gnuplot_binary.in.m Wed Aug 31 17:20:38 2016 +0300 +++ b/scripts/plot/util/gnuplot_binary.in.m Thu Sep 01 23:55:09 2016 -0400 @@ -46,7 +46,6 @@ error ("gnuplot_binary: NEW_PROG must be a non-empty string"); endif gp_binary = new_prog; - __gnuplot_has_feature__ ("__reset__"); endif if (nargin > 1)
--- a/scripts/plot/util/private/__gnuplot_has_feature__.m Wed Aug 31 17:20:38 2016 +0300 +++ b/scripts/plot/util/private/__gnuplot_has_feature__.m Thu Sep 01 23:55:09 2016 -0400 @@ -42,9 +42,9 @@ "dashtype"}; persistent has_features; - if (isempty (has_features) || strcmp (feature, "__reset__")) + if (isempty (has_features)) try - gnuplot_version = __gnuplot_version__ ("__reset__"); + gnuplot_version = __gnuplot_version__ (); catch ## Don't throw an error if gnuplot isn't installed gnuplot_version = "0.0.0";
--- a/scripts/plot/util/private/__gnuplot_version__.m Wed Aug 31 17:20:38 2016 +0300 +++ b/scripts/plot/util/private/__gnuplot_version__.m Thu Sep 01 23:55:09 2016 -0400 @@ -21,11 +21,15 @@ ## Undocumented internal function. ## @end deftypefn -function version = __gnuplot_version__ (do_reset = false) +## Return the version of gnuplot we are using. Note that we do not +## attempt to handle the case of the user switching to different +## versions of gnuplot during the same session. + +function version = __gnuplot_version__ () persistent __version__ = ""; - if (isempty (__version__) || do_reset) + if (isempty (__version__)) [status, output] = system (sprintf ('"%s" --version', gnuplot_binary ())); if (status != 0) ## This message ends in a newline so that the traceback messages