changeset 5400:c7e3cf2fce3e

[project @ 2005-07-05 15:01:32 by jwe]
author jwe
date Tue, 05 Jul 2005 15:01:32 +0000
parents db34dff19947
children f654f94c46af
files scripts/ChangeLog scripts/strings/dec2base.m scripts/strings/findstr.m src/ChangeLog src/ov-str-mat.cc src/ov-str-mat.h src/parse.y
diffstat 7 files changed, 45 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,11 @@
+2005-07-05  cctsim  <cctsim@yahoo.co.uk>
+
+	* strings/dec2base.m: Don't remove all leading zeros if result is zero.
+
+2005-07-05  John W. Eaton  <jwe@octave.org>
+
+	* strings/findstr.m: Return [] for no matches.
+
 2005-06-17  Keith Goodman  <kwgoodman@gmail.com>
 
 	* miscellaneous/tic.m: Fix doc string.
--- a/scripts/strings/dec2base.m
+++ b/scripts/strings/dec2base.m
@@ -95,7 +95,7 @@
   ## have a leading zero to remove.  But if LEN >= MAX_LEN, we should
   ## not remove any leading zeros.
   if ((nargin == 2 || (nargin == 3 && max_len > len))
-      && all (retval(:,1) == symbols(1)))
+      && all (retval(:,1) == symbols(1)) && length (retval) != 1)
     retval = retval(:,2:end);
   endif
 
--- a/scripts/strings/findstr.m
+++ b/scripts/strings/findstr.m
@@ -117,7 +117,11 @@
       v = v(find (keep));
     endif
   endif
-  
+
+  if (isempty (v))
+    v = [];
+  endif
+
   ## Always return a column vector, because that's what the old one did
   if (rows (v) > 1) 
     v = v.';
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,15 @@
+2005-07-05  John W. Eaton  <jwe@octave.org>
+
+	* ov-str-mat.cc (octave_char_matrix_str::do_index_op_internal):
+	Rename from char_matrix_str::do_index_op.  New arg, type.
+	ov-str-mat.h (octave_char_matrix_str::do_index_op): Define using
+	do_index_op_internal.
+	(octave_char_matrix_sq_str::do_index_op): New function.
+
+2005-07-01  John W. Eaton  <jwe@octave.org>
+
+	* parse.y (end_error): Also handle end_try_catch case.
+
 2005-06-17  John W. Eaton  <jwe@octave.org>
 
 	* help.cc (help_from_list, help_from_symbol_table, 
--- a/src/ov-str-mat.cc
+++ b/src/ov-str-mat.cc
@@ -81,8 +81,8 @@
 }
 
 octave_value
-octave_char_matrix_str::do_index_op (const octave_value_list& idx,
-				     int resize_ok)
+octave_char_matrix_str::do_index_op_internal (const octave_value_list& idx,
+					      int resize_ok, char type)
 {
   octave_value retval;
 
@@ -97,7 +97,7 @@
 
 	if (! error_state)
 	  retval = octave_value (charNDArray (matrix.index (i, j, resize_ok)),
-				 true);
+				 true, type);
       }
       break;
 
@@ -107,7 +107,7 @@
 
 	if (! error_state)
 	  retval = octave_value (charNDArray (matrix.index (i, resize_ok)),
-				 true);
+				 true, type);
       }
       break;
 
@@ -120,7 +120,7 @@
 
 	if (! error_state)
 	  retval = octave_value (charNDArray (matrix.index (idx_vec, resize_ok)),
-				 true);
+				 true, type);
       }
       break;
     }
--- a/src/ov-str-mat.h
+++ b/src/ov-str-mat.h
@@ -85,7 +85,8 @@
 
   type_conv_fcn numeric_conversion_function (void) const;
 
-  octave_value do_index_op (const octave_value_list& idx, int resize_ok);
+  octave_value do_index_op (const octave_value_list& idx, int resize_ok)
+    { return do_index_op_internal (idx, resize_ok); }
 
   void assign (const octave_value_list& idx, const charMatrix& rhs);
 
@@ -143,6 +144,11 @@
 	     oct_mach_info::float_format flt_fmt) const
     { return os.write (matrix, block_size, output_type, skip, flt_fmt); }
 
+protected:
+
+  octave_value do_index_op_internal (const octave_value_list& idx,
+				     int resize_ok, char type = '"');
+
 private:
 
   DECLARE_OCTAVE_ALLOCATOR
@@ -191,6 +197,9 @@
 
   bool is_sq_string (void) const { return true; }
 
+  octave_value do_index_op (const octave_value_list& idx, int resize_ok)
+    { return do_index_op_internal (idx, resize_ok, '\''); }
+
 private:
 
   DECLARE_OCTAVE_ALLOCATOR
--- a/src/parse.y
+++ b/src/parse.y
@@ -1478,6 +1478,10 @@
       error (fmt, type, "endwhile", l, c); 
       break;
 
+    case token::try_catch_end:
+      error (fmt, type, "end_try_catch", l, c); 
+      break;
+
     case token::unwind_protect_end:
       error (fmt, type, "end_unwind_protect", l, c); 
       break;