From bug-octave-request at bevo dot che dot wisc dot edu Mon Jan 6 12:18:34 2003 Subject: bug in fread(fid,0) From: "John W. Eaton" To: Schloegl Alois Cc: bug-octave at bevo dot che dot wisc dot edu Date: Mon, 6 Jan 2003 12:17:51 -0600 On 6-Jan-2003, Schloegl Alois wrote: | Bug report for Octave 2.1.40 configured for i586-pc-linux-gnu | | Description: | ----------- | | fread(fid,0,'int16') returns more than 0 elements. | | Probably, it is interpreted as fread(fid,inf, 'int16') Please try the following patch. Thanks, jwe src/ChangeLog: 2003-01-06 John W. Eaton * oct-stream.cc (get_size): If only one dimension is specified and it is zero, also set the other dimension to zero instead of one. liboctave/ChangeLog: 2003-01-06 John W. Eaton * dMatrix.cc (Matrix::read): Set size and return immediately if there is nothing to read. Index: liboctave/dMatrix.cc =================================================================== RCS file: /usr/local/cvsroot/octave/liboctave/dMatrix.cc,v retrieving revision 1.93 diff -u -r1.93 dMatrix.cc --- liboctave/dMatrix.cc 4 Jan 2003 04:46:11 -0000 1.93 +++ liboctave/dMatrix.cc 6 Jan 2003 18:13:41 -0000 at @ -2443,6 +2443,16 @@ oct_data_conv::data_type dt, int skip, oct_mach_info::float_format flt_fmt) { + if (nr == 0 || nc == 0) + { + if (nr >= 0 && nc >= 0) + resize (nr, nc); + else + resize (0, 0); + + return 0; + } + int retval = -1; bool ok = true; Index: src/oct-stream.cc =================================================================== RCS file: /usr/local/cvsroot/octave/src/oct-stream.cc,v retrieving revision 1.82 diff -u -r1.82 oct-stream.cc --- src/oct-stream.cc 2 Jan 2003 03:14:42 -0000 1.82 +++ src/oct-stream.cc 6 Jan 2003 18:13:49 -0000 at @ -123,7 +123,8 @@ one_elt_size_spec = true; dnr = size (0); - dnc = 1.0; + + dnc = (dnr == 0.0) ? 0.0 : 1.0; } else if (sz_len == 2) { ------------------------------------------------------------- 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 -------------------------------------------------------------