summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-03-10 03:56:34 -0500
committerJohn Wiegley <johnw@newartisans.com>2010-03-10 03:56:34 -0500
commit7e719c42dc1464fdef1fe54ac7287e1eca60f44d (patch)
tree5c4c14ebc4b93865f15465b5fdf7f08f9628bd7c
parent25c72d6e23dc93cc590e73327238368245cdcd9c (diff)
downloadfork-ledger-7e719c42dc1464fdef1fe54ac7287e1eca60f44d.tar.gz
fork-ledger-7e719c42dc1464fdef1fe54ac7287e1eca60f44d.tar.bz2
fork-ledger-7e719c42dc1464fdef1fe54ac7287e1eca60f44d.zip
Extended regexp syntax for "payee" and "capture"
-rw-r--r--src/textual.cc36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/textual.cc b/src/textual.cc
index dae9c3c6..6a8ea62e 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -742,7 +742,21 @@ void instance_t::payee_mapping_directive(char * line)
char * payee = skip_ws(line);
char * regex = next_element(payee, true);
- context.journal.payee_mappings.push_back(payee_mapping_t(mask_t(regex), payee));
+ if (regex)
+ context.journal.payee_mappings.push_back
+ (payee_mapping_t(mask_t(regex), payee));
+
+ while (peek_whitespace_line()) {
+ std::streamsize len = read_line(line);
+ assert(len > 0);
+
+ regex = skip_ws(line);
+ if (! *regex)
+ break;
+
+ context.journal.payee_mappings.push_back
+ (payee_mapping_t(mask_t(regex), payee));
+ }
}
void instance_t::account_mapping_directive(char * line)
@@ -750,9 +764,23 @@ void instance_t::account_mapping_directive(char * line)
char * account_name = skip_ws(line);
char * payee_regex = next_element(account_name, true);
- context.journal.account_mappings.push_back
- (account_mapping_t(mask_t(payee_regex),
- context.top_account()->find_account(account_name)));
+ if (payee_regex)
+ context.journal.account_mappings.push_back
+ (account_mapping_t(mask_t(payee_regex),
+ context.top_account()->find_account(account_name)));
+
+ while (peek_whitespace_line()) {
+ std::streamsize len = read_line(line);
+ assert(len > 0);
+
+ payee_regex = skip_ws(line);
+ if (! *payee_regex)
+ break;
+
+ context.journal.account_mappings.push_back
+ (account_mapping_t(mask_t(payee_regex),
+ context.top_account()->find_account(account_name)));
+ }
}
void instance_t::tag_directive(char * line)