octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #50102] dlmread crashing the interpreter on Cy


From: Dan Sebald
Subject: [Octave-bug-tracker] [bug #50102] dlmread crashing the interpreter on Cygwin
Date: Sun, 19 Mar 2017 03:53:38 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0

Follow-up Comment #16, bug #50102 (project octave):

Is it always true that cmax gets incremented?  There is a conditional there:


              // Separator followed by EOL doesn't generate extra column
              if (pos2 != std::string::npos)
                cmax++;
[snip]
            }
          while (pos2 != std::string::npos);


If pos2 equals -1 (i.e., std::string::npos), then cmax is not incremented and
the while loop exits.

Let's say the file has only one column.  Then there is no "sep" to be found
and cmax isn't incremented.  Is that possible?  (It's difficult to follow.) 
And if that happens, then


          // FIXME: Should always be the case that iscmplx == false.
          //        Flag is initialized that way and no data has been read.
          if (iscmplx)
            cdata.resize (rmax, cmax, empty_value);
          else
            rdata.resize (rmax, cmax, empty_value);


where rmax = 32 and cmax = 0, which I wonder is valid.

Let me think about this, but just ask you if you think there should be
something added like the following:


       // Estimate the number of columns from first line of data.
       if (cmax == 0)
         {
           size_t pos1, pos2;
           if (auto_sep_is_wspace)
             pos1 = line.find_first_not_of (" \t");
           else
             pos1 = 0;
+          cmax = 1;


That is, upon finding the first non-blank line there is automatically one
column and then an additional column is added for every separator found.  In
other words, cmax is the number of separators plus 1.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?50102>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]