From 82b502970ee59216f72302f7580866363e5de724 Mon Sep 17 00:00:00 2001 From: gereon Date: Sat, 1 Dec 2012 20:29:24 +0100 Subject: [PATCH] patched tra parser, test cases work now --- src/parser/readTraFile.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/parser/readTraFile.cpp b/src/parser/readTraFile.cpp index e5e58baf5..7bb653da9 100644 --- a/src/parser/readTraFile.cpp +++ b/src/parser/readTraFile.cpp @@ -135,7 +135,7 @@ sparse::StaticSparseMatrix * readTraFile(const char * filename) { uint_fast32_t maxnode; uint_fast32_t non_zero = makeFirstPass(file.data, maxnode); /* - * if first pass returned zer, the file format was wrong + * if first pass returned zero, the file format was wrong */ if (non_zero == 0) throw mrmc::exceptions::wrong_file_format(); @@ -174,22 +174,29 @@ sparse::StaticSparseMatrix * readTraFile(const char * filename) { /* * read all transitions from file */ - while (1) + while (buf[0] != '\0') { /* * read row, col and value. if value == 0.0, we have reached the * end of the file. */ row = strtol(buf, &buf, 10); + if ((buf[0] != ' ') && (buf[0] != '\t')) throw mrmc::exceptions::wrong_file_format(); + col = strtol(buf, &buf, 10); + if ((buf[0] != ' ') && (buf[0] != '\t')) throw mrmc::exceptions::wrong_file_format(); + val = strtod(buf, &buf); + if ((buf[0] != '\n') && (buf[0] != '\r')) throw mrmc::exceptions::wrong_file_format(); + if (val == 0.0) break; pantheios::log_DEBUG("Write value ", pantheios::real(val), " to position ", pantheios::integer(row), " x ", pantheios::integer(col)); - sp->addNextValue(row,col,val); + sp->addNextValue(row,col,val); + buf = skipWS(buf); } /*