diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-02 15:16:40 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-02 15:16:40 -0400 |
commit | 46b35a015bc72a7ecf03a296f6dc20917c6ae7f0 (patch) | |
tree | 5af195d22e39712019ace139a4ab0770bd0fb291 /src/item.cc | |
parent | cf9b4a38739426e4993fac49798ebe7dcfa11d62 (diff) | |
download | fork-ledger-46b35a015bc72a7ecf03a296f6dc20917c6ae7f0.tar.gz fork-ledger-46b35a015bc72a7ecf03a296f6dc20917c6ae7f0.tar.bz2 fork-ledger-46b35a015bc72a7ecf03a296f6dc20917c6ae7f0.zip |
Don't allow implicit matching of strings against masks, =~ is needed.
Diffstat (limited to 'src/item.cc')
-rw-r--r-- | src/item.cc | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/item.cc b/src/item.cc index 6e820b8d..2fe7601c 100644 --- a/src/item.cc +++ b/src/item.cc @@ -141,18 +141,29 @@ namespace { value_t& arg(args[0]); if (arg.is_string()) { - if (args.size() == 1) + if (args.size() == 1) { return item.has_tag(args[0].as_string()); - else if (optional<string> tag = item.get_tag(args[0].as_string())) - return args[1] == string_value(*tag); + } + else if (optional<string> tag = item.get_tag(args[0].as_string())) { + if (args[1].is_string()) { + return args[1].as_string() == *tag; + } + else if (args[1].is_mask()) { + return args[1].as_mask().match(*tag); + } + } } else if (arg.is_mask()) { foreach (const item_t::string_map::value_type& data, *item.metadata) { if (arg.as_mask().match(data.first)) { if (args.size() == 1) return true; - else if (data.second && args[1] == string_value(*data.second)) - return true; + else if (data.second) { + if (args[1].is_string()) + return args[1].as_string() == *data.second; + else if (args[1].is_mask()) + return args[1].as_mask().match(*data.second); + } } } } @@ -312,8 +323,13 @@ string item_context(const item_t& item) std::ostringstream out; out << "While balancing item from \"" << path.string() - << "\", line " << item.beg_line - << ", byte " << item.beg_pos << ":\n"; + << "\""; + + if (item.beg_line != (item.end_line - 1)) + out << ", lines " << item.beg_line << "-" + << (item.end_line - 1) << ":\n"; + else + out << ", line " << item.beg_line << ":\n"; bool first = true; for (char * p = std::strtok(buf.get(), "\n"); |