Ignore:
Timestamp:
Dec 15, 2005, 1:46:38 PM (16 years ago)
Author:
Markus Ringnér
Message:

Fixed istream parsing when separator is last on line: a trailing NaN is generated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/gslapi/matrix.cc

    r434 r439  
    5656      std::string element;
    5757      std::stringstream ss(line);
     58     
    5859      bool ok=true;
    5960      while(ok) {
     
    7778        }
    7879      }           
     80      if(sep!='\0' && line[line.size()-1]==sep) // add NaN for final separator
     81          v.push_back(std::numeric_limits<double>::quiet_NaN());
    7982      if (!nof_columns)
    8083        nof_columns=v.size();
     
    8285        std::ostringstream s;
    8386        s << "matrix::matrix(std::istream&, char) data file error: "
    84           << "line" << nof_rows+1 << " has " << v.size()
     87          << "line" << nof_rows << " has " << v.size()
    8588          << " columns; expected " << nof_columns << " columns.";
    8689        throw utility::IO_error(s.str());
Note: See TracChangeset for help on using the changeset viewer.