diff options
-rw-r--r-- | amount.cc | 9 | ||||
-rw-r--r-- | gnucash.cc | 2 | ||||
-rw-r--r-- | ledger.cc | 10 | ||||
-rw-r--r-- | ledger.h | 10 | ||||
-rw-r--r-- | reports.cc | 7 |
5 files changed, 20 insertions, 18 deletions
@@ -547,16 +547,11 @@ static commodity * parse_amount(mpz_t out, const char * num, if (saw_commodity) { commodities_map_iterator item = main_ledger->commodities.find(symbol.c_str()); - if (item == main_ledger->commodities.end()) { + if (item == main_ledger->commodities.end()) comm = new commodity(symbol, prefix, separate, thousands, european, precision); - } else { + else comm = (*item).second; - - if (use_warnings && precision > comm->precision) - std::cerr << "Warning: Use of higher precision than expected: " - << value_str << std::endl; - } } parse_number(out, value_str.c_str(), comm); @@ -273,6 +273,8 @@ book * parse_gnucash(std::istream& in, bool compute_balances) curr_account_id.clear(); curr_quant.clear(); + main_ledger->commodities.erase("USD"); + return ledger; } @@ -4,7 +4,6 @@ namespace ledger { -bool use_warnings = false; book * main_ledger; commodity::~commodity() @@ -251,6 +250,15 @@ mask::mask(const std::string& pat) : exclude(false) << std::endl; } +mask::mask(const mask& m) : exclude(m.exclude), pattern(m.pattern) +{ + const char *error; + int erroffset; + regexp = pcre_compile(pattern.c_str(), PCRE_CASELESS, + &error, &erroffset, NULL); + assert(regexp); +} + void read_regexps(const std::string& path, regexps_map& regexps) { if (access(path.c_str(), R_OK) != -1) { @@ -1,5 +1,5 @@ #ifndef _LEDGER_H -#define _LEDGER_H "$Revision: 1.23 $" +#define _LEDGER_H "$Revision: 1.24 $" ////////////////////////////////////////////////////////////////////// // @@ -93,9 +93,6 @@ extern amount * create_amount(const std::string& value, class mask { - // jww (2003-10-08): need to correct this - //mask(const mask&); - public: bool exclude; std::string pattern; @@ -103,11 +100,11 @@ class mask explicit mask(const std::string& pattern); -#if 0 + mask(const mask&); + ~mask() { pcre_free(regexp); } -#endif bool match(const std::string& str) const; }; @@ -287,7 +284,6 @@ class book }; extern book * main_ledger; -extern bool use_warnings; inline commodity::commodity(const std::string& sym, bool pre, bool sep, bool thou, bool euro, int prec) @@ -393,7 +393,7 @@ int main(int argc, char * argv[]) // Parse the command-line options int c; - while (-1 != (c = getopt(argc, argv, "+b:e:d:cChRV:wf:i:p:PvsSEnF"))) { + while (-1 != (c = getopt(argc, argv, "+b:e:d:cChRV:f:i:p:PvsSEnF"))) { switch (char(c)) { case 'b': case 'e': { @@ -473,7 +473,6 @@ int main(int argc, char * argv[]) case 'C': show_cleared = true; break; case 'R': show_virtual = false; break; - case 'w': use_warnings = true; break; case 's': show_children = true; break; case 'S': show_sorted = true; break; case 'E': show_empty = true; break; @@ -516,7 +515,8 @@ int main(int argc, char * argv[]) index = optind; - if (use_warnings && (have_beginning || have_ending)) { +#if 0 + if (have_beginning || have_ending) { std::cout << "Reporting"; if (have_beginning) { @@ -533,6 +533,7 @@ int main(int argc, char * argv[]) std::cout << std::endl; } +#endif // A ledger data file must be specified |