about summary refs log tree commit diff stats
path: root/subx/011run.cc
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-09-30 23:14:01 -0700
committerKartik Agaram <vc@akkartik.com>2018-09-30 23:14:01 -0700
commit69b004f59b145b85803f9072528d0885bac53690 (patch)
treed6584dbd1ca8d0624d562e8821724e03bf86ac07 /subx/011run.cc
parent79c7700b4080108ea6e4379915160e4f836505a9 (diff)
downloadmu-69b004f59b145b85803f9072528d0885bac53690.tar.gz
4626
Diffstat (limited to 'subx/011run.cc')
-rw-r--r--subx/011run.cc19
1 files changed, 9 insertions, 10 deletions
diff --git a/subx/011run.cc b/subx/011run.cc
index b3fc7684..b7cf280f 100644
--- a/subx/011run.cc
+++ b/subx/011run.cc
@@ -147,11 +147,7 @@ void parse(istream& fin, program& out) {
       if (word_data[0] == '#') break;  // comment
       if (word_data == ".") continue;  // comment token
       if (word_data == "==") {
-        if (!l.empty()) {
-          assert(!out.segments.empty());
-          trace(99, "parse") << "flushing to segment" << end();
-          out.segments.back().lines.swap(l);
-        }
+        flush(out, l);
         segment s;
         string segment_title;
         lin >> segment_title;
@@ -173,14 +169,17 @@ void parse(istream& fin, program& out) {
     if (!curr.words.empty())
       l.push_back(curr);
   }
-  if (!l.empty()) {
-    assert(!out.segments.empty());
-    trace(99, "parse") << "flushing to segment" << end();
-    out.segments.back().lines.swap(l);
-  }
+  flush(out, l);
   trace(99, "parse") << "done" << end();
 }
 
+void flush(program& p, vector<line>& lines) {
+  if (lines.empty()) return;
+  assert(!p.segments.empty());
+  trace(99, "parse") << "flushing to segment" << end();
+  p.segments.back().lines.swap(lines);
+}
+
 void parse_word(const string& data, word& out) {
   out.original = data;
   istringstream win(data);