changeset 7813:12a68443191c

[mq]: cellstr
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 22 May 2008 22:00:26 +0200
parents c25094267486
children 87865ed7405f
files scripts/ChangeLog scripts/strings/strcat.m src/ChangeLog src/ov-cell.cc
diffstat 4 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Wed May 21 12:26:57 2008 +0200
+++ b/scripts/ChangeLog	Thu May 22 22:00:26 2008 +0200
@@ -1,3 +1,7 @@
+2008-06-02  Jaroslav Hajek <highegg@gmail.com>
+
+	* strings/strcat.m: Add tests.
+
 2008-06-02  Kim Hansen  <kimhanse@gmail.com>
 
 	* strings/mat2str.m: Change is_complex to iscomplex, add tests, add
--- a/scripts/strings/strcat.m	Wed May 21 12:26:57 2008 +0200
+++ b/scripts/strings/strcat.m	Thu May 22 22:00:26 2008 +0200
@@ -94,6 +94,8 @@
 %!assert(strcat({"ab "}, "ab "), {"ab ab"})
 %!assert(strcat("ab ", {"ab "}), {"abab "})
 %!assert(strcat({"ab "}, {"ab "}), {"ab ab "})
+%!assert(strcat("", "ab"), "ab")
+%!assert(strcat("", {"ab"}, {""}), {"ab"})
 ## 2d
 %!assert(strcat(["ab ";"cde"], ["ab ";"cde"]), ["abab  ";"cdecde"])
 
--- a/src/ChangeLog	Wed May 21 12:26:57 2008 +0200
+++ b/src/ChangeLog	Thu May 22 22:00:26 2008 +0200
@@ -1,3 +1,8 @@
+2008-06-02  Jaroslav Hajek <highegg@gmail.com>
+
+	* ov-cell.cc (Fcellstr): For compatibility with Matlab, return {''}
+	when given ''.
+
 2008-05-21  David Bateman  <dbateman@free.fr>
 
 	* DLD-FUNCTIONS/quad.cc (quad_float_user_function): New function.
--- a/src/ov-cell.cc	Wed May 21 12:26:57 2008 +0200
+++ b/src/ov-cell.cc	Thu May 22 22:00:26 2008 +0200
@@ -1080,7 +1080,9 @@
 	  string_vector s = args(0).all_strings ();
 
 	  if (! error_state)
-	    retval = Cell (s, true);
+	    retval = (s.is_empty ()
+                      ? Cell (octave_value (std::string ()))
+                      : Cell (s, true));
 	  else
 	    error ("cellstr: expecting argument to be a 2-d character array");
 	}