*** no comment ***
This commit is contained in:
parent
88a895a494
commit
70b3eda8d1
7 changed files with 73 additions and 28 deletions
|
|
@ -77,6 +77,9 @@ bin_PROGRAMS = ledger
|
|||
ledger_CXXFLAGS =
|
||||
ledger_SOURCES = main.cc
|
||||
ledger_LDADD = $(LIBOBJS) libledger.la
|
||||
if USE_EDITOR
|
||||
ledger_CXXFLAGS += -DUSE_EDITOR=1
|
||||
endif
|
||||
if HAVE_EXPAT
|
||||
ledger_CXXFLAGS += -DHAVE_EXPAT=1
|
||||
ledger_LDADD += -lexpat
|
||||
|
|
|
|||
4
acprep
4
acprep
|
|
@ -23,13 +23,13 @@ LIBDIRS="-L/sw/lib -L/usr/local/lib"
|
|||
|
||||
if [ "$1" = "--debug" ]; then
|
||||
./configure CPPFLAGS="$INCDIRS" LDFLAGS="$LIBDIRS" CXXFLAGS="-g" \
|
||||
--enable-debug --disable-emacs
|
||||
--enable-debug
|
||||
elif [ "$1" = "--opt" ]; then
|
||||
./configure CPPFLAGS="$INCDIRS" LDFLAGS="$LIBDIRS" \
|
||||
CXXFLAGS="-fomit-frame-pointer -O3 -mcpu=7450 -fPIC"
|
||||
elif [ "$1" = "--flat-opt" ]; then
|
||||
./configure CPPFLAGS="$INCDIRS" LDFLAGS="$LIBDIRS" \
|
||||
CXXFLAGS="-fomit-frame-pointer -O3 -mcpu=7450" --disable-emacs
|
||||
CXXFLAGS="-fomit-frame-pointer -O3 -mcpu=7450"
|
||||
elif [ "$1" = "--safe-opt" ]; then
|
||||
./configure CPPFLAGS="$INCDIRS" LDFLAGS="$LIBDIRS" \
|
||||
CXXFLAGS="-fomit-frame-pointer -O3 -mcpu=7450 -fPIC -DDEBUG_LEVEL=1"
|
||||
|
|
|
|||
65
binary.cc
65
binary.cc
|
|
@ -13,15 +13,15 @@ namespace ledger {
|
|||
static unsigned long binary_magic_number = 0xFFEED765;
|
||||
#ifdef USE_EDITOR
|
||||
#ifdef DEBUG_ENABLED
|
||||
static unsigned long format_version = 0x00020587;
|
||||
static unsigned long format_version = 0x00020589;
|
||||
#else
|
||||
static unsigned long format_version = 0x00020586;
|
||||
static unsigned long format_version = 0x00020588;
|
||||
#endif
|
||||
#else
|
||||
#ifdef DEBUG_ENABLED
|
||||
static unsigned long format_version = 0x00020507;
|
||||
static unsigned long format_version = 0x00020509;
|
||||
#else
|
||||
static unsigned long format_version = 0x00020506;
|
||||
static unsigned long format_version = 0x00020508;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -338,7 +338,7 @@ inline void read_binary_transaction(char *& data, transaction_t * xact)
|
|||
}
|
||||
|
||||
inline void read_binary_entry_base(char *& data, entry_base_t * entry,
|
||||
transaction_t *& xact_pool)
|
||||
transaction_t *& xact_pool, bool& finalize)
|
||||
{
|
||||
#ifdef USE_EDITOR
|
||||
read_binary_long(data, entry->src_idx);
|
||||
|
|
@ -348,19 +348,23 @@ inline void read_binary_entry_base(char *& data, entry_base_t * entry,
|
|||
read_binary_long(data, entry->end_line);
|
||||
#endif
|
||||
|
||||
bool ignore_calculated = read_binary_number<char>(data) == 1;
|
||||
|
||||
for (unsigned long i = 0, count = read_binary_long<unsigned long>(data);
|
||||
i < count;
|
||||
i++) {
|
||||
DEBUG_PRINT("ledger.memory.ctors", "ctor transaction_t");
|
||||
read_binary_transaction(data, xact_pool);
|
||||
if (ignore_calculated && xact_pool->flags & TRANSACTION_CALCULATED)
|
||||
finalize = true;
|
||||
entry->add_transaction(xact_pool++);
|
||||
}
|
||||
}
|
||||
|
||||
inline void read_binary_entry(char *& data, entry_t * entry,
|
||||
transaction_t *& xact_pool)
|
||||
transaction_t *& xact_pool, bool& finalize)
|
||||
{
|
||||
read_binary_entry_base(data, entry, xact_pool);
|
||||
read_binary_entry_base(data, entry, xact_pool, finalize);
|
||||
read_binary_long(data, entry->_date);
|
||||
read_binary_long(data, entry->_date_eff);
|
||||
read_binary_string(data, &entry->code);
|
||||
|
|
@ -370,15 +374,16 @@ inline void read_binary_entry(char *& data, entry_t * entry,
|
|||
inline void read_binary_auto_entry(char *& data, auto_entry_t * entry,
|
||||
transaction_t *& xact_pool)
|
||||
{
|
||||
read_binary_entry_base(data, entry, xact_pool);
|
||||
bool ignore;
|
||||
read_binary_entry_base(data, entry, xact_pool, ignore);
|
||||
read_binary_string(data, &entry->predicate_string);
|
||||
entry->predicate = new item_predicate<transaction_t>(entry->predicate_string);
|
||||
}
|
||||
|
||||
inline void read_binary_period_entry(char *& data, period_entry_t * entry,
|
||||
transaction_t *& xact_pool)
|
||||
transaction_t *& xact_pool, bool& finalize)
|
||||
{
|
||||
read_binary_entry_base(data, entry, xact_pool);
|
||||
read_binary_entry_base(data, entry, xact_pool, finalize);
|
||||
read_binary_string(data, &entry->period_string);
|
||||
std::istringstream stream(entry->period_string);
|
||||
entry->period.parse(stream);
|
||||
|
|
@ -595,8 +600,11 @@ unsigned int read_binary_journal(std::istream& in,
|
|||
|
||||
for (unsigned long i = 0; i < count; i++) {
|
||||
new(entry_pool) entry_t;
|
||||
read_binary_entry(data, entry_pool, xact_pool);
|
||||
bool finalize = false;
|
||||
read_binary_entry(data, entry_pool, xact_pool, finalize);
|
||||
entry_pool->journal = journal;
|
||||
if (finalize && ! entry_pool->finalize())
|
||||
continue;
|
||||
journal->entries.push_back(entry_pool++);
|
||||
}
|
||||
|
||||
|
|
@ -609,8 +617,11 @@ unsigned int read_binary_journal(std::istream& in,
|
|||
|
||||
for (unsigned long i = 0; i < period_count; i++) {
|
||||
period_entry_t * period_entry = new period_entry_t;
|
||||
read_binary_period_entry(data, period_entry, xact_pool);
|
||||
bool finalize = false;
|
||||
read_binary_period_entry(data, period_entry, xact_pool, finalize);
|
||||
period_entry->journal = journal;
|
||||
if (finalize && ! period_entry->finalize())
|
||||
continue;
|
||||
journal->period_entries.push_back(period_entry);
|
||||
}
|
||||
|
||||
|
|
@ -623,13 +634,15 @@ unsigned int read_binary_journal(std::istream& in,
|
|||
delete[] commodities;
|
||||
delete[] data_pool;
|
||||
|
||||
VALIDATE(journal->valid());
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
bool binary_parser_t::test(std::istream& in) const
|
||||
{
|
||||
if (read_binary_number<unsigned long>(in) == binary_magic_number &&
|
||||
read_binary_long<unsigned long>(in) == format_version)
|
||||
read_binary_number<unsigned long>(in) == format_version)
|
||||
return true;
|
||||
|
||||
in.clear();
|
||||
|
|
@ -759,7 +772,8 @@ void write_binary_value_expr(std::ostream& out, value_expr_t * expr)
|
|||
}
|
||||
}
|
||||
|
||||
void write_binary_transaction(std::ostream& out, transaction_t * xact)
|
||||
void write_binary_transaction(std::ostream& out, transaction_t * xact,
|
||||
bool ignore_calculated)
|
||||
{
|
||||
write_binary_long(out, xact->_date);
|
||||
write_binary_long(out, xact->_date_eff);
|
||||
|
|
@ -770,10 +784,14 @@ void write_binary_transaction(std::ostream& out, transaction_t * xact)
|
|||
write_binary_value_expr(out, xact->amount_expr);
|
||||
} else {
|
||||
write_binary_number<char>(out, 0);
|
||||
write_binary_amount(out, xact->amount);
|
||||
if (ignore_calculated && xact->flags & TRANSACTION_CALCULATED)
|
||||
write_binary_amount(out, amount_t());
|
||||
else
|
||||
write_binary_amount(out, xact->amount);
|
||||
}
|
||||
|
||||
if (xact->cost) {
|
||||
if (xact->cost &&
|
||||
(! (ignore_calculated && xact->flags & TRANSACTION_CALCULATED))) {
|
||||
write_binary_number<char>(out, 1);
|
||||
if (xact->cost_expr != NULL) {
|
||||
write_binary_number<char>(out, 1);
|
||||
|
|
@ -808,11 +826,22 @@ void write_binary_entry_base(std::ostream& out, entry_base_t * entry)
|
|||
write_binary_long(out, entry->end_line);
|
||||
#endif
|
||||
|
||||
bool ignore_calculated = false;
|
||||
for (transactions_list::const_iterator i = entry->transactions.begin();
|
||||
i != entry->transactions.end();
|
||||
i++)
|
||||
if ((*i)->amount_expr || (*i)->cost_expr) {
|
||||
ignore_calculated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
write_binary_number<char>(out, ignore_calculated ? 1 : 0);
|
||||
|
||||
write_binary_long(out, entry->transactions.size());
|
||||
for (transactions_list::const_iterator i = entry->transactions.begin();
|
||||
i != entry->transactions.end();
|
||||
i++)
|
||||
write_binary_transaction(out, *i);
|
||||
write_binary_transaction(out, *i, ignore_calculated);
|
||||
}
|
||||
|
||||
void write_binary_entry(std::ostream& out, entry_t * entry)
|
||||
|
|
@ -917,7 +946,7 @@ void write_binary_journal(std::ostream& out, journal_t * journal)
|
|||
commodity_index = 0;
|
||||
|
||||
write_binary_number(out, binary_magic_number);
|
||||
write_binary_long(out, format_version);
|
||||
write_binary_number(out, format_version);
|
||||
|
||||
// Write out the files that participated in this journal, so that
|
||||
// they can be checked for changes on reading.
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ bool transaction_t::valid() const
|
|||
if (cost && ! cost->valid())
|
||||
return false;
|
||||
|
||||
if (flags & ~0x000f)
|
||||
if (flags & ~0x001f)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
@ -109,6 +109,7 @@ bool entry_base_t::finalize()
|
|||
// The amount doesn't need to be set because the code below will
|
||||
// balance this transaction against the other.
|
||||
add_transaction(nxact);
|
||||
nxact->flags |= TRANSACTION_CALCULATED;
|
||||
}
|
||||
|
||||
// If one transaction of a two-line transaction is of a different
|
||||
|
|
@ -191,6 +192,7 @@ bool entry_base_t::finalize()
|
|||
} else {
|
||||
transaction_t * nxact = new transaction_t((*x)->account);
|
||||
add_transaction(nxact);
|
||||
nxact->flags |= TRANSACTION_CALCULATED;
|
||||
nxact->amount = amt;
|
||||
}
|
||||
|
||||
|
|
@ -203,6 +205,7 @@ bool entry_base_t::finalize()
|
|||
case value_t::AMOUNT:
|
||||
(*x)->amount = *((amount_t *) balance.data);
|
||||
(*x)->amount.negate();
|
||||
(*x)->flags |= TRANSACTION_CALCULATED;
|
||||
|
||||
balance += (*x)->amount;
|
||||
break;
|
||||
|
|
|
|||
13
journal.h
13
journal.h
|
|
@ -22,6 +22,7 @@ namespace ledger {
|
|||
#define TRANSACTION_BALANCE 0x0002
|
||||
#define TRANSACTION_AUTO 0x0004
|
||||
#define TRANSACTION_BULK_ALLOC 0x0008
|
||||
#define TRANSACTION_CALCULATED 0x0010
|
||||
|
||||
class entry_t;
|
||||
class account_t;
|
||||
|
|
@ -132,10 +133,18 @@ class entry_base_t
|
|||
#endif
|
||||
transactions_list transactions;
|
||||
|
||||
entry_base_t() : journal(NULL) {
|
||||
entry_base_t() : journal(NULL),
|
||||
#ifdef USE_EDITOR
|
||||
beg_pos(0), beg_line(0), end_pos(0), end_line(0)
|
||||
#endif
|
||||
{
|
||||
DEBUG_PRINT("ledger.memory.ctors", "ctor entry_base_t");
|
||||
}
|
||||
entry_base_t(const entry_base_t& e) : journal(NULL) {
|
||||
entry_base_t(const entry_base_t& e) : journal(NULL),
|
||||
#ifdef USE_EDITOR
|
||||
beg_pos(0), beg_line(0), end_pos(0), end_line(0)
|
||||
#endif
|
||||
{
|
||||
DEBUG_PRINT("ledger.memory.ctors", "ctor entry_base_t");
|
||||
for (transactions_list::const_iterator i = e.transactions.begin();
|
||||
i != e.transactions.end();
|
||||
|
|
|
|||
10
valexpr.cc
10
valexpr.cc
|
|
@ -130,6 +130,10 @@ void value_expr_t::compute(value_t& result, const details_t& details) const
|
|||
result = 0L;
|
||||
break;
|
||||
|
||||
case F_NOW:
|
||||
result = long(terminus);
|
||||
break;
|
||||
|
||||
case DATE:
|
||||
if (details.xact && transaction_has_xdata(*details.xact) &&
|
||||
transaction_xdata_(*details.xact).date)
|
||||
|
|
@ -525,11 +529,7 @@ value_expr_t * parse_value_term(std::istream& in)
|
|||
in.get(c);
|
||||
switch (c) {
|
||||
// Basic terms
|
||||
case 'm':
|
||||
node.reset(new value_expr_t(value_expr_t::CONSTANT_T));
|
||||
node->constant_t = terminus;
|
||||
break;
|
||||
|
||||
case 'm': node.reset(new value_expr_t(value_expr_t::F_NOW)); break;
|
||||
case 'a': node.reset(new value_expr_t(value_expr_t::AMOUNT)); break;
|
||||
case 'b': node.reset(new value_expr_t(value_expr_t::COST)); break;
|
||||
case 'd': node.reset(new value_expr_t(value_expr_t::DATE)); break;
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ struct value_expr_t
|
|||
TOTAL_EXPR,
|
||||
|
||||
// Functions
|
||||
F_NOW,
|
||||
F_PARENT,
|
||||
F_ARITH_MEAN,
|
||||
F_VALUE,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue