summaryrefslogtreecommitdiff
path: root/src/item.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-03-07 05:16:05 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-03-07 05:16:05 -0600
commitc19b7099b2f135611192818bb968a7f8abb78493 (patch)
treef8169d88a6d10b7d336e36e0383f92ef11def6a5 /src/item.cc
parent150ca971add9377d8afc2b88dd8efb840a19cb9a (diff)
downloadfork-ledger-c19b7099b2f135611192818bb968a7f8abb78493.tar.gz
fork-ledger-c19b7099b2f135611192818bb968a7f8abb78493.tar.bz2
fork-ledger-c19b7099b2f135611192818bb968a7f8abb78493.zip
Fix parsing of metadata values containing spaces
Diffstat (limited to 'src/item.cc')
-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;
}