diff --git a/mpw-shell.cpp b/mpw-shell.cpp index 9400374..c6a8b0f 100644 --- a/mpw-shell.cpp +++ b/mpw-shell.cpp @@ -60,8 +60,8 @@ void init(Environment &env) { int read_file(phase1 &p, const std::string &file) { const mapped_file mf(file, mapped_file::readonly); - p.process(mf.begin(), mf.end(), true); - + p.process(mf.begin(), mf.end(), false); + p.finish(); return 0; } @@ -227,7 +227,7 @@ int main(int argc, char **argv) { if (cflag) { std::string s(cflag); s.push_back('\n'); - p1.process(s.data(), s.data() + s.length(), true); + p1.process(s, true); p2.finish(); exit(e.status()); } diff --git a/phase1.h b/phase1.h index c0b9e2c..36c29d1 100644 --- a/phase1.h +++ b/phase1.h @@ -18,9 +18,9 @@ public: process((const unsigned char *)begin, (const unsigned char *)end, final); } - void process(const std::string &s) { process(s.data(), s.data() + s.size()); } + void process(const std::string &s, bool final = false) { process(s.data(), s.data() + s.size(), final); } - void finish() { const char *tmp = ""; process(tmp, tmp, true); } + void finish() { const char *tmp = "\n"; process(tmp, tmp+1, true); } void reset();