use getline in script parser

This commit is contained in:
wangjiacai 2022-01-14 14:40:45 +08:00
parent 8211247e87
commit 5acc341171

View File

@ -1,8 +1,7 @@
#include <script_parser.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <script_parser.h>
using namespace boost::unit_test; using namespace boost::unit_test;
using namespace std; using namespace std;
@ -13,10 +12,11 @@ int parseScript(const char* path) {
perror(path); perror(path);
return ENOENT; return ENOENT;
} else { } else {
std::stringstream strbuf; string line;
strbuf << script.rdbuf(); while(getline(script, line, '\n')) {
std::string contents(strbuf.str()); cout << line <<endl;
cout << contents << endl; }
script.close();
} }
return 0; return 0;