diff options
Diffstat (limited to 'bbot')
-rw-r--r-- | bbot/machine-manifest.cxx | 35 |
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 ()) |