diff scripts/plot/private/__gnuplot_has_terminal__.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
line wrap: on
line diff
--- a/scripts/plot/private/__gnuplot_has_terminal__.m
+++ b/scripts/plot/private/__gnuplot_has_terminal__.m
@@ -25,11 +25,10 @@
 ## Created: 2010-09-13
 
 function gnuplot_supports_term = __gnuplot_has_terminal__ (term, plot_stream)
-  term = deblank (term);
-  n = find (term == " ", 1);
-  if (! isempty (n))
-    term = term(1:n-1);
-  endif
+
+  term = strtrim (term);
+  term = lower (strtok (term, " "));
+
   if (__gnuplot_has_feature__ ("variable_GPVAL_TERMINALS"))
     if (nargin < 2)
       plot_stream = __gnuplot_open_stream__ (2);
@@ -59,6 +58,8 @@
                            "svg", "texdraw", "tgif", "tkcanvas", ...
                            "tpic", "windows", "x11", "xlib", "xterm"};
   endif
-  gnuplot_supports_term = any (strcmpi (available_terminals, term));
+
+  gnuplot_supports_term = any (strcmp (term, available_terminals));
+
 endfunction