diff options
author | John Wiegley <johnw@newartisans.com> | 2004-04-10 11:52:43 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-04-10 11:52:43 +0000 |
commit | 9ffdff9510bd9fc2ac4a8efe8f6b94bde794fda1 (patch) | |
tree | eeffcb9d3214a9e405a4fa395de37185b89fa206 | |
parent | b5097ced2bf621c0bf9b79c9bcc85bb715ce6218 (diff) | |
download | fork-ledger-9ffdff9510bd9fc2ac4a8efe8f6b94bde794fda1.tar.gz fork-ledger-9ffdff9510bd9fc2ac4a8efe8f6b94bde794fda1.tar.bz2 fork-ledger-9ffdff9510bd9fc2ac4a8efe8f6b94bde794fda1.zip |
*** empty log message ***
-rw-r--r-- | amount.cc | 4 | ||||
-rw-r--r-- | parse.cc | 4 | ||||
-rw-r--r-- | reports.cc | 32 |
3 files changed, 23 insertions, 17 deletions
@@ -227,8 +227,10 @@ amount * gmp_amount::street(bool get_quotes) const { amount * amt = copy(); - int max = 10; + if (! amt->commdty()) + return amt; + int max = 10; while (--max >= 0) { if (! amt->commdty()->price && ! amt->commdty()->sought) { if (get_quotes) @@ -292,7 +292,7 @@ void parse_automated_transactions(std::istream& in, book * ledger) // book * parse_ledger(std::istream& in, regexps_map& regexps, - bool compute_balances) + bool compute_balances) { static char line[MAX_LINE + 1]; char c; @@ -334,7 +334,9 @@ book * parse_ledger(std::istream& in, regexps_map& regexps, break; case '=': // automated transactions + do_compute = false; parse_automated_transactions(in, ledger); + do_compute = compute_balances; break; default: @@ -126,8 +126,7 @@ void report_balances(std::ostream& out, regexps_map& regexps) } else { bool by_exclusion = false; - bool match = matches(regexps, acct->as_str(), - &by_exclusion); + bool match = matches(regexps, acct->as_str(), &by_exclusion); if (! match) { acct->checked = 2; } @@ -237,7 +236,7 @@ void print_register(const std::string& acct_name, std::ostream& out, // gnucash does. transaction * xact; - if ((*i)->xacts.size() == 2) { + if (! full_names && (*i)->xacts.size() == 2) { if (*x == (*i)->xacts.front()) xact = (*i)->xacts.back(); else @@ -302,7 +301,6 @@ static void equity_entry(account * acct, regexps_map& regexps, opening.cleared = true; opening.desc = "Opening Balance"; - transaction * xact; for (totals::const_iterator i = acct->balance.amounts.begin(); i != acct->balance.amounts.end(); i++) { @@ -310,7 +308,7 @@ static void equity_entry(account * acct, regexps_map& regexps, if ((*i).second->is_zero()) continue; - xact = new transaction(); + transaction * xact = new transaction(); xact->acct = const_cast<account *>(acct); xact->cost = (*i).second->street(get_quotes); opening.xacts.push_back(xact); @@ -551,7 +549,7 @@ int main(int argc, char * argv[]) have_beginning = true; if (! parse_date(optarg, &begin_date)) { std::cerr << "Error: Bad begin date: " << optarg << std::endl; - std::exit(1); + return 1; } break; @@ -559,7 +557,7 @@ int main(int argc, char * argv[]) have_ending = true; if (! parse_date(optarg, &end_date)) { std::cerr << "Error: Bad end date: " << optarg << std::endl; - std::exit(1); + return 1; } break; @@ -572,7 +570,7 @@ int main(int argc, char * argv[]) have_date_mask = true; if (! parse_date_mask(optarg, &date_mask)) { std::cerr << "Error: Bad date mask: " << optarg << std::endl; - std::exit(1); + return 1; } break; @@ -618,7 +616,7 @@ int main(int argc, char * argv[]) if (optind == argc) { show_help(std::cout); - std::exit(1); + return 1; } index = optind; @@ -632,9 +630,8 @@ int main(int argc, char * argv[]) if (! file || ! *file) { std::cerr << ("Please specify ledger file using -f option " - "or LEDGER environment variable.") - << std::endl; - std::exit(1); + "or LEDGER environment variable.") << std::endl; + return 1; } } @@ -644,10 +641,10 @@ int main(int argc, char * argv[]) int name_index = index; if (command == "register" || command == "reg") { - if (optind == argc) { + if (name_index == argc) { std::cerr << ("Error: Must specify an account name " "after the 'register' command.") << std::endl; - std::exit(1); + return 1; } index++; } @@ -675,7 +672,7 @@ int main(int argc, char * argv[]) delete file; if (! main_ledger) - std::exit(1); + return 1; // Record any prices specified by the user @@ -714,6 +711,11 @@ int main(int argc, char * argv[]) else if (command == "entry") { add_new_entry(index, argc, argv); } + else { + std::cerr << "Error: Unrecognized command '" << command << "'." + << std::endl; + return 1; + } #ifdef DEBUG // Ordinarily, deleting the main ledger isn't necessary, since the |