From bug-octave-request at bevo dot che dot wisc dot edu Fri Jan 23 08:23:08 2004 Subject: cellstr From: "John W. Eaton" To: Stefan van der Walt Cc: bug-octave at bevo dot che dot wisc dot edu Date: Fri, 23 Jan 2004 08:22:21 -0600 On 23-Jan-2004, Stefan van der Walt wrote: | Under Octave 2.1.50 I have the following strange behavior: | | octave:1> cellstr({'123'}) | panic: Segmentation fault -- stopping myself... Please try the following patch. Thanks, jwe src/ChangeLog: 2004-01-23 John W. Eaton * ov-cell.cc (all_strings): Always compute total required length of retval. Index: src/ov-cell.cc =================================================================== RCS file: /usr/local/cvsroot/octave/src/ov-cell.cc,v retrieving revision 1.34 diff -u -r1.34 ov-cell.cc --- src/ov-cell.cc 22 Jan 2004 04:26:19 -0000 1.34 +++ src/ov-cell.cc 23 Jan 2004 14:21:56 -0000 at @ -280,24 +280,21 @@ int max_len = 0; - if (pad) + for (int j = 0; j < nc; j++) { - for (int j = 0; j < nc; j++) + for (int i = 0; i < nr; i++) { - for (int i = 0; i < nr; i++) - { - string_vector s = matrix(i,j).all_strings (); + string_vector s = matrix(i,j).all_strings (); - if (error_state) - return retval; + if (error_state) + return retval; - n_elts += s.length (); + n_elts += s.length (); - int s_max_len = s.max_length (); + int s_max_len = s.max_length (); - if (s_max_len > max_len) - max_len = s_max_len; - } + if (s_max_len > max_len) + max_len = s_max_len; } } at @ -326,8 +323,6 @@ } } - - return retval; } ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------