[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #49536] many functions that expect a "string"
From: |
Mike Miller |
Subject: |
[Octave-bug-tracker] [bug #49536] many functions that expect a "string" silently truncate char matrix arguments (octave_value::string_value) |
Date: |
Wed, 23 Nov 2016 20:32:21 +0000 (UTC) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0 |
Follow-up Comment #8, bug #49536 (project octave):
The warning comes from the following backtrace
#0 octave_char_matrix_str::string_value[abi:cxx11](bool) const
(this=<optimized out>) at ../libinterp/octave-value/ov-str-mat.cc:238
#1 0x00007fe5b75c66bf in octave_char_matrix_str::short_disp (this=<optimized
out>, os=...) at ../libinterp/octave-value/ov-str-mat.cc:274
#2 0x00007fe5b7b4f25b in octave_value::short_disp (this=0x7fe57cfed9b0,
os=...) at ../libinterp/octave-value/ov.h:1228
#3 symbol_table::do_workspace_info[abi:cxx11]() const (this=0x7fe56019de80)
at ../libinterp/corefcn/symtab.cc:1507
#4 0x00007fe5b7abfbd9 in symbol_table::workspace_info[abi:cxx11](int)
(scope=1) at ../libinterp/corefcn/symtab.h:2095
#5 octave_link::set_workspace () at ../libinterp/corefcn/octave-link.cc:71
I am now using this change
diff --git a/libinterp/octave-value/ov-str-mat.cc
b/libinterp/octave-value/ov-str-mat.cc
--- a/libinterp/octave-value/ov-str-mat.cc
+++ b/libinterp/octave-value/ov-str-mat.cc
@@ -234,6 +234,9 @@ octave_char_matrix_str::string_value (bo
charMatrix chm (matrix);
+ if (chm.rows () > 1)
+ warning ("evaluating a character matrix as a string, only the first row
is used");
+
// FIXME: Is this correct?
return chm.row_as_string (0);
}
@@ -268,7 +271,8 @@ octave_char_matrix_str::short_disp (std:
{
if (matrix.ndims () == 2 && numel () > 0)
{
- std::string tmp = string_value ();
+ charMatrix chm (matrix);
+ std::string tmp = chm.row_as_string (0);
// FIXME: should this be configurable?
size_t max_len = 100;
and can now work with the GUI and run the full test suite in the GUI with no
warnings.
Needs some polish and a warning ID, but I think this is a good first start to
draw a line.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?49536>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #49536] many functions that expect a "string" silently truncate char matrix arguments (octave_value::string_value), Mike Miller, 2016/11/04
- [Octave-bug-tracker] [bug #49536] many functions that expect a "string" silently truncate char matrix arguments (octave_value::string_value), Ceral Paquet, 2016/11/05
- [Octave-bug-tracker] [bug #49536] many functions that expect a "string" silently truncate char matrix arguments (octave_value::string_value), Ceral Paquet, 2016/11/05
- [Octave-bug-tracker] [bug #49536] many functions that expect a "string" silently truncate char matrix arguments (octave_value::string_value), Philip Nienhuis, 2016/11/05
- [Octave-bug-tracker] [bug #49536] many functions that expect a "string" silently truncate char matrix arguments (octave_value::string_value), Mike Miller, 2016/11/07
- [Octave-bug-tracker] [bug #49536] many functions that expect a "string" silently truncate char matrix arguments (octave_value::string_value), Colin Macdonald, 2016/11/22
- [Octave-bug-tracker] [bug #49536] many functions that expect a "string" silently truncate char matrix arguments (octave_value::string_value), John W. Eaton, 2016/11/22
- Message not available
- [Octave-bug-tracker] [bug #49536] many functions that expect a "string" silently truncate char matrix arguments (octave_value::string_value),
Mike Miller <=
- [Octave-bug-tracker] [bug #49536] many functions that expect a "string" silently truncate char matrix arguments (octave_value::string_value), Rik, 2016/11/28