summaryrefslogtreecommitdiff
path: root/src/item.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-11-16 00:15:25 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-11-16 00:15:25 -0500
commit6b557f810e1c6eb2dcd8a24eeeacfcf9cc8210e3 (patch)
tree52b5e0dfa040fd878ac4817a0fd49cee7c6f1688 /src/item.cc
parentbadbeb545b9e700e6656dfbc348bfe1387cb2ffa (diff)
parentb2c426abaed18e0784e39f804dcae0324e21f32f (diff)
downloadfork-ledger-6b557f810e1c6eb2dcd8a24eeeacfcf9cc8210e3.tar.gz
fork-ledger-6b557f810e1c6eb2dcd8a24eeeacfcf9cc8210e3.tar.bz2
fork-ledger-6b557f810e1c6eb2dcd8a24eeeacfcf9cc8210e3.zip
Merge branch 'next'
Diffstat (limited to 'src/item.cc')
-rw-r--r--src/item.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/item.cc b/src/item.cc
index 43274cfd..da6429ed 100644
--- a/src/item.cc
+++ b/src/item.cc
@@ -118,17 +118,20 @@ void item_t::set_tag(const string& tag,
void item_t::parse_tags(const char * p, optional<date_t::year_type> current_year)
{
if (const char * b = std::strchr(p, '[')) {
- if (const char * e = std::strchr(p, ']')) {
- char buf[256];
- std::strncpy(buf, b + 1, e - b - 1);
- buf[e - b - 1] = '\0';
-
- if (char * p = std::strchr(buf, '=')) {
- *p++ = '\0';
- _date_eff = parse_date(p, current_year);
+ if (*(b + 1) != '\0' &&
+ (std::isdigit(*(b + 1)) || *(b + 1) == '=')) {
+ if (const char * e = std::strchr(p, ']')) {
+ char buf[256];
+ std::strncpy(buf, b + 1, e - b - 1);
+ buf[e - b - 1] = '\0';
+
+ if (char * p = std::strchr(buf, '=')) {
+ *p++ = '\0';
+ _date_eff = parse_date(p, current_year);
+ }
+ if (buf[0])
+ _date = parse_date(buf, current_year);
}
- if (buf[0])
- _date = parse_date(buf, current_year);
}
}