# HG changeset patch # User Rik # Date 1312827549 25200 # Node ID 1eebae7ac5d2dcb4ad5d924ac9b87ed64ba18d8a # Parent b74cb659e757b205af5eb06ae41046afe06baa15 strmatch.m: Trim search pattern of spaces and nulls. * strmatch.m: Trim search pattern of spaces and nulls diff -r b74cb659e757 -r 1eebae7ac5d2 scripts/sparse/svds.m --- a/scripts/sparse/svds.m Mon Aug 08 12:14:41 2011 -0400 +++ b/scripts/sparse/svds.m Mon Aug 08 11:19:09 2011 -0700 @@ -251,8 +251,8 @@ %! s = s(idx); %! u = u(:,idx); %! v = v(:,idx); -%! randn ('state', 43); % Initialize to make normest function reproducible -%! rand ('state', 43) +%! randn ('state', 35); % Initialize to make normest function reproducible +%! rand ('state', 35) %! opts.v0 = rand (2*n,1); % Initialize eigs ARPACK starting vector %! % to guarantee reproducible results %!test diff -r b74cb659e757 -r 1eebae7ac5d2 scripts/strings/strmatch.m --- a/scripts/strings/strmatch.m Mon Aug 08 12:14:41 2011 -0400 +++ b/scripts/strings/strmatch.m Mon Aug 08 11:19:09 2011 -0700 @@ -25,7 +25,7 @@ ## The second argument @var{A} must be a string, character matrix, or a cell ## array of strings. If the third argument @code{"exact"} is not given, then ## @var{s} only needs to match @var{A} up to the length of @var{s}. -## Trailing spaces and nulls in @var{A} are ignored even with the @code{"exact"} +## Trailing spaces and nulls in @var{s} and @var{A} are ignored when matching. ## option. ## ## For example: @@ -63,6 +63,8 @@ error ("strmatch: A must be a string or cell array of strings"); endif + ## Trim blanks and nulls from search string + s = regexprep (s, "[ \\0]+$", ''); len = length (s); exact = nargin == 3 && ischar (exact) && strcmp (exact, "exact"); @@ -100,7 +102,7 @@ %!assert (strmatch ("apple", ["apple pie"; "apple juice"; "an apple"]), [1; 2]); %!assert (strmatch ("apple", {"apple pie"; "apple juice"; "tomato"}), [1; 2]); %!assert (strmatch ("apple pie", "apple"), []); -%!assert (strmatch ("a ", "a"), []); +%!assert (strmatch ("a ", "a"), 1); %!assert (strmatch ("a", "a \0", "exact"), 1); %!assert (strmatch ("a b", {"a b", "a c", "c d"}), 1); %!assert (strmatch ("", {"", "foo", "bar", ""}), [1, 4]);