Mercurial > hg > octave-nkf
diff scripts/plot/private/__gnuplot_ginput__.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 | 72c96de7a403 |
children | 0e75f5412f1e |
line wrap: on
line diff
--- a/scripts/plot/private/__gnuplot_ginput__.m +++ b/scripts/plot/private/__gnuplot_ginput__.m @@ -31,6 +31,10 @@ function [x, y, button] = __gnuplot_ginput__ (f, n) + if (compare_versions (__gnuplot_version__ (), "4.0", "<=")) + error ("ginput: version %s of gnuplot not supported", gnuplot_version ()); + endif + ostream = get (f, "__plot_stream__"); if (numel (ostream) < 1) error ("ginput: stream to gnuplot not open"); @@ -46,10 +50,6 @@ ostream = ostream(1); endif - if (compare_versions (__gnuplot_version__ (), "4.0", "<=")) - error ("ginput: version %s of gnuplot not supported", gnuplot_version ()); - endif - if (nargin == 1) x = zeros (100, 1); y = zeros (100, 1); @@ -66,7 +66,7 @@ ##Mode: 6*8*8 == 0600 [err, msg] = mkfifo (gpin_name, 6*8*8); - if (err != 0) + if (err) error ("ginput: Can not open fifo (%s)", msg); endif endif @@ -84,8 +84,8 @@ fprintf (ostream, "set print \"%s\";\n", gpin_name); fflush (ostream); [gpin, err] = fopen (gpin_name, "r"); - if (err != 0) - error ("ginput: Can not open fifo (%s)", msg); + if (err) + error ("ginput: Can not open FIFO (%s)", msg); endif fputs (ostream, "pause mouse any;\n\n"); fputs (ostream, "\nif (exists(\"MOUSE_KEY\") && exists(\"MOUSE_X\")) print MOUSE_X, MOUSE_Y, MOUSE_KEY; else print \"0 0 -1\"\n"); @@ -98,7 +98,7 @@ [x(k), y(k), button(k), count] = fscanf (gpin, "%f %f %d", "C"); fclose (gpin); else - fprintf (ostream, "set print \"-\";\n"); + fputs (ostream, "set print \"-\";\n"); fflush (ostream); fputs (ostream, "pause mouse any;\n\n"); fputs (ostream, "\nif (exists(\"MOUSE_KEY\") && exists(\"MOUSE_X\")) print \"OCTAVE: \", MOUSE_X, MOUSE_Y, MOUSE_KEY; else print \"0 0 -1\"\n"); @@ -109,7 +109,7 @@ str = {}; while (isempty (str)) - str = char (fread (istream)'); + str = fread (istream, "*char")'; if (isempty (str)) sleep (0.05); else