Mercurial > hg > octave-lyh
annotate scripts/plot/private/__gnuplot_has_feature__.m @ 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 | 1339c964b527 |
children |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
12793
diff
changeset
|
1 ## Copyright (C) 2009-2012 Ben Abbott |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2 ## |
11104 | 3 ## This file is part of Octave. |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
8620
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
18 |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8645
diff
changeset
|
20 ## @deftypefn {Function File} {@var{has_feature} =} __gnuplot_has_feature__ (@var{feature}) |
8620
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
21 ## Undocumented internal function. |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
22 ## @end deftypefn |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
23 |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
24 ## Author: Ben Abbott <bpabbott@mac.com> |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
25 ## Created: 2009-01-27 |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
26 |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
27 function res = __gnuplot_has_feature__ (feature) |
16108
3cce6b4e0f7c
Update gnuplot plotting scripts for faster or more modern synta
Rik <rik@octave.org>
parents:
16095
diff
changeset
|
28 persistent features = {"x11_figure_position", |
3cce6b4e0f7c
Update gnuplot plotting scripts for faster or more modern synta
Rik <rik@octave.org>
parents:
16095
diff
changeset
|
29 "wxt_figure_size", |
3cce6b4e0f7c
Update gnuplot plotting scripts for faster or more modern synta
Rik <rik@octave.org>
parents:
16095
diff
changeset
|
30 "transparent_patches", |
3cce6b4e0f7c
Update gnuplot plotting scripts for faster or more modern synta
Rik <rik@octave.org>
parents:
16095
diff
changeset
|
31 "transparent_surface", |
3cce6b4e0f7c
Update gnuplot plotting scripts for faster or more modern synta
Rik <rik@octave.org>
parents:
16095
diff
changeset
|
32 "epslatex_implies_eps_filesuffix", |
3cce6b4e0f7c
Update gnuplot plotting scripts for faster or more modern synta
Rik <rik@octave.org>
parents:
16095
diff
changeset
|
33 "epslatexstandalone_terminal", |
3cce6b4e0f7c
Update gnuplot plotting scripts for faster or more modern synta
Rik <rik@octave.org>
parents:
16095
diff
changeset
|
34 "screen_coordinates_for_{lrtb}margin", |
3cce6b4e0f7c
Update gnuplot plotting scripts for faster or more modern synta
Rik <rik@octave.org>
parents:
16095
diff
changeset
|
35 "variable_GPVAL_TERMINALS", |
3cce6b4e0f7c
Update gnuplot plotting scripts for faster or more modern synta
Rik <rik@octave.org>
parents:
16095
diff
changeset
|
36 "key_has_font_properties", |
3cce6b4e0f7c
Update gnuplot plotting scripts for faster or more modern synta
Rik <rik@octave.org>
parents:
16095
diff
changeset
|
37 "windows_figure_position", |
3cce6b4e0f7c
Update gnuplot plotting scripts for faster or more modern synta
Rik <rik@octave.org>
parents:
16095
diff
changeset
|
38 "has_termoption_dashed"}; |
3cce6b4e0f7c
Update gnuplot plotting scripts for faster or more modern synta
Rik <rik@octave.org>
parents:
16095
diff
changeset
|
39 persistent has_features; |
8620
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
40 |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
41 if (isempty (has_features)) |
12325
5d68277d4496
__gnuplot_has_feature__.m: Don't throw an error if gnuplot isn't installed.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
42 try |
5d68277d4496
__gnuplot_has_feature__.m: Don't throw an error if gnuplot isn't installed.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
43 gnuplot_version = __gnuplot_version__ (); |
5d68277d4496
__gnuplot_has_feature__.m: Don't throw an error if gnuplot isn't installed.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
44 catch |
5d68277d4496
__gnuplot_has_feature__.m: Don't throw an error if gnuplot isn't installed.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
45 ## Don't throw an error if gnuplot isn't installed |
5d68277d4496
__gnuplot_has_feature__.m: Don't throw an error if gnuplot isn't installed.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
46 gnuplot_version = "0.0.0"; |
5d68277d4496
__gnuplot_has_feature__.m: Don't throw an error if gnuplot isn't installed.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
47 end_try_catch |
16095
1339c964b527
Fix warning when using "termoption dashed" with gnuplot 4.2.X (bug #38370)
Rik <rik@octave.org>
parents:
14417
diff
changeset
|
48 versions = {"4.2.5", "4.4", "4.4", "4.4", "4.2", "4.2", "4.4", "4.4", "4.4", "4.4", "4.3"}; |
1339c964b527
Fix warning when using "termoption dashed" with gnuplot 4.2.X (bug #38370)
Rik <rik@octave.org>
parents:
14417
diff
changeset
|
49 operators = {">=", ">=", ">=", ">=", ">=", ">=", ">=", ">=", ">=", ">=", ">="}; |
16108
3cce6b4e0f7c
Update gnuplot plotting scripts for faster or more modern synta
Rik <rik@octave.org>
parents:
16095
diff
changeset
|
50 have_features = false (size (features)); |
8620
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
51 for n = 1 : numel (have_features) |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
52 has_features(n) = compare_versions (gnuplot_version, versions{n}, operators{n}); |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
53 endfor |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
54 endif |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
55 |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
56 n = find (strcmpi (feature, features)); |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
57 if (isempty (n)) |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
58 res = NaN; |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
59 else |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
60 res = has_features(n); |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
61 endif |
16108
3cce6b4e0f7c
Update gnuplot plotting scripts for faster or more modern synta
Rik <rik@octave.org>
parents:
16095
diff
changeset
|
62 |
8620
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
63 endfunction |
a2dd2ffc504d
__gnuplot_has_feature__.m: New file, checks for supported feature.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
64 |