changeset 20213:ca2da088eada stable

Return an empty matrix, not error, from dlmread when file is empty (bug #45156). * dlmread.cc (Fdlmread): Only extract data from matrix if there is data to extract. Otherwise, return a null matrix.
author Rik <rik@octave.org>
date Thu, 21 May 2015 15:57:57 -0700
parents 6af35d4f1ba4
children 9866b3202c52
files libinterp/corefcn/dlmread.cc
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/dlmread.cc	Wed May 20 10:15:20 2015 -0600
+++ b/libinterp/corefcn/dlmread.cc	Thu May 21 15:57:57 2015 -0700
@@ -474,11 +474,14 @@
       if (c1 >= c)
         c1 = c - 1;
 
-      // Now take the subset of the matrix.
-      if (iscmplx)
-        cdata = cdata.extract (0, c0, r1, c1);
-      else
-        rdata = rdata.extract (0, c0, r1, c1);
+      // Now take the subset of the matrix if there are any values.
+      if (i > 0 || j > 0)
+        {
+          if (iscmplx)
+            cdata = cdata.extract (0, c0, r1, c1);
+          else
+            rdata = rdata.extract (0, c0, r1, c1);
+        }
 
       if (iscmplx)
         retval(0) = cdata;