Mercurial > hg > octave-lyh
comparison scripts/plot/gnuplot_binary.in @ 16108:3cce6b4e0f7c
Update gnuplot plotting scripts for faster or more modern synta
* scripts/plot/__gnuplot_drawnow__.m: Use default values in function header.
Check number of arguments to function immediately. Use single quotes to
avoid lots of backslashing. Use strtok() to replace hand-coded functionality.
Initialize persistent variables in declaration (10% faster).
* scripts/plot/gnuplot_binary.in: Replace tabs with spaces. Simplify input
validation. Add %!test block.
* scripts/plot/private/__gnuplot_get_var__.m: Use default values in function
header. Use "*char" in fread to automatically convert to char variable.
* scripts/plot/private/__gnuplot_ginput__.m: Check immediately for required
version of gnuplot. Use "*char" in fread to automatically convert to char
variable. Use fputs in place of fprintf to match rest of code.
* scripts/plot/private/__gnuplot_has_feature__.m: Initialize persistent varibles
in declaration. Use false () rather than logical (zeros()) construction.
* scripts/plot/private/__gnuplot_has_terminal__.m: Use strtok() to replace
hand-coded functionality
* scripts/plot/private/__gnuplot_print__.m: Replace sprintf calls with direct
string char matrix concatenation (2.4x faster) where possible. Replace for
loop with multiple argument form of set(). Use single quotes to avoid lots
of backslashing.
* scripts/plot/private/__gnuplot_version__.m: Use single quotes to avoid lots
of backslashing.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 25 Feb 2013 21:01:36 -0800 |
parents | 72c96de7a403 |
children | 4d7f95eb8bfe |
comparison
equal
deleted
inserted
replaced
16107:3b791008b88e | 16108:3cce6b4e0f7c |
---|---|
20 ## @deftypefn {Loadable Function} {[@var{prog}, @var{args}] =} gnuplot_binary () | 20 ## @deftypefn {Loadable Function} {[@var{prog}, @var{args}] =} gnuplot_binary () |
21 ## @deftypefnx {Loadable Function} {[@var{old_prog}, @var{old_args}] =} gnuplot_binary (@var{new_prog}, @var{arg1}, @dots{}) | 21 ## @deftypefnx {Loadable Function} {[@var{old_prog}, @var{old_args}] =} gnuplot_binary (@var{new_prog}, @var{arg1}, @dots{}) |
22 ## Query or set the name of the program invoked by the plot command | 22 ## Query or set the name of the program invoked by the plot command |
23 ## when the graphics toolkit is set to "gnuplot". Additional arguments to | 23 ## when the graphics toolkit is set to "gnuplot". Additional arguments to |
24 ## pass to the external plotting program may also be given. | 24 ## pass to the external plotting program may also be given. |
25 ## The default value is @code{"gnuplot"} without additional arguments. | 25 ## The default value is @code{"gnuplot"} with no additional arguments. |
26 ## @xref{Installation}. | 26 ## @xref{Installation}. |
27 ## @seealso{graphics_toolkit} | |
27 ## @end deftypefn | 28 ## @end deftypefn |
28 | 29 |
29 ## Author: jwe | 30 ## Author: jwe |
30 | 31 |
31 function [prog, args] = gnuplot_binary (new_prog, varargin) | 32 function [prog, args] = gnuplot_binary (new_prog, varargin) |
37 prog = gp_binary; | 38 prog = gp_binary; |
38 args = gp_args; | 39 args = gp_args; |
39 endif | 40 endif |
40 | 41 |
41 if (nargin == 1) | 42 if (nargin == 1) |
42 if (ischar (new_prog)) | 43 if (! ischar (new_prog) || isempty (new_prog)) |
43 if (! isempty (new_prog)) | 44 error ("gnuplot_binary: NEW_PROG must be a non-empty string"); |
44 gp_binary = new_prog; | |
45 else | |
46 error ("gnuplot_binary: value must not be empty"); | |
47 endif | |
48 else | |
49 error ("gnuplot_binary: expecting program to be a character string"); | |
50 endif | 45 endif |
46 gp_binary = new_prog; | |
51 endif | 47 endif |
52 | 48 |
53 if (nargin > 1) | 49 if (nargin > 1) |
54 if (iscellstr (varargin)) | 50 if (! iscellstr (varargin)) |
55 gp_args = varargin; | 51 error ("gnuplot_binary: arguments must be character strings"); |
56 else | |
57 error ("gnuplot_binary: expecting arguments to be character strings"); | |
58 endif | 52 endif |
53 gp_args = varargin; | |
59 endif | 54 endif |
60 | 55 |
61 endfunction | 56 endfunction |
57 | |
58 | |
59 %!test | |
60 %! orig_val = gnuplot_binary (); | |
61 %! old_val = gnuplot_binary ("X"); | |
62 %! assert (orig_val, old_val); | |
63 %! assert (gnuplot_binary (), "X"); | |
64 %! gnuplot_binary (orig_val); | |
65 %! assert (gnuplot_binary (), orig_val); |