Mercurial > hg > octave-nkf
changeset 19596:2304ddfd736f stable
Restore warning Octave:num-to-str missing since 3.2.4 (bug #43814).
* data.cc (do_cat): New variable all_strings_p. Check and set all_strings_p
in for loop checking type of each argument to be concatenated. Call
gripe_implicit_conversion if ! all_strings_p and result_type is "char".
* pt-mat.cc: Include "gripes.h"
* pt-mat.cc (tree_matrix::rvalue1): New variable all_strings_p.
Call all_strings_p () to set all_strings_p. Call gripe_implicit_conversion if
! all_strings_p and result_type is "char".
author | Rik <rik@octave.org> |
---|---|
date | Sun, 14 Dec 2014 21:14:36 -0800 |
parents | 616f2b22787b |
children | 9887a930465f 93dd3457eef9 |
files | libinterp/corefcn/data.cc libinterp/parse-tree/pt-mat.cc |
diffstat | 2 files changed, 18 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/data.cc +++ b/libinterp/corefcn/data.cc @@ -1771,6 +1771,7 @@ { std::string result_type; + bool all_strings_p = true; bool all_sq_strings_p = true; bool all_dq_strings_p = true; bool all_real_p = true; @@ -1792,6 +1793,8 @@ else result_type = get_concat_class (result_type, args(i).class_name ()); + if (all_strings_p && ! args(i).is_string ()) + all_strings_p = false; if (all_sq_strings_p && ! args(i).is_sq_string ()) all_sq_strings_p = false; if (all_dq_strings_p && ! args(i).is_dq_string ()) @@ -1850,9 +1853,13 @@ { char type = all_dq_strings_p ? '"' : '\''; - maybe_warn_string_concat (all_dq_strings_p, all_sq_strings_p); - - charNDArray result = do_single_type_concat<charNDArray> (args, dim); + if (! all_strings_p) + gripe_implicit_conversion ("Octave:num-to-str", + "numeric", result_type); + else + maybe_warn_string_concat (all_dq_strings_p, all_sq_strings_p); + + charNDArray result = do_single_type_concat<charNDArray> (args, dim); retval = octave_value (result, type); }
--- a/libinterp/parse-tree/pt-mat.cc +++ b/libinterp/parse-tree/pt-mat.cc @@ -31,6 +31,7 @@ #include "data.h" #include "defun.h" #include "error.h" +#include "gripes.h" #include "oct-obj.h" #include "pt-arg-list.h" #include "pt-bp.h" @@ -926,6 +927,7 @@ { octave_value retval = Matrix (); + bool all_strings_p = false; bool all_sq_strings_p = false; bool all_dq_strings_p = false; bool all_empty_p = false; @@ -939,6 +941,7 @@ if (tmp && ! tmp.empty ()) { dim_vector dv = tmp.dims (); + all_strings_p = tmp.all_strings_p (); all_sq_strings_p = tmp.all_sq_strings_p (); all_dq_strings_p = tmp.all_dq_strings_p (); all_empty_p = tmp.all_empty_p (); @@ -983,7 +986,11 @@ { char type = all_dq_strings_p ? '"' : '\''; - maybe_warn_string_concat (all_dq_strings_p, all_sq_strings_p); + if (! all_strings_p) + gripe_implicit_conversion ("Octave:num-to-str", + "numeric", result_type); + else + maybe_warn_string_concat (all_dq_strings_p, all_sq_strings_p); charNDArray result (dv, Vstring_fill_char);