summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/item.cc32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/item.cc b/src/item.cc
index 3a2b0b60..ef64e154 100644
--- a/src/item.cc
+++ b/src/item.cc
@@ -172,19 +172,7 @@ void item_t::parse_tags(const char * p,
q = std::strtok(NULL, " \t")) {
const string::size_type len = std::strlen(q);
if (len < 2) continue;
- if (! tag.empty()) {
- string_map::iterator i;
- string field(p + (q - buf.get()));
- if (by_value) {
- bind_scope_t bound_scope(scope, *this);
- i = set_tag(tag, expr_t(field).calc(bound_scope), overwrite_existing);
- } else {
- i = set_tag(tag, string_value(field), overwrite_existing);
- }
- (*i).second.second = true;
- break;
- }
- else if (q[0] == ':' && q[len - 1] == ':') { // a series of tags
+ if (q[0] == ':' && q[len - 1] == ':') { // a series of tags
for (char * r = std::strtok(q + 1, ":");
r;
r = std::strtok(NULL, ":")) {
@@ -199,6 +187,24 @@ void item_t::parse_tags(const char * p,
index = 2;
}
tag = string(q, len - index);
+
+ string_map::iterator i;
+ const string::size_type plen = std::strlen(p);
+ const char * v = p + (q - p) + (len - index) + 1;
+ while (*v == '\0' && v < p + plen)
+ ++v;
+
+ if (v < p + plen) {
+ string field(v);
+ if (by_value) {
+ bind_scope_t bound_scope(scope, *this);
+ i = set_tag(tag, expr_t(field).calc(bound_scope), overwrite_existing);
+ } else {
+ i = set_tag(tag, string_value(field), overwrite_existing);
+ }
+ (*i).second.second = true;
+ break;
+ }
}
first = false;
}