Mercurial > octave
changeset 22681:cef19bf07f26
gnuplot_binary.in.m: Overhaul function.
* gnuplot_binary.in.m: Document additional calling form.
Add semicolon to end of line for mlock() function call.
Set gnuplot_binary name when additional args are present (bug in existing
code). Clear additional args field if a new binary is set without
other inputs. Revise BIST tests for new behavior.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 27 Oct 2016 15:54:49 -0700 |
parents | 62702ba67a38 |
children | 05308824fbcf |
files | scripts/plot/util/gnuplot_binary.in.m |
diffstat | 1 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/util/gnuplot_binary.in.m Thu Oct 27 15:31:11 2016 -0700 +++ b/scripts/plot/util/gnuplot_binary.in.m Thu Oct 27 15:54:49 2016 -0700 @@ -18,6 +18,7 @@ ## -*- texinfo -*- ## @deftypefn {} {[@var{prog}, @var{args}] =} gnuplot_binary () +## @deftypefnx {} {[@var{old_prog}, @var{old_args}] =} gnuplot_binary (@var{new_prog}) ## @deftypefnx {} {[@var{old_prog}, @var{old_args}] =} gnuplot_binary (@var{new_prog}, @var{arg1}, @dots{}) ## Query or set the name of the program invoked by the plot command when the ## graphics toolkit is set to @qcode{"gnuplot"}. @@ -32,7 +33,7 @@ function [prog, args] = gnuplot_binary (new_prog, varargin) - mlock () + mlock (); persistent gp_binary = %OCTAVE_CONF_GNUPLOT%; persistent gp_args = {}; @@ -41,11 +42,12 @@ args = gp_args; endif - if (nargin == 1) + if (nargin > 0) if (! ischar (new_prog) || isempty (new_prog)) error ("gnuplot_binary: NEW_PROG must be a non-empty string"); endif gp_binary = new_prog; + gp_args = {}; endif if (nargin > 1) @@ -59,10 +61,13 @@ %!test -%! orig_val = gnuplot_binary (); -%! old_val = gnuplot_binary ("__foobar__"); +%! [orig_val, orig_args] = gnuplot_binary (); +%! [old_val, old_args] = gnuplot_binary ("__foobar__", "-opt1"); %! assert (orig_val, old_val); +%! assert (orig_args, old_args); %! assert (gnuplot_binary (), "__foobar__"); -%! gnuplot_binary (orig_val); +%! [~, new_args] = gnuplot_binary (); +%! assert (new_args, {"-opt1"}); +%! gnuplot_binary (orig_val, orig_args{:}); %! assert (gnuplot_binary (), orig_val);