about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
Diffstat (limited to 'subx')
-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);