changeset 11129:0de5cc44e690

use gripe functions for NaN to logical and NaN to character conversions more consistently
author John W. Eaton <jwe@octave.org>
date Thu, 21 Oct 2010 16:12:00 -0400
parents 9cb5c0b7b43b
children 7c573eb981eb
files liboctave/Array-util.cc liboctave/Array-util.h liboctave/ChangeLog src/ChangeLog src/ops.h src/ov-base-mat.cc src/ov-base-scalar.cc src/ov-complex.h src/ov-cx-mat.cc src/ov-cx-sparse.cc src/ov-float.cc src/ov-float.h src/ov-flt-complex.h src/ov-flt-cx-mat.cc src/ov-flt-re-mat.cc src/ov-range.cc src/ov-re-mat.cc src/ov-re-sparse.cc src/ov-scalar.cc src/ov-scalar.h
diffstat 20 files changed, 50 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/Array-util.cc	Thu Oct 21 11:58:42 2010 -0700
+++ b/liboctave/Array-util.cc	Thu Oct 21 16:12:00 2010 -0400
@@ -661,7 +661,15 @@
 void
 gripe_nan_to_logical_conversion (void)
 {
-  (*current_liboctave_error_handler) ("invalid conversion of NaN to logical");
+  (*current_liboctave_error_handler)
+    ("invalid conversion from NaN to logical");
+}
+
+void
+gripe_nan_to_character_conversion (void)
+{
+  (*current_liboctave_error_handler)
+    ("invalid conversion from NaN to character");
 }
 
 void
--- a/liboctave/Array-util.h	Thu Oct 21 11:58:42 2010 -0700
+++ b/liboctave/Array-util.h	Thu Oct 21 16:12:00 2010 -0400
@@ -112,6 +112,8 @@
 
 extern void OCTAVE_API gripe_nan_to_logical_conversion (void);
 
+extern void OCTAVE_API gripe_nan_to_character_conversion (void);
+
 extern void OCTAVE_API gripe_nonconformant (const char *op, int op1_len, int op2_len);
 
 extern void OCTAVE_API gripe_nonconformant (const char *op, int op1_nr, int op1_nc,
--- a/liboctave/ChangeLog	Thu Oct 21 11:58:42 2010 -0700
+++ b/liboctave/ChangeLog	Thu Oct 21 16:12:00 2010 -0400
@@ -1,3 +1,8 @@
+2010-10-21  John W. Eaton  <jwe@octave.org>
+
+	* Array-util.cc (gripe_nan_to_character_conversion): New function.
+	* Array-util.h: Provide decl.
+
 2010-10-19  John W. Eaton  <jwe@octave.org>
 
 	* Makefile.am (INCS): Add caseless-str.h to the list.
--- a/src/ChangeLog	Thu Oct 21 11:58:42 2010 -0700
+++ b/src/ChangeLog	Thu Oct 21 16:12:00 2010 -0400
@@ -1,3 +1,13 @@
+2010-10-21  John W. Eaton  <jwe@octave.org>
+
+	* ov-float.cc, ov-flt-re-mat.cc, ov-re-mat.cc, ov-re-sparse.cc,
+	ov-scalar.cc: Use gripe_nan_to_character_conversion.
+
+	* ops.h, ov-base-mat.cc, ov-base-scalar.cc, ov-complex.h,
+	ov-cx-mat.cc, ov-cx-sparse.cc, ov-float.h, ov-flt-complex.h,
+	ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-range.cc, ov-re-mat.cc,
+	ov-re-sparse.cc, ov-scalar.h: Use gripe_nan_to_logical_conversion.
+
 2010-10-20  John W. Eaton  <jwe@octave.org>
 
 	* toplev.cc (Fsystem): Allow optional RETURN_OUTPUT and TYPE
--- a/src/ops.h	Thu Oct 21 11:58:42 2010 -0700
+++ b/src/ops.h	Thu Oct 21 16:12:00 2010 -0400
@@ -303,7 +303,7 @@
     CAST_BINOP_ARGS (const CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \
     if (xisnan (v1.CONCAT2(t1, _value) ()) || xisnan (v2.CONCAT2(t2, _value) ())) \
       { \
-        error ("invalid conversion from NaN to logical"); \
+        gripe_nan_to_logical_conversion (); \
         return octave_value (); \
       } \
     else \
--- a/src/ov-base-mat.cc	Thu Oct 21 11:58:42 2010 -0700
+++ b/src/ov-base-mat.cc	Thu Oct 21 16:12:00 2010 -0400
@@ -413,7 +413,7 @@
       MT t1 (matrix.reshape (dim_vector (nel, 1)));
 
       if (t1.any_element_is_nan ())
-        error ("invalid conversion from NaN to logical");
+        gripe_nan_to_logical_conversion ();
       else
         {
           boolNDArray t2 = t1.all ();
--- a/src/ov-base-scalar.cc	Thu Oct 21 11:58:42 2010 -0700
+++ b/src/ov-base-scalar.cc	Thu Oct 21 16:12:00 2010 -0400
@@ -128,7 +128,7 @@
   bool retval = false;
 
   if (xisnan (scalar))
-    error ("invalid conversion from NaN to logical");
+    gripe_nan_to_logical_conversion ();
   else
     retval = (scalar != ST ());
 
--- a/src/ov-complex.h	Thu Oct 21 11:58:42 2010 -0700
+++ b/src/ov-complex.h	Thu Oct 21 16:12:00 2010 -0400
@@ -138,7 +138,7 @@
   bool bool_value (bool warn = false) const
   {
     if (xisnan (scalar))
-      error ("invalid conversion from NaN to logical");
+      gripe_nan_to_logical_conversion ();
     else if (warn && scalar != 0.0 && scalar != 1.0)
       gripe_logical_conversion ();
 
@@ -148,7 +148,7 @@
   boolNDArray bool_array_value (bool warn = false) const
   {
     if (xisnan (scalar))
-      error ("invalid conversion from NaN to logical");
+      gripe_nan_to_logical_conversion ();
     else if (warn && scalar != 0.0 && scalar != 1.0)
       gripe_logical_conversion ();
 
--- a/src/ov-cx-mat.cc	Thu Oct 21 11:58:42 2010 -0700
+++ b/src/ov-cx-mat.cc	Thu Oct 21 16:12:00 2010 -0400
@@ -226,7 +226,7 @@
 octave_complex_matrix::bool_array_value (bool warn) const
 {
   if (matrix.any_element_is_nan ())
-    error ("invalid conversion from NaN to logical");
+    gripe_nan_to_logical_conversion ();
   else if (warn && (! matrix.all_elements_are_real () 
                     || real (matrix).any_element_not_one_or_zero ()))
     gripe_logical_conversion ();
--- a/src/ov-cx-sparse.cc	Thu Oct 21 11:58:42 2010 -0700
+++ b/src/ov-cx-sparse.cc	Thu Oct 21 16:12:00 2010 -0400
@@ -215,7 +215,7 @@
 octave_sparse_complex_matrix::sparse_bool_matrix_value (bool warn) const
 {
   if (matrix.any_element_is_nan ())
-    error ("invalid conversion from NaN to logical");
+    gripe_nan_to_logical_conversion ();
   else if (warn && (! matrix.all_elements_are_real () 
                     || real (matrix).any_element_not_one_or_zero ()))
     gripe_logical_conversion ();
--- a/src/ov-float.cc	Thu Oct 21 11:58:42 2010 -0700
+++ b/src/ov-float.cc	Thu Oct 21 16:12:00 2010 -0400
@@ -104,7 +104,7 @@
   octave_value retval;
 
   if (xisnan (scalar))
-    ::error ("invalid conversion from NaN to character");
+    gripe_nan_to_character_conversion ();
   else
     {
       int ival = NINT (scalar);
--- a/src/ov-float.h	Thu Oct 21 11:58:42 2010 -0700
+++ b/src/ov-float.h	Thu Oct 21 16:12:00 2010 -0400
@@ -195,7 +195,7 @@
   bool bool_value (bool warn = false) const
   {
     if (xisnan (scalar))
-      error ("invalid conversion from NaN to logical");
+      gripe_nan_to_logical_conversion ();
     else if (warn && scalar != 0 && scalar != 1)
       gripe_logical_conversion ();
 
@@ -205,7 +205,7 @@
   boolNDArray bool_array_value (bool warn = false) const
   {
     if (xisnan (scalar))
-      error ("invalid conversion from NaN to logical");
+      gripe_nan_to_logical_conversion ();
     else if (warn && scalar != 0 && scalar != 1)
       gripe_logical_conversion ();
 
--- a/src/ov-flt-complex.h	Thu Oct 21 11:58:42 2010 -0700
+++ b/src/ov-flt-complex.h	Thu Oct 21 16:12:00 2010 -0400
@@ -136,7 +136,7 @@
   bool bool_value (bool warn = false) const
   {
     if (xisnan (scalar))
-      error ("invalid conversion from NaN to logical");
+      gripe_nan_to_logical_conversion ();
     else if (warn && scalar != 0.0f && scalar != 1.0f)
       gripe_logical_conversion ();
 
@@ -146,7 +146,7 @@
   boolNDArray bool_array_value (bool warn = false) const
   {
     if (xisnan (scalar))
-      error ("invalid conversion from NaN to logical");
+      gripe_nan_to_logical_conversion ();
     else if (warn && scalar != 0.0f && scalar != 1.0f)
       gripe_logical_conversion ();
 
--- a/src/ov-flt-cx-mat.cc	Thu Oct 21 11:58:42 2010 -0700
+++ b/src/ov-flt-cx-mat.cc	Thu Oct 21 16:12:00 2010 -0400
@@ -215,7 +215,7 @@
 octave_float_complex_matrix::bool_array_value (bool warn) const
 {
   if (matrix.any_element_is_nan ())
-    error ("invalid conversion from NaN to logical");
+    gripe_nan_to_logical_conversion ();
   else if (warn && (! matrix.all_elements_are_real () 
                     || real (matrix).any_element_not_one_or_zero ()))
     gripe_logical_conversion ();
--- a/src/ov-flt-re-mat.cc	Thu Oct 21 11:58:42 2010 -0700
+++ b/src/ov-flt-re-mat.cc	Thu Oct 21 16:12:00 2010 -0400
@@ -216,7 +216,7 @@
 octave_float_matrix::bool_array_value (bool warn) const
 {
   if (matrix.any_element_is_nan ())
-    error ("invalid conversion from NaN to logical");
+    gripe_nan_to_logical_conversion ();
   else if (warn && matrix.any_element_not_one_or_zero ())
     gripe_logical_conversion ();
 
@@ -283,7 +283,7 @@
 
       if (xisnan (d))
         {
-          ::error ("invalid conversion from NaN to character");
+          gripe_nan_to_character_conversion ();
           return retval;
         }
       else
--- a/src/ov-range.cc	Thu Oct 21 11:58:42 2010 -0700
+++ b/src/ov-range.cc	Thu Oct 21 16:12:00 2010 -0400
@@ -317,7 +317,7 @@
   Matrix m = range.matrix_value ();
 
   if (m.any_element_is_nan ())
-    error ("invalid conversion from NaN to logical");
+    gripe_nan_to_logical_conversion ();
   else if (warn && m.any_element_not_one_or_zero ())
     gripe_logical_conversion ();
 
--- a/src/ov-re-mat.cc	Thu Oct 21 11:58:42 2010 -0700
+++ b/src/ov-re-mat.cc	Thu Oct 21 16:12:00 2010 -0400
@@ -225,7 +225,7 @@
 octave_matrix::bool_array_value (bool warn) const
 {
   if (matrix.any_element_is_nan ())
-    error ("invalid conversion from NaN to logical");
+    gripe_nan_to_logical_conversion ();
   else if (warn && matrix.any_element_not_one_or_zero ())
     gripe_logical_conversion ();
 
@@ -385,7 +385,7 @@
 
       if (xisnan (d))
         {
-          ::error ("invalid conversion from NaN to character");
+          gripe_nan_to_character_conversion ();
           return retval;
         }
       else
--- a/src/ov-re-sparse.cc	Thu Oct 21 11:58:42 2010 -0700
+++ b/src/ov-re-sparse.cc	Thu Oct 21 16:12:00 2010 -0400
@@ -145,7 +145,7 @@
   NDArray m = matrix.matrix_value ();
 
   if (m.any_element_is_nan ())
-    error ("invalid conversion from NaN to logical");
+    gripe_nan_to_logical_conversion ();
   else if (warn && m.any_element_not_one_or_zero ())
     gripe_logical_conversion ();
 
@@ -188,7 +188,7 @@
 octave_sparse_matrix::sparse_bool_matrix_value (bool warn) const
 {
   if (matrix.any_element_is_nan ())
-    error ("invalid conversion from NaN to logical");
+    gripe_nan_to_logical_conversion ();
   else if (warn && matrix.any_element_not_one_or_zero ())
     gripe_logical_conversion ();
 
@@ -225,7 +225,7 @@
 
               if (xisnan (d))
                 {
-                  ::error ("invalid conversion from NaN to character");
+                  gripe_nan_to_character_conversion ();
                   return retval;
                 }
               else
--- a/src/ov-scalar.cc	Thu Oct 21 11:58:42 2010 -0700
+++ b/src/ov-scalar.cc	Thu Oct 21 16:12:00 2010 -0400
@@ -119,7 +119,7 @@
   octave_value retval;
 
   if (xisnan (scalar))
-    ::error ("invalid conversion from NaN to character");
+    gripe_nan_to_character_conversion ();
   else
     {
       int ival = NINT (scalar);
--- a/src/ov-scalar.h	Thu Oct 21 11:58:42 2010 -0700
+++ b/src/ov-scalar.h	Thu Oct 21 16:12:00 2010 -0400
@@ -196,7 +196,7 @@
   bool bool_value (bool warn = false) const
   {
     if (xisnan (scalar))
-      error ("invalid conversion from NaN to logical");
+      gripe_nan_to_logical_conversion ();
     else if (warn && scalar != 0 && scalar != 1)
       gripe_logical_conversion ();
 
@@ -206,7 +206,7 @@
   boolNDArray bool_array_value (bool warn = false) const
   {
     if (xisnan (scalar))
-      error ("invalid conversion from NaN to logical");
+      gripe_nan_to_logical_conversion ();
     else if (warn && scalar != 0 && scalar != 1)
       gripe_logical_conversion ();