logo       

`glob' and string array to cell conversion: msg#00073

gnu.octave.bugs

Subject: `glob' and string array to cell conversion

While using `glob' (2.1.64), the following code doesn't give the
expected results:

octave:1> for f = glob('*'), disp(f), end

I expected a printout of the files in the current directory, but,
because `glob' returns a cell array of dimension Nx1, instead one cell
array is printed.

Would a simple patch like the one below fix the problem, or is more
invasive surgery needed?

Regards
Stefan

--- Cell.cc 2005-01-20 16:28:50.000000000 +0200
+++ Cell.cc.new 2005-04-29 00:24:22.000000000 +0200
@@ -36,10 +36,10 @@ Cell::Cell (const string_vector& sv)

if (n > 0)
{
- resize (dim_vector (n, 1));
+ resize (dim_vector (1, n));

for (int i = 0; i < n; i++)
- elem(i,0) = sv[i];
+ elem(0,i) = sv[i];
}
}



-------------------------------------------------------------
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
-------------------------------------------------------------




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise