Mercurial > hg > octave-nkf
changeset 5371:30b2b6ef8597
[project @ 2005-05-24 15:24:37 by jwe]
author | jwe |
---|---|
date | Tue, 24 May 2005 15:24:37 +0000 |
parents | f07a9653b844 |
children | b4485a3ce01b |
files | scripts/ChangeLog scripts/strings/strcmp.m |
diffstat | 2 files changed, 18 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2005-05-24 John W. Eaton <jwe@octave.org> + + * strings/strcmp.m: Return logical values in all cases. + 2005-05-23 John W. Eaton <jwe@octave.org> * plot/orient.m: New file. Adapt to Octave coding style.
--- a/scripts/strings/strcmp.m +++ b/scripts/strings/strcmp.m @@ -19,11 +19,12 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} strcmp (@var{s1}, @var{s2}) -## Compares two strings, returning 1 if they are the same, and 0 otherwise. +## Compares two strings, returning true if they are the same, and false +## otherwise. ## ## @strong{Caution:} For compatibility with @sc{Matlab}, Octave's strcmp -## function returns 1 if the strings are equal, and 0 otherwise. This is -## just the opposite of the corresponding C library function. +## function returns true if the strings are equal, and false otherwise. +## This is just the opposite of the corresponding C library function. ## @end deftypefn ## Author: jwe @@ -34,7 +35,7 @@ usage ("strcmp (s, t)"); endif - retval = 0; + retval = false; if (isstr (s1)) [r1, c1] = size (s1); @@ -42,7 +43,7 @@ [r2, c2] = size (s2); if (r1 == r2 && c1 == c2) if (c1 == 0) - retval = 1; + retval = true; else retval = all (all (s1 == s2)); endif @@ -52,7 +53,7 @@ if (r1 == 1) t2 = s2(:); n = length (t2); - retval = zeros (n, 1); + retval = zeros (n, 1, "logical"); for i = 1:n retval(i) = strcmp (s1, t2{i}); endfor @@ -60,7 +61,7 @@ elseif (r1 > 1) if (r2 == 1 && c2 == 1) t2 = s2{1}; - retval = zeros (r1, 1); + retval = zeros (r1, 1, "logical"); for i = 1:r1 retval(i) = strcmp (deblank (s1(i,:)), t2); endfor @@ -68,7 +69,7 @@ t2 = s2(:); n = length (t2); if (n == r1) - retval = zeros (n, 1); + retval = zeros (n, 1, "logical"); for i = 1:n retval(i) = strcmp (deblank (s1(i,:)), t2{i}); endfor @@ -84,7 +85,7 @@ if (r2 == 1) t1 = s1(:); n = length (t1); - retval = zeros (n, 1); + retval = zeros (n, 1, "logical"); for i = 1:n retval(i) = strcmp (t1{i}, s2); endfor @@ -92,7 +93,7 @@ elseif (r2 > 1) if (r1 == 1 && c1 == 1) t1 = s1{1}; - retval = zeros (r2, 1); + retval = zeros (r2, 1, "logical"); for i = 1:r2 retval(i) = strcmp (t1, deblank (s2(i,:))); endfor @@ -100,7 +101,7 @@ t1 = s1(:); n = length (t1); if (n == r2) - retval = zeros (n, 1); + retval = zeros (n, 1, "logical"); for i = 1:n retval(i) = strcmp (t1{i}, deblank (s2(i,:))); endfor @@ -114,7 +115,7 @@ t1 = s1{:}; t2 = s2(:); n = length (t2); - retval = zeros (n, 1); + retval = zeros (n, 1, "logical"); for i = 1:n retval(i) = strcmp (t1, t2{i}); endfor @@ -123,7 +124,7 @@ t1 = s1(:); t2 = s2{:}; n = length (t1); - retval = zeros (n, 1); + retval = zeros (n, 1, "logical"); for i = 1:n retval(i) = strcmp (t1{i}, t2); endfor