octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #54415] The row_as_string( index ).c_str() met


From: Alan W. Irwin
Subject: [Octave-bug-tracker] [bug #54415] The row_as_string( index ).c_str() method of the octave-4 charMatrix class fails for strings longer than 15 bytes
Date: Wed, 1 Aug 2018 18:02:19 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.10.1 Chrome/61.0.3163.140 Safari/537.36 Konqueror (WebEnginePart)

Follow-up Comment #2, bug #54415 (project octave):

Thanks, Markus, for that useful advice.  Indeed, when I changed

tmp_cstring = (char *) temp_matrix.row_as_string( i ).c_str();
    
(where the tmp_cstring declaration was properly scoped)
    
to
    
str         = temp_matrix.row_as_string( i );
tmp_cstring = (char *) str.c_str();
    
(where both the str and tmp_cstring declarations were properly scoped)
    
in our own implemented swig typemap for the swig-generated octave bindings for
both hex_print2 and various PLplot functions that have const char **
arguments, all problems with long strings went away.  For example:

octave:3> hex_print2(["0123456789abcde";
"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"])
30 31 32 33 34 35 36 37 38 39 61 62 63 64 65  0 
0123456789abcde
30 31 32 33 34 35 36 37 38 39 61 62 63 64 65 66 30 31 32 33 34 35 36 37 38 39
61 62 63 64 65 66 30 31 32 33 34 35 36 37 38 39 61 62 63 64 65 66 30 31 32 33
34 35 36 37 38 39 61 62 63 64 65 66 30 31 32 33 34 35 36 37 38 39 61 62 63 64
65 66 30 31 32 33 34 35 36 37 38 39 61 62 63 64 65 66  0 
0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef

now works fine.  Also, the previous success for our swig-generated bindings
for the conversion of cell arrays of long strings is now explained because
that interface code always used the preferred style.

Thanks, once again for your key help in solving this issue, and please close
this bug with appropriate labels indicating not a direct octave issue but
solved anyway.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?54415>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]