From c59a5c9f86c2eaaddf6d4cff5e1ae69721d8c709 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 14 Jan 2005 23:20:34 +0000 Subject: Updated binary file version. (read_binary_journal): Read in the default commodity. (write_binary_journal): Write out the default commodity. --- binary.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'binary.cc') diff --git a/binary.cc b/binary.cc index 7b97a21c..6b38a2c5 100644 --- a/binary.cc +++ b/binary.cc @@ -11,7 +11,7 @@ namespace ledger { static unsigned long binary_magic_number = 0xFFEED765; -static unsigned long format_version = 0x00020027; +static unsigned long format_version = 0x00020028; static account_t ** accounts; static account_t ** accounts_next; @@ -414,6 +414,13 @@ unsigned int read_binary_journal(std::istream& in, for (commodity_t::ident_t i = 0; i < c_count; i++) read_binary_commodity_extra(data, i); + commodity_t::ident_t ident; + read_binary_number(data, ident); + if (ident == 0xffffffff || ident == 0) + commodity_t::default_commodity = NULL; + else + commodity_t::default_commodity = commodities[ident - 1]; + // Read in the entries and transactions for (unsigned long i = 0; i < count; i++) { @@ -692,6 +699,11 @@ void write_binary_journal(std::ostream& out, journal_t * journal, if (! (*i).first.empty()) write_binary_commodity_extra(out, (*i).second); + if (commodity_t::default_commodity) + write_binary_number(out, commodity_t::default_commodity->ident); + else + write_binary_number(out, 0xffffffff); + // Write out the entries and transactions unsigned long xact_count = 0; -- cgit v1.2.3