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 | |
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')
-rw-r--r-- | src/item.cc | 30 | ||||
-rw-r--r-- | src/value.cc | 4 |
2 files changed, 23 insertions, 11 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"); diff --git a/src/value.cc b/src/value.cc index a34ceb98..9f14038f 100644 --- a/src/value.cc +++ b/src/value.cc @@ -944,15 +944,11 @@ bool value_t::is_equal_to(const value_t& val) const case STRING: if (val.is_string()) return as_string() == val.as_string(); - else if (val.is_mask()) - return val.as_mask().match(as_string()); break; case MASK: if (val.is_mask()) return as_mask() == val.as_mask(); - else if (val.is_string()) - return as_mask().match(val.as_string()); break; case SEQUENCE: |