From 93612d7e1df8898d2b18fa535bacf84eabe48066 Mon Sep 17 00:00:00 2001 From: Joel Beckmeyer Date: Mon, 24 Apr 2017 22:55:37 -0400 Subject: [PATCH] implement new method to make file parsing more robust --- src/Simulation.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Simulation.cpp b/src/Simulation.cpp index ea90ec0..58b6835 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -19,10 +19,10 @@ bool Simulation::parseCircuit(string fileName) // get rid of first line getline(in, tmpString); - while (!in.eof()) { - in >> tmpType; - in >> tmpString; - in >> tmp1; + while (true) { + if (!(in >> tmpType)) break; + if (!(in >> tmpString)) break; + if (!(in >> tmp1)) break; if (tmpType == "INPUT" || tmpType == "OUTPUT") { tmpWire = findWire(tmp1); @@ -117,11 +117,11 @@ bool Simulation::parseVector(string fileName) { // get rid of first line getline(in, tmpString); - while(!in.eof()) { - in >> tmpString; - in >> tmpString; - in >> timeInt; - in >> valInt; + while(true) { + if (!(in >> tmpString)) break; + if (!(in >> tmpString)) break; + if (!(in >> tmpInt)) break; + if (!(in >> valInt)) break; for(auto i = wires.begin(); i != wires.end(); ++i) { if((**i).getName() == tmpString) {