Skip to content

Commit 09ed342

Browse files
committed
process "\n" when finishing up lexer.
1 parent 0c96252 commit 09ed342

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

mpw-shell.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ void init(Environment &env) {
6060
int read_file(phase1 &p, const std::string &file) {
6161
const mapped_file mf(file, mapped_file::readonly);
6262

63-
p.process(mf.begin(), mf.end(), true);
64-
63+
p.process(mf.begin(), mf.end(), false);
64+
p.finish();
6565
return 0;
6666
}
6767

@@ -227,7 +227,7 @@ int main(int argc, char **argv) {
227227
if (cflag) {
228228
std::string s(cflag);
229229
s.push_back('\n');
230-
p1.process(s.data(), s.data() + s.length(), true);
230+
p1.process(s, true);
231231
p2.finish();
232232
exit(e.status());
233233
}

phase1.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class phase1 {
1818
process((const unsigned char *)begin, (const unsigned char *)end, final);
1919
}
2020

21-
void process(const std::string &s) { process(s.data(), s.data() + s.size()); }
21+
void process(const std::string &s, bool final = false) { process(s.data(), s.data() + s.size(), final); }
2222

23-
void finish() { const char *tmp = ""; process(tmp, tmp, true); }
23+
void finish() { const char *tmp = "\n"; process(tmp, tmp+1, true); }
2424

2525
void reset();
2626

0 commit comments

Comments
 (0)