diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-10-21 01:08:09 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-10-21 01:13:27 -0700 |
commit | 66abe7c1bd54ca227b9e035d52a1c2f1ea387b5e (patch) | |
tree | 9fc885faa5b4878247d4411bd0d72c1c59cc5f92 /052tangle.cc | |
parent | 22d93b76718a9e260c1969adf53fc0559cf24355 (diff) | |
download | mu-66abe7c1bd54ca227b9e035d52a1c2f1ea387b5e.tar.gz |
3539
Always check if next_word() returned an empty string (if it hit eof). Thanks Rebecca Allard for running into a crash when a .mu file ends with '{' (without a following newline). Open question: how to express the constraint that next_word() should always check if its result is empty? Can *any* type system do that?! Even the usual constraint that we must use a result isn't iron-clad: you could save the result in a variable but then ignore it. Unless you go to Go's extraordinary lengths of considering any dead code an error.
Diffstat (limited to '052tangle.cc')
-rw-r--r-- | 052tangle.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/052tangle.cc b/052tangle.cc index 50c74076..8aaecbd1 100644 --- a/052tangle.cc +++ b/052tangle.cc @@ -34,6 +34,11 @@ Fragments_used.clear(); :(before "End Command Handlers") else if (command == "before") { string label = next_word(in); + if (label.empty()) { + assert(!has_data(in)); + raise << "incomplete 'before' block at end of file\n" << end(); + return result; + } recipe tmp; slurp_body(in, tmp); if (is_waypoint(label)) @@ -44,6 +49,11 @@ else if (command == "before") { } else if (command == "after") { string label = next_word(in); + if (label.empty()) { + assert(!has_data(in)); + raise << "incomplete 'after' block at end of file\n" << end(); + return result; + } recipe tmp; slurp_body(in, tmp); if (is_waypoint(label)) |