hi,

i have spotted a small misfunctioning of textread.cc
when reading empty files.

$ rm -f test.txt;touch test.txt
$ octave -q
octave:1> [a,b]=textread("test.txt","%f %f")
a = [](0x0)
error: element number 2 undefined in return list
error: evaluating assignment expression near line 1, column 6

it would be more appropriate to have no error issued and get an
empty b.

I don't have a patch as I don't understand the code completely. I guess
a fix needs to be applied  to the final loop below. insert an empty
value when cl or ml is zero?

    dim_vector dim(1, nr_rows);
    for (unsigned int i = 0; i < input.columns.size(); i++) {
        long unsigned int cl = cell_output[i].length();
        long unsigned int ml = matrix_output[i].length();

        if ((cl == 0) && (ml == 0)) {
            continue;
        }
        else if (cl == 0) {
            matrix_output[i].resize(1, nr_rows);
            retval.append(octave_value(matrix_output[i].transpose()));
        } else {
            cell_output[i].resize(dim);
            retval.append(octave_value(cell_output[i].transpose()));
        }
    }

cheers, eric
-- 
View this message in context: 
http://www.nabble.com/misfunctioning-of-textread.cc-tp23314910p23314910.html
Sent from the octave-dev mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to