Mercurial > hg > octave-lyh
diff scripts/strings/deblank.m @ 5462:74804828df1a
[project @ 2005-09-22 18:36:22 by jwe]
author | jwe |
---|---|
date | Thu, 22 Sep 2005 18:36:23 +0000 |
parents | ec8c33dcd1bf |
children | 75a828280d68 |
line wrap: on
line diff
--- a/scripts/strings/deblank.m +++ b/scripts/strings/deblank.m @@ -19,15 +19,16 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} deblank (@var{s}) -## Removes the trailing blanks and nulls from the string @var{s}. -## If @var{s} is a matrix, @var{deblank} trims each row to the -## length of longest string. +## Remove trailing blanks and nulls from @var{s}. If @var{s} +## is a matrix, @var{deblank} trims each row to the length of longest +## string. If @var{s} is a cell array, operate recursively on each +## element of the cell array. ## @end deftypefn ## Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> ## Adapted-By: jwe -function t = deblank (s) +function s = deblank (s) if (nargin != 1) usage ("deblank (s)"); @@ -37,11 +38,17 @@ k = find (! isspace (s) & s != "\0"); if (isempty (s) || isempty (k)) - t = ""; + s = ""; else - t = s(:,1:ceil (max (k) / rows (s))); + s = s(:,1:ceil (max (k) / rows (s))); endif + elseif (iscell(s)) + + for i = 1:numel (s) + s{i} = deblank (s{i}); + endfor + else error ("deblank: expecting string argument"); endif