aboutsummaryrefslogtreecommitdiff
path: root/bbot/machine-manifest.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-05-10 18:46:42 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-05-11 17:56:04 +0300
commitdd1d5472bf28beba971d2b507fab53dec43939f7 (patch)
tree10d0f60e34012b339d1fb740d56a15487ccb1cf1 /bbot/machine-manifest.cxx
parentb8232e40e605b60234dae7ef92f257bab5c47723 (diff)
Allow multi-line machine manifest options value
Diffstat (limited to 'bbot/machine-manifest.cxx')
-rw-r--r--bbot/machine-manifest.cxx35
1 files changed, 29 insertions, 6 deletions
diff --git a/bbot/machine-manifest.cxx b/bbot/machine-manifest.cxx
index 7f9a030..b7baf7e 100644
--- a/bbot/machine-manifest.cxx
+++ b/bbot/machine-manifest.cxx
@@ -4,10 +4,14 @@
#include <bbot/machine-manifest.hxx>
+#include <sstream>
+
+#include <libbutl/tab-parser.hxx>
#include <libbutl/string-parser.hxx>
#include <libbutl/manifest-parser.hxx>
#include <libbutl/manifest-serializer.hxx>
+using namespace std;
using namespace butl;
namespace bbot
@@ -64,9 +68,16 @@ namespace bbot
throw parsing (p.name (), nv.name_line, nv.name_column, d);
};
- auto bad_value = [&p, &nv] (const string& d, size_t offset = 0)
+ // Offsets are used to tie an error to the specific position inside a
+ // manifest value (possibly a multiline one).
+ //
+ auto bad_value = [&p, &nv] (
+ const string& d, uint64_t column_offset = 0, uint64_t line_offset = 0)
{
- throw parsing (p.name (), nv.value_line, nv.value_column + offset, d);
+ throw parsing (p.name (),
+ nv.value_line + line_offset,
+ (line_offset == 0 ? nv.value_column : 1) + column_offset,
+ d);
};
optional<machine_type> type;
@@ -106,14 +117,26 @@ namespace bbot
strings op;
+ // Note that when reporting errors we combine the manifest value
+ // position with the respective error position.
+ //
try
{
- op = string_parser::parse_quoted (v, false);
+ istringstream is (v);
+ tab_parser parser (is, "");
+
+ tab_fields tl;
+ while (!(tl = parser.next ()).empty ())
+ {
+ for (auto& tf: tl)
+ op.emplace_back (move (tf.value));
+ }
}
- catch (const invalid_string& e)
+ catch (const tab_parsing& e)
{
- bad_value (string ("invalid machine options: ") + e.what (),
- e.position);
+ bad_value ("invalid machine options: " + e.description,
+ e.column - 1,
+ e.line - 1);
}
if (op.empty ())