summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2005-07-28 23:54:56 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:41:17 -0400
commited63481f3b1ff66f4ec2ef34f237002e33c0825c (patch)
tree00298aa86ad5395913b6736b3c55cb2b4d8a90a0
parentd65a758c8428403ece6548955a206a4b18a577b2 (diff)
downloadfork-ledger-ed63481f3b1ff66f4ec2ef34f237002e33c0825c.tar.gz
fork-ledger-ed63481f3b1ff66f4ec2ef34f237002e33c0825c.tar.bz2
fork-ledger-ed63481f3b1ff66f4ec2ef34f237002e33c0825c.zip
*** empty log message ***
-rw-r--r--amount.cc4
-rw-r--r--amount.h4
-rw-r--r--binary.cc14
3 files changed, 12 insertions, 10 deletions
diff --git a/amount.cc b/amount.cc
index 933716c6..a5ef1720 100644
--- a/amount.cc
+++ b/amount.cc
@@ -66,14 +66,14 @@ static struct _init_amounts {
commodity_t * commodity;
commodity = commodity_t::find_commodity("s", true);
- commodity->flags |= COMMODITY_STYLE_NOMARKET;
+ commodity->flags |= COMMODITY_STYLE_NOMARKET | COMMODITY_STYLE_BUILTIN;
parse_conversion("1.0m", "60s");
parse_conversion("1.0h", "60m");
#if 0
commodity = commodity_t::find_commodity("b", true);
- commodity->flags |= COMMODITY_STYLE_NOMARKET;
+ commodity->flags |= COMMODITY_STYLE_NOMARKET | COMMODITY_STYLE_BUILTIN;
parse_conversion("1.00 Kb", "1024 b");
parse_conversion("1.00 Mb", "1024 Kb");
diff --git a/amount.h b/amount.h
index d5d6ec11..98df367b 100644
--- a/amount.h
+++ b/amount.h
@@ -288,6 +288,7 @@ inline std::istream& operator>>(std::istream& in, amount_t& amt) {
#define COMMODITY_STYLE_THOUSANDS 0x0008
#define COMMODITY_STYLE_NOMARKET 0x0010
#define COMMODITY_STYLE_VARIABLE 0x0020
+#define COMMODITY_STYLE_BUILTIN 0x0040
typedef std::map<const std::time_t, amount_t> history_map;
typedef std::pair<const std::time_t, amount_t> history_pair;
@@ -400,9 +401,6 @@ class commodity_t
if (precision > 16)
return false;
- if (flags & ~0x1f)
- return false;
-
return true;
}
};
diff --git a/binary.cc b/binary.cc
index acc83d5b..e9ac3deb 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 = 0x00020039;
+static unsigned long format_version = 0x00020040;
static account_t ** accounts;
static account_t ** accounts_next;
@@ -421,10 +421,14 @@ unsigned int read_binary_journal(std::istream& in,
commodities = commodities_next = new commodity_t *[c_count];
for (commodity_t::ident_t i = 0; i < c_count; i++) {
commodity_t * commodity = read_binary_commodity(data);
- std::pair<commodities_map::iterator, bool> result
- = commodity_t::commodities.insert(commodities_pair(commodity->symbol,
- commodity));
- assert(result.second);
+ if (! (commodity->flags & COMMODITY_STYLE_BUILTIN)) {
+ std::pair<commodities_map::iterator, bool> result
+ = commodity_t::commodities.insert(commodities_pair(commodity->symbol,
+ commodity));
+ if (! result.second)
+ throw error(std::string("Failed to read commodity from cache: ") +
+ commodity->symbol);
+ }
}
for (commodity_t::ident_t i = 0; i < c_count; i++)