From bc31e4838bae16748352901634d264af9b045369 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 17 Mar 2012 07:02:03 -0500 Subject: Fixed #711: Parsing of alias directive --- src/textual.cc | 12 ++++-------- test/regress/1384C1D8.test | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 test/regress/1384C1D8.test diff --git a/src/textual.cc b/src/textual.cc index 8856af5d..0cb7fb81 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -982,27 +982,23 @@ void instance_t::account_alias_directive(account_t * account, string alias) // (account), add a reference to the account in the `account_aliases' // map, which is used by the post parser to resolve alias references. trim(alias); -#if defined(DEBUG_ON) std::pair result = -#endif context.journal->account_aliases.insert (accounts_map::value_type(alias, account)); -#if defined(DEBUG_ON) - assert(result.second); -#endif + if (! result.second) + (*result.first).second = account; } void instance_t::alias_directive(char * line) { - char * b = next_element(line); - if (char * e = std::strchr(b, '=')) { + if (char * e = std::strchr(line, '=')) { char * z = e - 1; while (std::isspace(*z)) *z-- = '\0'; *e++ = '\0'; e = skip_ws(e); - account_alias_directive(top_account()->find_account(e), b); + account_alias_directive(top_account()->find_account(e), line); } } diff --git a/test/regress/1384C1D8.test b/test/regress/1384C1D8.test new file mode 100644 index 00000000..77a07b7a --- /dev/null +++ b/test/regress/1384C1D8.test @@ -0,0 +1,27 @@ +@alias OLD1 = NEW1 + +2012-01-01 Something + OLD1 $10.00 + Other + +!alias OLD2 = NEW2 + +2012-01-01 Something + OLD2 $10.00 + Other + +account NEW3 + alias OLD3 + +2012-01-01 Something + OLD3 $10.00 + Other + +test bal + $10.00 NEW1 + $10.00 NEW2 + $10.00 NEW3 + $-30.00 Other +-------------------- + 0 +end test -- cgit v1.2.3