Mercurial > octave-nkf
diff src/strfns.cc @ 5862:2b35a7fe9302
[project @ 2006-06-20 04:31:56 by jwe]
author | jwe |
---|---|
date | Tue, 20 Jun 2006 04:31:56 +0000 |
parents | 080c08b192d8 |
children | a65b51ed388c |
line wrap: on
line diff
--- a/src/strfns.cc Fri Jun 16 05:09:42 2006 +0000 +++ b/src/strfns.cc Tue Jun 20 04:31:56 2006 +0000 @@ -229,15 +229,17 @@ cell = args(0).cell_value (); } - if (r == 1) + if (r == 0 || r == 1) { // Broadcast the string. boolNDArray output (cell.dimensions); + std::string s = r == 0 ? std::string () : str[0]; + for (int i = 0; i < cell.length (); i++) if (cell(i).is_string ()) - output(i) = (cell(i).string_value () == str[0]); + output(i) = (cell(i).string_value () == s); else output(i) = false; @@ -374,6 +376,49 @@ return retval; } +/* +%!shared x +%! x = char (zeros (0, 2)); +%!assert (strcmp ('', x) == false); +%!assert (strcmp (x, '') == false); +%!assert (strcmp (x, x) == true); +%!assert (strcmp ({''}, x) == false); +%!assert (strcmp ({x}, '') == false); +%!assert (strcmp ({x}, x) == true); +%!assert (strcmp ('', {x}) == false); +%!assert (strcmp (x, {''}) == false); +%!assert (strcmp (x, {x}) == true); +%!assert (all (strcmp ({x; x}, '') == [false; false])); +%!assert (all (strcmp ({x; x}, {''}) == [false; false])); +%!assert (all (strcmp ('', {x; x}) == [false; false])); +%!assert (all (strcmp ({''}, {x; x}) == [false; false])); +%!assert (strcmp ({'foo'}, x) == false); +%!assert (strcmp ({'foo'}, 'foo') == true); +%!assert (strcmp ({'foo'}, x) == false); +%!assert (strcmp (x, {'foo'}) == false); +%!assert (strcmp ('foo', {'foo'}) == true); +%!assert (strcmp (x, {'foo'}) == false); +%!shared y +%! y = char (zeros (2, 0)); +%!assert (strcmp ('', y) == false); +%!assert (strcmp (y, '') == false); +%!assert (strcmp (y, y) == true); +%!assert (all (strcmp ({''}, y) == [true; true])); +%!assert (strcmp ({y}, '') == true); +%!assert (all (strcmp ({y}, y) == [true; true])); +%!assert (all (strcmp ('', {y}) == [true; true])); +%!assert (all (strcmp (y, {''}) == [true; true])); +%!assert (all (strcmp (y, {y}) == [true; true])); +%!assert (all (strcmp ({y; y}, '') == [false; false])); +%!assert (all (strcmp ({y; y}, {''}) == [false; false])); +%!assert (all (strcmp ('', {y; y}) == [false; false])); +%!assert (all (strcmp ({''}, {y; y}) == [false; false])); +%!assert (all (strcmp ({'foo'}, y) == [false; false])); +%!assert (all (strcmp ({'foo'}, y) == [false; false])); +%!assert (all (strcmp (y, {'foo'}) == [false; false])); +%!assert (all (strcmp (y, {'foo'}) == [false; false])); +*/ + DEFUN (list_in_columns, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} list_in_columns (@var{arg}, @var{width})\n\