From c436586303842c199e3d1078480ac4ea5cceb061 Mon Sep 17 00:00:00 2001 From: gereon Date: Wed, 5 Dec 2012 22:30:58 +0100 Subject: [PATCH] fixing error if lab file contains no trailing newline --- src/parser/readLabFile.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parser/readLabFile.cpp b/src/parser/readLabFile.cpp index ba56c44a0..ebcacd099 100644 --- a/src/parser/readLabFile.cpp +++ b/src/parser/readLabFile.cpp @@ -63,7 +63,7 @@ LabParser::LabParser(uint_fast64_t node_count, const char * filename) { size_t cnt = 0; /* - * iterate over tokens while not at end of file + * iterate over tokens until we hit #END or end of file */ while(buf[0] != '\0') { @@ -81,7 +81,7 @@ LabParser::LabParser(uint_fast64_t node_count, const char * filename) foundDecl = true; continue; } - if (strncmp(buf, "#END", cnt) == 0) + else if (strncmp(buf, "#END", cnt) == 0) { foundEnd = true; break; @@ -171,7 +171,7 @@ LabParser::LabParser(uint_fast64_t node_count, const char * filename) * parse node number, then iterate over propositions */ node = checked_strtol(buf, &buf); - while (buf[0] != '\n') + while ((buf[0] != '\n') && (buf[0] != '\0')) { cnt = strcspn(buf, separator); if (cnt == 0)