# HG changeset patch # User John W. Eaton # Date 1232056755 18000 # Node ID 6b074f37e8d76b4435dc8c1086f41f45baaf2121 # Parent 17e0ad741fac363cfe72d8b0290a6e9bc379f4e7 reshape: improve error message diff -r 17e0ad741fac -r 6b074f37e8d7 liboctave/Array.cc --- a/liboctave/Array.cc Thu Jan 15 14:58:49 2009 -0500 +++ b/liboctave/Array.cc Thu Jan 15 16:59:15 2009 -0500 @@ -442,9 +442,14 @@ if (dimensions.numel () == new_dims.numel ()) retval = Array (*this, new_dims); else - (*current_liboctave_error_handler) - ("reshape: size mismatch (%s != %s)", dimensions.str (), - new_dims.str ()); + { + std::string dimensions_str = dimensions.str (); + std::string new_dims_str = new_dims.str (); + + (*current_liboctave_error_handler) + ("reshape: can't reshape %s array to %s array", + dimensions_str.c_str (), new_dims_str.c_str ()); + } } else retval = *this; diff -r 17e0ad741fac -r 6b074f37e8d7 liboctave/Sparse.cc --- a/liboctave/Sparse.cc Thu Jan 15 14:58:49 2009 -0500 +++ b/liboctave/Sparse.cc Thu Jan 15 16:59:15 2009 -0500 @@ -796,9 +796,14 @@ retval.xcidx(k+1) = new_nnz; } else - (*current_liboctave_error_handler) - ("reshape: size mismatch (%s != %s)", dimensions.str (), - new_dims.str ()); + { + std::string dimensions_str = dimensions.str (); + std::string new_dims_str = new_dims.str (); + + (*current_liboctave_error_handler) + ("reshape: can't reshape %s array to %s array", + dimensions_str.c_str (), new_dims_str.c_str ()); + } } else retval = *this; diff -r 17e0ad741fac -r 6b074f37e8d7 src/data.cc --- a/src/data.cc Thu Jan 15 14:58:49 2009 -0500 +++ b/src/data.cc Thu Jan 15 16:59:15 2009 -0500 @@ -4542,7 +4542,13 @@ if (new_dims.numel () == dims.numel ()) retval = (new_dims == dims) ? arg : arg.reshape (new_dims); else - error ("reshape: size mismatch (%s != %s)", dims.str (), new_dims.str ()); + { + std::string dims_str = dims.str (); + std::string new_dims_str = new_dims.str (); + + error ("reshape: can't reshape %s array to %s array", + dims_str.c_str (), new_dims_str.c_str ()); + } return retval; }