diff options
author | John Wiegley <johnw@newartisans.com> | 2005-01-07 04:39:35 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 02:40:48 -0400 |
commit | 9403113c59f5af0e8d3bedd46e8d50b685f9abb2 (patch) | |
tree | f008cefe2431f647b9a717abb1a08fccf67b551f /binary.cc | |
parent | a69bddcf2a0ec3b1da71dfb8593476af0a0e1c5f (diff) | |
download | fork-ledger-9403113c59f5af0e8d3bedd46e8d50b685f9abb2.tar.gz fork-ledger-9403113c59f5af0e8d3bedd46e8d50b685f9abb2.tar.bz2 fork-ledger-9403113c59f5af0e8d3bedd46e8d50b685f9abb2.zip |
(read_binary_amount): If the commodity ident is zero,
it is an explicit reference to commodity_t::null_commodity.
(write_binary_journal): Initialize account_index and
commodity_index to zero before writing.
(write_binary_journal): Set the "ident" field of the
null_commodity to 0, so that read_binary_amount can recognize it.
Diffstat (limited to 'binary.cc')
-rw-r--r-- | binary.cc | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -168,6 +168,8 @@ inline void read_binary_amount(char *& data, amount_t& amt) read_binary_number(data, ident); if (ident == 0xffffffff) amt.commodity_ = NULL; + else if (ident == 0) + amt.commodity_ = commodity_t::null_commodity; else amt.commodity_ = commodities[ident - 1]; @@ -628,6 +630,9 @@ void write_binary_account(std::ostream& out, account_t * account) void write_binary_journal(std::ostream& out, journal_t * journal, strings_list * files) { + account_index = + commodity_index = 0; + write_binary_number(out, binary_magic_number); write_binary_number(out, format_version); @@ -678,6 +683,8 @@ void write_binary_journal(std::ostream& out, journal_t * journal, i++) if (! (*i).first.empty()) write_binary_commodity(out, (*i).second); + else + (*i).second->ident = 0; for (commodities_map::const_iterator i = commodity_t::commodities.begin(); i != commodity_t::commodities.end(); |