summaryrefslogtreecommitdiff
path: root/textual.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-08-15 02:39:13 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-08-15 02:39:13 -0400
commitb10ff955a370b7fd2add5c5493f1987b5d7b6600 (patch)
tree9e5b0cd0022862766cda8b62aca7c7336bbc4c51 /textual.cc
parent972ed4c386f8beeafda3519f6769f6dd9670e69a (diff)
downloadfork-ledger-b10ff955a370b7fd2add5c5493f1987b5d7b6600.tar.gz
fork-ledger-b10ff955a370b7fd2add5c5493f1987b5d7b6600.tar.bz2
fork-ledger-b10ff955a370b7fd2add5c5493f1987b5d7b6600.zip
cleaned up binary data writing, and file handling
Diffstat (limited to 'textual.cc')
-rw-r--r--textual.cc28
1 files changed, 13 insertions, 15 deletions
diff --git a/textual.cc b/textual.cc
index 07fb428d..4fd4ade3 100644
--- a/textual.cc
+++ b/textual.cc
@@ -296,6 +296,14 @@ entry_t * parse_entry(std::istream& in, account_t * master)
return curr;
}
+template <typename T>
+struct push_var {
+ T& var;
+ T prev;
+ push_var(T& _var) : var(_var), prev(var) {}
+ ~push_var() { var = prev; }
+};
+
unsigned int parse_textual_journal(std::istream& in, journal_t * journal,
account_t * master)
{
@@ -496,9 +504,9 @@ unsigned int parse_textual_journal(std::istream& in, journal_t * journal,
linenum++;
break;
- case ':': { // option setting
+ case '-': { // option setting
std::string opt;
- in >> c;
+ in >> c >> c;
in >> opt;
in.getline(line, MAX_LINE);
linenum++;
@@ -533,19 +541,9 @@ unsigned int parse_textual_journal(std::istream& in, journal_t * journal,
in.getline(line, MAX_LINE);
linenum++;
- char * p = skip_ws(line);
- std::ifstream stream(p);
-
- journal->sources.push_back(p);
-
- unsigned int curr_linenum = linenum;
- std::string curr_path = path;
-
- count += parse_textual_journal(stream, journal,
- account_stack.front());
-
- linenum = curr_linenum;
- path = curr_path;
+ push_var<unsigned int> save_linenum(linenum);
+ push_var<std::string> save_path(path);
+ count += parse_journal_file(skip_ws(line), journal);
}
break;