From bug-request at octave dot org Thu Dec 16 08:21:55 2004 Subject: RE: Possible Error in -ascii save/restore From: "John W. Eaton" To: Cc: , Date: Thu, 16 Dec 2004 09:22:53 -0500 On 16-Dec-2004, Hallvard dot Paulsen at wartsila dot com wrote: | I've done a experiment, and it is likely that it is a line-termination | error. Yes I realize that. | The experiment was as follows: | $ octave | octave:1> vect = [1, 2, 3] | vect = | | 1 2 3 | | octave:2> save test | octave:3> quit | $ dos2unix test | test: done. | $ octave | octave:1> load test | octave:2> vect | vect = | | 1 2 3 | | octave:3> quit | | Other cygwin tools do not seam to care what type of line-termination is | used.. I think the bug is in the octave_matrix::load_ascii function in src/ov-re-mat.cc: octave_matrix::load_ascii (std::istream& is) { int mdims = 0; bool success = true; std::streampos pos = is.tellg (); if (extract_keyword (is, "ndims", mdims, true)) { if (mdims >= 0) { dim_vector dv; dv.resize (mdims); for (int i = 0; i < mdims; i++) is >> dv(i); NDArray tmp(dv); is >> tmp; if (!is) { error ("load: failed to load matrix constant"); success = false; } matrix = tmp; } else { error ("load: failed to extract number of rows and columns"); success = false; } } else { int nr = 0; int nc = 0; // re-read the same line again is.clear (); is.seekg (pos); if (extract_keyword (is, "rows", nr) && nr >= 0 && extract_keyword (is, "columns", nc) && nc >= 0) { if (nr > 0 && nc > 0) { Matrix tmp (nr, nc); is >> tmp; if (is) matrix = tmp; else { error ("load: failed to load matrix constant"); success = false; } } else if (nr == 0 || nc == 0) matrix = Matrix (nr, nc); else panic_impossible (); } else { error ("load: failed to extract number of rows and columns"); success = false; } } return success; } Note the is.tellg() and is.seekg(). I think this is failing when the filesystem is mounted in text mode because then there is some translation going on for CRLF pairs. Is this a bug in Octave or the way the Cygwin text mode filesystem works? All we want Octave to do here is return to the previous location in the file and read again. jwe ------------------------------------------------------------- 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 -------------------------------------------------------------