diff libinterp/octave-value/ov-flt-re-mat.cc @ 18196:1b6db9303933

allow toupper and tolower to handle numeric values (bug #33537) * ov-base-sparse.cc (octave_base_sparse<T>::map): Special case for umap_xtolower and umap_xtoupper. * ov-float.cc (octave_float_scalar::map): Likewise. * ov-flt-re-mat.cc (octave_float_matrix::map): Likewise. * ov-intx.h (OCTAVE_VALUE_INT_MATRIX_T::map, OCTAVE_VALUE_INT_SCALAR_T::map): Likewise. * ov-re-mat.cc (octave_matrix::map): Likewise. * ov-scalar.cc (octave_scalar::map): Likewise. * build-sparse-tests.sh, mappers.cc: Update tests.
author John W. Eaton <jwe@octave.org>
date Thu, 02 Jan 2014 22:44:37 -0500
parents 6a71e5030df5
children 0d5721873d6b
line wrap: on
line diff
--- a/libinterp/octave-value/ov-flt-re-mat.cc	Thu Jan 02 13:23:51 2014 -0800
+++ b/libinterp/octave-value/ov-flt-re-mat.cc	Thu Jan 02 22:44:37 2014 -0500
@@ -812,8 +812,21 @@
       ARRAY_MAPPER (isna, bool, octave_is_NA);
       ARRAY_MAPPER (xsignbit, float, xsignbit);
 
+    // Special cases for Matlab compatibility.
+    case umap_xtolower:
+    case umap_xtoupper:
+      return matrix;
+
     default:
-      return octave_base_value::map (umap);
+      // FIXME: this will break if some well-meaning person rearranges
+      // the enum list in ov-base.h.
+      if (umap >= umap_xisalnum && umap <= umap_xtoupper)
+        {
+          octave_value str_conv = convert_to_str (true, true);
+          return error_state ? octave_value () : str_conv.map (umap);
+        }
+      else
+        return octave_base_value::map (umap);
     }
 }