From 84537b81bd210ba5eadf618a7858be7db1ae4350 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 20 Apr 2017 12:44:38 -0700 Subject: 3839 Fix CI. In the process I also fixed a bug in the tangle/ utility. --- tangle/003tangle.cc | 9 ++++++--- tangle/003tangle.test.cc | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'tangle') diff --git a/tangle/003tangle.cc b/tangle/003tangle.cc index 3573c11f..7eb62f27 100644 --- a/tangle/003tangle.cc +++ b/tangle/003tangle.cc @@ -251,10 +251,13 @@ void slurp_tangle_string(istream& in, ostream& out) { in.get(); char c; while (in >> c) { - if (c == '\\') // only works for double-quotes + if (c == '\\') { + // skip backslash and save next character unconditionally + in >> c; + out << c; continue; - if (c == '"') - break; + } + if (c == '"') break; out << c; } } diff --git a/tangle/003tangle.test.cc b/tangle/003tangle.test.cc index 88901ef7..6d6b88a7 100644 --- a/tangle/003tangle.test.cc +++ b/tangle/003tangle.test.cc @@ -76,6 +76,20 @@ void test_tangle_with_tanglecomments_inside_directive() { CHECK_TRACE_DOESNT_CONTAIN("tangle", "//: 1"); } +void test_tangle_with_multiword_directives() { + istringstream in("a b\nc\n:(after \"a b\")\nd\n"); + list dummy; + tangle(in, dummy); + CHECK_TRACE_CONTENTS("tangle", "a bdc"); +} + +void test_tangle_with_quoted_multiword_directives() { + istringstream in("a \"b\"\nc\n:(after \"a \\\"b\\\"\")\nd\n"); + list dummy; + tangle(in, dummy); + CHECK_TRACE_CONTENTS("tangle", "a \"b\"dc"); +} + void test_tangle2() { istringstream in("a\nb\nc\n:(after b)\nd\n"); list dummy; -- cgit 1.4.1-2-gfad0