Mercurial > octave-nkf
changeset 12981:4ec4096f65d1
doc: State that required input is cellstr, not cell, for strtrim and deblank (Bug #34038)
NEWS: Note incompatible changes to certain string functions since 3.4.2
deblank.m, strtrim.m: Document that cellstr, not cell, is required input.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 21 Aug 2011 21:44:39 -0700 |
parents | 421f2030bb76 |
children | 5e37369ea13c |
files | NEWS scripts/strings/deblank.m scripts/strings/strtrim.m |
diffstat | 3 files changed, 31 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Fri Aug 19 12:39:55 2011 -0500 +++ b/NEWS Sun Aug 21 21:44:39 2011 -0700 @@ -12,6 +12,16 @@ * ML-compatible options: 'whitespace', treatasempty', format string repeat count, user-specified comment style, uneven-length output arrays, %n and %u conversion specifiers (provisionally) + + ** Certain string functions have been modified for greater Matlab compatibility + and for 15X greater performance when operating on cell array of strings. + + deblank : Now requires character or cellstr input + strtrim : Now requires character or cellstr input. + No longer trims nulls ("\0") from string for ML compatibility. + strmatch: Follows documentation precisely and ignores trailing spaces + in pattern and in string. Note that Matlab documents this + behavior but the implementation does *not* always follow it. ** New functions added.
--- a/scripts/strings/deblank.m Fri Aug 19 12:39:55 2011 -0500 +++ b/scripts/strings/deblank.m Sun Aug 21 21:44:39 2011 -0700 @@ -20,8 +20,20 @@ ## @deftypefn {Function File} {} deblank (@var{s}) ## Remove trailing whitespace 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. +## string. If @var{s} is a cell array of strings, operate recursively on each +## string element. +## +## Examples: +## @example +## @group +## deblank (" abc ") +## @result{} " abc" +## +## deblank ([" abc "; " def "]) +## @result{} [" abc " ; " def"] +## @end group +## @end example +## @seealso{strtrim} ## @end deftypefn ## Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> @@ -62,4 +74,5 @@ %!error <Invalid call to deblank> deblank (); %!error <Invalid call to deblank> deblank ("foo", "bar"); %!error <argument must be a string> deblank (1); +%!error <argument must be a string> deblank ({[]});
--- a/scripts/strings/strtrim.m Fri Aug 19 12:39:55 2011 -0500 +++ b/scripts/strings/strtrim.m Sun Aug 21 21:44:39 2011 -0700 @@ -20,18 +20,19 @@ ## @deftypefn {Function File} {} strtrim (@var{s}) ## Remove leading and trailing whitespace from @var{s}. If ## @var{s} is a matrix, @var{strtrim} 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. For example: +## longest string. If @var{s} is a cell array of strings, operate recursively +## on each string element. For example: ## ## @example ## @group ## strtrim (" abc ") -## @result{} "abc" +## @result{} "abc" ## ## strtrim ([" abc "; " def "]) -## @result{} ["abc "; " def"] +## @result{} ["abc " ; " def"] ## @end group ## @end example +## @seealso{deblank} ## @end deftypefn ## Author: John Swensen <jpswensen@jhu.edu> @@ -73,4 +74,5 @@ %!error <Invalid call to strtrim> strtrim (); %!error <Invalid call to strtrim> strtrim ("abc", "def"); %!error <argument must be a string> strtrim (1); +%!error <argument must be a string> strtrim ({[]});