Removed used of src_idx.
This commit is contained in:
parent
8948e161cd
commit
2ce7ae376c
7 changed files with 42 additions and 61 deletions
10
src/emacs.cc
10
src/emacs.cc
|
|
@ -36,14 +36,8 @@ namespace ledger {
|
|||
|
||||
void format_emacs_xacts::write_entry(entry_t& entry)
|
||||
{
|
||||
int idx = entry.src_idx;
|
||||
foreach (const path& path, entry.journal->sources)
|
||||
if (! idx--) {
|
||||
out << "\"" << path << "\" ";
|
||||
break;
|
||||
}
|
||||
|
||||
out << (static_cast<std::size_t>(entry.beg_line) + 1) << " ";
|
||||
out << "\"" << entry.pathname << "\" "
|
||||
<< (static_cast<std::size_t>(entry.beg_line) + 1) << " ";
|
||||
|
||||
tm when = gregorian::to_tm(*entry.date());
|
||||
std::time_t date = std::mktime(&when); // jww (2008-04-20): Is this GMT or local?
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@
|
|||
|
||||
namespace ledger {
|
||||
|
||||
entry_base_t::entry_base_t(const entry_base_t& e) : item_t()
|
||||
entry_base_t::entry_base_t(const entry_base_t& e)
|
||||
: item_t(), journal(NULL)
|
||||
{
|
||||
TRACE_CTOR(entry_base_t, "copy");
|
||||
#if 0
|
||||
|
|
@ -79,14 +80,12 @@ item_t::state_t entry_base_t::state() const
|
|||
void entry_base_t::add_xact(xact_t * xact)
|
||||
{
|
||||
xacts.push_back(xact);
|
||||
xact->journal = journal;
|
||||
}
|
||||
|
||||
bool entry_base_t::remove_xact(xact_t * xact)
|
||||
{
|
||||
xacts.remove(xact);
|
||||
xact->entry = NULL;
|
||||
xact->journal = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,9 +61,11 @@ class journal_t;
|
|||
class entry_base_t : public item_t
|
||||
{
|
||||
public:
|
||||
journal_t * journal;
|
||||
|
||||
xacts_list xacts;
|
||||
|
||||
entry_base_t() {
|
||||
entry_base_t() : item_t(), journal(NULL) {
|
||||
TRACE_CTOR(entry_base_t, "");
|
||||
}
|
||||
entry_base_t(const entry_base_t& e);
|
||||
|
|
|
|||
58
src/item.cc
58
src/item.cc
|
|
@ -310,44 +310,38 @@ bool item_t::valid() const
|
|||
|
||||
string item_context(const item_t& item)
|
||||
{
|
||||
unsigned short x = 0;
|
||||
foreach (const path& path, item.journal->sources) {
|
||||
if (x++ == item.src_idx) {
|
||||
std::size_t len = item.end_pos - item.beg_pos;
|
||||
assert(len > 0);
|
||||
assert(len < 2048);
|
||||
ifstream in(path);
|
||||
in.seekg(item.beg_pos, std::ios::beg);
|
||||
std::size_t len = item.end_pos - item.beg_pos;
|
||||
assert(len > 0);
|
||||
assert(len < 2048);
|
||||
|
||||
ifstream in(item.pathname);
|
||||
in.seekg(item.beg_pos, std::ios::beg);
|
||||
|
||||
scoped_array<char> buf(new char[len + 1]);
|
||||
in.read(buf.get(), len);
|
||||
scoped_array<char> buf(new char[len + 1]);
|
||||
in.read(buf.get(), len);
|
||||
|
||||
std::ostringstream out;
|
||||
std::ostringstream out;
|
||||
|
||||
out << "While balancing item from \"" << path.string()
|
||||
<< "\"";
|
||||
out << "While balancing item from \"" << item.pathname.string()
|
||||
<< "\"";
|
||||
|
||||
if (item.beg_line != (item.end_line - 1))
|
||||
out << ", lines " << item.beg_line << "-"
|
||||
<< (item.end_line - 1) << ":\n";
|
||||
else
|
||||
out << ", line " << item.beg_line << ":\n";
|
||||
if (item.beg_line != (item.end_line - 1))
|
||||
out << ", lines " << item.beg_line << "-"
|
||||
<< (item.end_line - 1) << ":\n";
|
||||
else
|
||||
out << ", line " << item.beg_line << ":\n";
|
||||
|
||||
bool first = true;
|
||||
for (char * p = std::strtok(buf.get(), "\n");
|
||||
p;
|
||||
p = std::strtok(NULL, "\n")) {
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
out << '\n';
|
||||
out << "> " << p;
|
||||
}
|
||||
return out.str();
|
||||
}
|
||||
bool first = true;
|
||||
for (char * p = std::strtok(buf.get(), "\n");
|
||||
p;
|
||||
p = std::strtok(NULL, "\n")) {
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
out << '\n';
|
||||
out << "> " << p;
|
||||
}
|
||||
assert(false);
|
||||
return empty_string;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
} // namespace ledger
|
||||
|
|
|
|||
18
src/item.h
18
src/item.h
|
|
@ -51,8 +51,6 @@
|
|||
|
||||
namespace ledger {
|
||||
|
||||
class journal_t;
|
||||
|
||||
/**
|
||||
* @brief Brief
|
||||
*
|
||||
|
|
@ -62,9 +60,9 @@ class item_t : public supports_flags<>, public scope_t
|
|||
{
|
||||
public:
|
||||
#define ITEM_NORMAL 0x00 // no flags at all, a basic transaction
|
||||
#define ITEM_IN_CACHE 0x01 // transaction allocated by the binary cache
|
||||
#define ITEM_GENERATED 0x02 // transaction was not found in a journal
|
||||
#define ITEM_TEMP 0x04 // transaction is a temporary object
|
||||
#define ITEM_IN_CACHE 0x01 // transaction allocated by the binary cache
|
||||
#define ITEM_GENERATED 0x02 // transaction was not found in a journal
|
||||
#define ITEM_TEMP 0x04 // transaction is a temporary object
|
||||
|
||||
enum state_t { UNCLEARED = 0, CLEARED, PENDING };
|
||||
|
||||
|
|
@ -77,9 +75,7 @@ public:
|
|||
typedef std::map<string, optional<string> > string_map;
|
||||
optional<string_map> metadata;
|
||||
|
||||
journal_t * journal;
|
||||
|
||||
unsigned short src_idx;
|
||||
path pathname;
|
||||
istream_pos_type beg_pos;
|
||||
std::size_t beg_line;
|
||||
istream_pos_type end_pos;
|
||||
|
|
@ -88,8 +84,7 @@ public:
|
|||
static bool use_effective_date;
|
||||
|
||||
item_t(flags_t _flags = ITEM_NORMAL, const optional<string>& _note = none)
|
||||
: supports_flags<>(_flags),
|
||||
_state(UNCLEARED), note(_note), journal(NULL), src_idx(0),
|
||||
: supports_flags<>(_flags), _state(UNCLEARED), note(_note),
|
||||
beg_pos(0), beg_line(0), end_pos(0), end_line(0)
|
||||
{
|
||||
TRACE_CTOR(item_t, "flags_t, const string&");
|
||||
|
|
@ -113,8 +108,7 @@ public:
|
|||
|
||||
note = item.note;
|
||||
|
||||
journal = item.journal;
|
||||
src_idx = item.src_idx;
|
||||
pathname = item.pathname;
|
||||
beg_pos = item.beg_pos;
|
||||
beg_line = item.beg_line;
|
||||
end_pos = item.end_pos;
|
||||
|
|
|
|||
|
|
@ -155,7 +155,6 @@ textual_parser_t::instance_t::instance_t
|
|||
account_stack.push_front(master);
|
||||
|
||||
pathname = journal.sources.back();
|
||||
src_idx = journal.sources.size() - 1;
|
||||
linenum = 1;
|
||||
beg_pos = in.tellg();
|
||||
beg_line = linenum;
|
||||
|
|
@ -472,7 +471,7 @@ void textual_parser_t::instance_t::automated_entry_directive(char * line)
|
|||
if (parse_xacts(in, account_stack.front(), *ae, "automated",
|
||||
end_pos)) {
|
||||
journal.auto_entries.push_back(ae);
|
||||
ae->src_idx = src_idx;
|
||||
ae->pathname = pathname;
|
||||
ae->beg_pos = beg_pos;
|
||||
ae->beg_line = beg_line;
|
||||
ae->end_pos = end_pos;
|
||||
|
|
@ -491,7 +490,7 @@ void textual_parser_t::instance_t::period_entry_directive(char * line)
|
|||
if (pe->finalize()) {
|
||||
extend_entry_base(&journal, *pe, true);
|
||||
journal.period_entries.push_back(pe);
|
||||
pe->src_idx = src_idx;
|
||||
pe->pathname = pathname;
|
||||
pe->beg_pos = beg_pos;
|
||||
pe->beg_line = beg_line;
|
||||
pe->end_pos = end_pos;
|
||||
|
|
@ -514,7 +513,7 @@ void textual_parser_t::instance_t::entry_directive(char * line)
|
|||
// would cause us to leak without this guard.
|
||||
std::auto_ptr<entry_t> entry_ptr(entry);
|
||||
|
||||
entry->src_idx = src_idx;
|
||||
entry->pathname = pathname;
|
||||
entry->beg_pos = beg_pos;
|
||||
entry->beg_line = beg_line;
|
||||
entry->end_pos = pos;
|
||||
|
|
|
|||
|
|
@ -94,7 +94,6 @@ protected:
|
|||
|
||||
path pathname;
|
||||
std::size_t linenum;
|
||||
std::size_t src_idx;
|
||||
istream_pos_type beg_pos;
|
||||
std::size_t beg_line;
|
||||
istream_pos_type end_pos;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue