From bug-octave-request at bevo dot che dot wisc dot edu Fri Feb 22 20:29:17 2002 Subject: setstr problem From: "John W. Eaton" To: Kwasniak Miroslaw Cc: bug-octave at bevo dot che dot wisc dot edu, mirek@zind.ikem.pwr.wroc.pl Date: Fri, 22 Feb 2002 20:28:52 -0600 On 22-Feb-2002, Kwasniak Miroslaw wrote: | Bug report for Octave 2.1.35 configured for i386-pc-linux-gnu | | Description: | ----------- | | setstr(0) doesn't work while matrix of zeros is accepted and I can copy | single element | | Repeat-By: | --------- | | > Z0=setstr(0);Z1=setstr([0 0]);Z2=Z1(1); | > toascii(Z0) | ans = [](0x0) | > toascii(Z1) | ans = | | 0 0 | > toascii(Z2) | ans = 0 Please try the following patch. Thanks, jwe 2002-02-22 John W. Eaton * ov-scalar.cc (convert_to_str): Use octave_value (std::string) constructor instead of octave_value (char *) constructor so that setstr (0) will work. Index: ov-scalar.cc =================================================================== RCS file: /usr/local/cvsroot/octave/src/ov-scalar.cc,v retrieving revision 1.12 diff -u -r1.12 ov-scalar.cc --- ov-scalar.cc 1 Feb 2000 04:06:31 -0000 1.12 +++ ov-scalar.cc 23 Feb 2002 02:27:58 -0000 at @ -98,12 +98,8 @@ else { // XXX FIXME XXX -- warn about out of range conversions? - - int i = NINT (scalar); - char s[2]; - s[0] = (char) i; - s[1] = '\0'; - retval = octave_value (s); + + retval = octave_value (std::string (1, char (NINT (scalar)))); } 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 -------------------------------------------------------------