# HG changeset patch # User Rik # Date 1379951719 25200 # Node ID 177147bf7b55e53c19e2c4340c277f7b9a9162af # Parent dea415e4216ddc2d7e2761968cfafa1d14283a73 Overhaul use of __pltopt__.m to correctly check for cellstr, not just cell. * scripts/plot/private/__pltopt__.m: Use modern coding conventions. Eliminate unneeded input checking in subfunctions. Remove unused variables. * scripts/plot/contourf.m, scripts/plot/feather.m, scripts/plot/plotmatrix.m, scripts/plot/private/__bar__.m, scripts/plot/private/__quiver__.m, scripts/plot/private/__scatter__.m, scripts/plot/private/__stem__.m, scripts/plot/stairs.m: Use iscellstr, not iscell, to properly validate inputs to __pltopt__. diff -r dea415e4216d -r 177147bf7b55 scripts/plot/contourf.m --- a/scripts/plot/contourf.m Sun Sep 22 18:33:57 2013 -0700 +++ b/scripts/plot/contourf.m Mon Sep 23 08:55:19 2013 -0700 @@ -72,7 +72,7 @@ hax = newplot (hax); [ctmp, htmp] = __contour__ (hax, "none", "fill", "on", - "linecolor", "black", varargin{:}); + "linecolor", "black", varargin{:}); unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig); diff -r dea415e4216d -r 177147bf7b55 scripts/plot/feather.m --- a/scripts/plot/feather.m Sun Sep 22 18:33:57 2013 -0700 +++ b/scripts/plot/feather.m Mon Sep 23 08:55:19 2013 -0700 @@ -71,7 +71,7 @@ have_line_spec = false; while (ioff <= nargin) arg = varargin{ioff++}; - if ((ischar (arg) || iscell (arg)) && ! have_line_spec) + if ((ischar (arg) || iscellstr (arg)) && ! have_line_spec) [linespec, valid] = __pltopt__ ("feather", arg, false); if (valid) line_spec = arg; diff -r dea415e4216d -r 177147bf7b55 scripts/plot/plotmatrix.m --- a/scripts/plot/plotmatrix.m Sun Sep 22 18:33:57 2013 -0700 +++ b/scripts/plot/plotmatrix.m Mon Sep 23 08:55:19 2013 -0700 @@ -129,7 +129,7 @@ parent = get (bigax, "parent"); for i = 1 : nargin - 1 arg = varargin{i}; - if (ischar (arg) || iscell (arg)) + if (ischar (arg) || iscellstr (arg)) [linespec, valid] = __pltopt__ ("plotmatrix", varargin{i}, false); if (valid) have_line_spec = true; diff -r dea415e4216d -r 177147bf7b55 scripts/plot/private/__bar__.m --- a/scripts/plot/private/__bar__.m Sun Sep 22 18:33:57 2013 -0700 +++ b/scripts/plot/private/__bar__.m Mon Sep 23 08:55:19 2013 -0700 @@ -73,7 +73,7 @@ group = false; idx++; else - if ((ischar (varargin{idx}) || iscell (varargin{idx})) + if ((ischar (varargin{idx}) || iscellstr (varargin{idx})) && ! have_line_spec) [linespec, valid] = __pltopt__ (func, varargin{idx}, false); if (valid) diff -r dea415e4216d -r 177147bf7b55 scripts/plot/private/__pltopt__.m --- a/scripts/plot/private/__pltopt__.m Sun Sep 22 18:33:57 2013 -0700 +++ b/scripts/plot/private/__pltopt__.m Mon Sep 23 08:55:19 2013 -0700 @@ -89,24 +89,19 @@ ## Author: jwe -function [options, valid] = __pltopt__ (caller, opt, err_on_invalid) - - valid = true; - options = __default_plot_options__ (); +function [options, valid] = __pltopt__ (caller, opt, err_on_invalid = true) - if (nargin == 2) - err_on_invalid = true; - endif + options = __default_plot_options__ (); + valid = true; + if (ischar (opt)) - nel = rows (opt); - elseif (iscellstr (opt)) - nel = numel (opt); - else + opt = cellstr (opt); + elseif (! iscellstr (opt)) error ("__pltopt__: argument must be a character string or cell array of character strings"); endif - if (ischar (opt)) - opt = cellstr (opt); - endif + + nel = numel (opt); + for i = nel:-1:1 [options(i), valid] = __pltopt1__ (caller, opt{i}, err_on_invalid); if (! err_on_invalid && ! valid) @@ -127,17 +122,11 @@ options = __default_plot_options__ (); valid = true; - more_opts = 1; - - if (! ischar (opt)) - return; - endif - have_linestyle = false; have_marker = false; ## If called by __errplot__, extract the linestyle before proceeding. - if (strcmp (caller,"__errplot__")) + if (strcmp (caller, "__errplot__")) if (strncmp (opt, "#~>", 3)) n = 3; elseif (strncmp (opt, "#~", 2) || strncmp (opt, "~>", 2)) diff -r dea415e4216d -r 177147bf7b55 scripts/plot/private/__quiver__.m --- a/scripts/plot/private/__quiver__.m Sun Sep 22 18:33:57 2013 -0700 +++ b/scripts/plot/private/__quiver__.m Mon Sep 23 08:55:19 2013 -0700 @@ -83,7 +83,7 @@ arg = varargin{ioff++}; if (ischar (arg) && strcmpi (arg, "filled")) have_filled = true; - elseif ((ischar (arg) || iscell (arg)) + elseif ((ischar (arg) || iscellstr (arg)) && ! have_line_spec) [linespec, valid] = __pltopt__ ("quiver", arg, false); if (valid) diff -r dea415e4216d -r 177147bf7b55 scripts/plot/private/__scatter__.m --- a/scripts/plot/private/__scatter__.m Sun Sep 22 18:33:57 2013 -0700 +++ b/scripts/plot/private/__scatter__.m Mon Sep 23 08:55:19 2013 -0700 @@ -93,7 +93,7 @@ arg = varargin{iarg++}; if (ischar (arg) && (strcmpi (arg, "filled") || strcmpi (arg, "fill"))) filled = true; - elseif ((ischar (arg) || iscell (arg)) && ! have_marker) + elseif ((ischar (arg) || iscellstr (arg)) && ! have_marker) [linespec, valid] = __pltopt__ (fcn, arg, false); if (valid) have_marker = true; diff -r dea415e4216d -r 177147bf7b55 scripts/plot/private/__stem__.m --- a/scripts/plot/private/__stem__.m Sun Sep 22 18:33:57 2013 -0700 +++ b/scripts/plot/private/__stem__.m Mon Sep 23 08:55:19 2013 -0700 @@ -274,7 +274,7 @@ arg = varargin{ioff++}; if (ischar (arg) && any (strcmpi (arg, {"fill", "filled"}))) dofill = true; - elseif ((ischar (arg) || iscell (arg)) && ! have_line_spec) + elseif ((ischar (arg) || iscellstr (arg)) && ! have_line_spec) [linespec, valid] = __pltopt__ (caller, arg, false); if (valid) have_line_spec = true; diff -r dea415e4216d -r 177147bf7b55 scripts/plot/stairs.m --- a/scripts/plot/stairs.m Sun Sep 22 18:33:57 2013 -0700 +++ b/scripts/plot/stairs.m Mon Sep 23 08:55:19 2013 -0700 @@ -149,7 +149,7 @@ have_line_spec = false; for i = 1:2:numel (varargin) arg = varargin{i}; - if (ischar (arg) || iscell (arg)) + if (ischar (arg) || iscellstr (arg)) [linespec, valid] = __pltopt__ ("stairs", arg, false); if (valid) have_line_spec = true;