# HG changeset patch # User John W. Eaton # Date 1235723501 18000 # Node ID 579de77acd909018af491c50ab07f936887f2887 # Parent 7de0992eb12300fdfd2587b0c1118c5b5713d941 strsplit.m: style fixes diff -r 7de0992eb123 -r 579de77acd90 scripts/ChangeLog --- a/scripts/ChangeLog Fri Feb 27 08:06:25 2009 +0100 +++ b/scripts/ChangeLog Fri Feb 27 03:31:41 2009 -0500 @@ -1,3 +1,7 @@ +2009-02-27 John W. Eaton + + * strings/strsplit.m: Style fixes. + 2009-02-27 Jaroslav Hajek * strings/strsplit.m: Check also nargin. diff -r 7de0992eb123 -r 579de77acd90 scripts/strings/strsplit.m --- a/scripts/strings/strsplit.m Fri Feb 27 08:06:25 2009 +0100 +++ b/scripts/strings/strsplit.m Fri Feb 27 03:31:41 2009 -0500 @@ -16,45 +16,48 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{s}] =} strsplit (@var{p}, @var{sep}, @var{strip_empty}) -## Splits a single string using one or more delimiters. -## The result is returned as a cell array of strings. Consecutive delimiters -## and delimiters at boundaries result in empty strings, unless @var{strip_empty} is true. +## Split a single string using one or more delimiters and return a cell +## array of strings. Consecutive delimiters and delimiters at +## boundaries result in empty strings, unless @var{strip_empty} is true. ## The default value of @var{strip_empty} is false. +## @seealso{strtok} ## @end deftypefn function s = strsplit (p, sep, strip_empty = false) - if (nargin < 2 || nargin > 3 || ! ischar (p) || rows (p) > 1 \ - || ! ischar (sep) || ! islogical (strip_empty)) + + if (nargin < 2 || nargin > 3 || ! ischar (p) || rows (p) > 1 + || ! ischar (sep) || ! islogical (strip_empty)) print_usage (); endif if (isempty (p)) s = cell (size (p)); else - ## split p according to delimiter. + ## Split p according to delimiter. if (isscalar (sep)) - ## single separator + ## Single separator. idx = find (p == sep); else - ## multiple separators + ## Multiple separators. idx = strchr (p, sep); endif - ## get substring sizes. + ## Get substring sizes. if (isempty (idx)) sizes = numel (p); else sizes = [idx(1)-1, diff(idx)-1, numel(p)-idx(end)]; endif - ## remove separators. + ## Remove separators. p(idx) = []; if (strip_empty) - ## omit zero lengths. + ## Omit zero lengths. sizes = sizes (sizes != 0); endif - ## convert! + ## Convert! s = mat2cell (p, 1, sizes); endif + endfunction %!assert (all (strcmp (strsplit ("road to hell", " "), {"road", "to", "hell"}))) diff -r 7de0992eb123 -r 579de77acd90 src/symtab.h --- a/src/symtab.h Fri Feb 27 08:06:25 2009 +0100 +++ b/src/symtab.h Fri Feb 27 03:31:41 2009 -0500 @@ -2064,6 +2064,8 @@ sr.force_variable (context); } + else + p->second.force_variable (context); } octave_value& do_varref (const std::string& name, context_id context)