summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-04-10 11:52:43 +0000
committerJohn Wiegley <johnw@newartisans.com>2004-04-10 11:52:43 +0000
commit9ffdff9510bd9fc2ac4a8efe8f6b94bde794fda1 (patch)
treeeeffcb9d3214a9e405a4fa395de37185b89fa206
parentb5097ced2bf621c0bf9b79c9bcc85bb715ce6218 (diff)
downloadfork-ledger-9ffdff9510bd9fc2ac4a8efe8f6b94bde794fda1.tar.gz
fork-ledger-9ffdff9510bd9fc2ac4a8efe8f6b94bde794fda1.tar.bz2
fork-ledger-9ffdff9510bd9fc2ac4a8efe8f6b94bde794fda1.zip
*** empty log message ***
-rw-r--r--amount.cc4
-rw-r--r--parse.cc4
-rw-r--r--reports.cc32
3 files changed, 23 insertions, 17 deletions
diff --git a/amount.cc b/amount.cc
index 6984d9bb..d3a77044 100644
--- a/amount.cc
+++ b/amount.cc
@@ -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)
diff --git a/parse.cc b/parse.cc
index 231a8514..940c51db 100644
--- a/parse.cc
+++ b/parse.cc
@@ -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:
diff --git a/reports.cc b/reports.cc
index 0446c0f5..44dfcd74 100644
--- a/reports.cc
+++ b/reports.cc
@@ -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