print is working again
This commit is contained in:
parent
c6c0179545
commit
38e9c6c76c
4 changed files with 53 additions and 43 deletions
2
Makefile
2
Makefile
|
|
@ -19,7 +19,7 @@ CXX = g++
|
||||||
CFLAGS = -Wall -ansi -pedantic
|
CFLAGS = -Wall -ansi -pedantic
|
||||||
#DFLAGS = -O3 -fomit-frame-pointer
|
#DFLAGS = -O3 -fomit-frame-pointer
|
||||||
DFLAGS = -g -DDEBUG=1
|
DFLAGS = -g -DDEBUG=1
|
||||||
#DFLAGS = -g -pg
|
#DFLAGS = -g -DDEBUG=1 -pg
|
||||||
|
|
||||||
INCS = -I/sw/include \
|
INCS = -I/sw/include \
|
||||||
-I/usr/include/gcc/darwin/3.3/c++ \
|
-I/usr/include/gcc/darwin/3.3/c++ \
|
||||||
|
|
|
||||||
12
error.cc
Normal file
12
error.cc
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include "error.h"
|
||||||
|
|
||||||
|
namespace ledger {
|
||||||
|
|
||||||
|
const char* parse_error::what() const throw()
|
||||||
|
{
|
||||||
|
std::ostringstream msg;
|
||||||
|
msg << file << ", line " << line << ": " << error::what();
|
||||||
|
return msg.str().c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ledger
|
||||||
61
format.cc
61
format.cc
|
|
@ -226,43 +226,48 @@ void format_t::format_elements(std::ostream& out,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case element_t::OPT_AMOUNT: {
|
case element_t::OPT_AMOUNT:
|
||||||
if (! details.entry || ! details.xact)
|
if (details.xact) {
|
||||||
break;
|
std::string disp;
|
||||||
|
bool use_disp = false;
|
||||||
|
|
||||||
std::string disp;
|
if (details.xact->amount != details.xact->cost) {
|
||||||
bool use_disp = false;
|
|
||||||
|
|
||||||
if (std::find(details.entry->transactions.begin(),
|
|
||||||
details.entry->transactions.end(), details.xact) !=
|
|
||||||
details.entry->transactions.end()) {
|
|
||||||
if (details.entry->transactions.size() == 2 &&
|
|
||||||
details.xact == details.entry->transactions.back() &&
|
|
||||||
(details.entry->transactions.front()->amount ==
|
|
||||||
details.entry->transactions.front()->cost) &&
|
|
||||||
(details.entry->transactions.front()->amount ==
|
|
||||||
- details.entry->transactions.back()->amount)) {
|
|
||||||
use_disp = true;
|
|
||||||
}
|
|
||||||
else if (details.entry->transactions.size() != 2 &&
|
|
||||||
details.xact->amount != details.xact->cost) {
|
|
||||||
amount_t unit_cost = details.xact->cost / details.xact->amount;
|
amount_t unit_cost = details.xact->cost / details.xact->amount;
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
stream << details.xact->amount << " @ " << unit_cost;
|
stream << details.xact->amount << " @ " << unit_cost;
|
||||||
disp = stream.str();
|
disp = stream.str();
|
||||||
use_disp = true;
|
use_disp = true;
|
||||||
|
} else {
|
||||||
|
unsigned int xacts_real_count = 0;
|
||||||
|
transaction_t * first = NULL;
|
||||||
|
transaction_t * last = NULL;
|
||||||
|
|
||||||
|
for (transactions_list::const_iterator i
|
||||||
|
= details.entry->transactions.begin();
|
||||||
|
i != details.entry->transactions.end();
|
||||||
|
i++)
|
||||||
|
if (! ((*i)->flags & TRANSACTION_AUTO)) {
|
||||||
|
xacts_real_count++;
|
||||||
|
|
||||||
|
if (! first)
|
||||||
|
first = *i;
|
||||||
|
last = *i;
|
||||||
|
}
|
||||||
|
|
||||||
|
use_disp = (xacts_real_count == 2 &&
|
||||||
|
details.xact == last &&
|
||||||
|
first->amount == - last->amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! use_disp)
|
||||||
|
disp = std::string(details.xact->amount);
|
||||||
|
out << disp;
|
||||||
|
|
||||||
|
// jww (2004-07-31): this should be handled differently
|
||||||
|
if (! details.xact->note.empty())
|
||||||
|
out << " ; " << details.xact->note;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! use_disp)
|
|
||||||
disp = std::string(details.xact->amount);
|
|
||||||
out << disp;
|
|
||||||
|
|
||||||
// jww (2004-07-31): this should be handled differently
|
|
||||||
if (! details.xact->note.empty())
|
|
||||||
out << " ; " << details.xact->note;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case element_t::VALUE: {
|
case element_t::VALUE: {
|
||||||
balance_t value;
|
balance_t value;
|
||||||
|
|
|
||||||
21
walk.h
21
walk.h
|
|
@ -66,20 +66,13 @@ void handle_transaction(transaction_t * xact,
|
||||||
const Function& functor,
|
const Function& functor,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
if ((flags & MATCHING_TRANSACTIONS) &&
|
for (transactions_list::iterator i = xact->entry->transactions.begin();
|
||||||
! (xact->flags & TRANSACTION_HANDLED)) {
|
i != xact->entry->transactions.end();
|
||||||
xact->flags |= TRANSACTION_HANDLED;
|
i++)
|
||||||
functor(xact);
|
if (! ((*i)->flags & (TRANSACTION_AUTO | TRANSACTION_HANDLED)) &&
|
||||||
}
|
(*i == xact ?
|
||||||
|
(flags & MATCHING_TRANSACTIONS) :
|
||||||
if (flags & OTHER_TRANSACTIONS)
|
(flags & OTHER_TRANSACTIONS))) {
|
||||||
for (transactions_list::iterator i = xact->entry->transactions.begin();
|
|
||||||
i != xact->entry->transactions.end();
|
|
||||||
i++) {
|
|
||||||
if (*i == xact || ((*i)->flags & (TRANSACTION_AUTO |
|
|
||||||
TRANSACTION_HANDLED)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
(*i)->flags |= TRANSACTION_HANDLED;
|
(*i)->flags |= TRANSACTION_HANDLED;
|
||||||
functor(*i);
|
functor(*i);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue