summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am8
-rw-r--r--NEWS6
-rw-r--r--binary.cc20
-rw-r--r--configure.in9
-rw-r--r--format.cc2
-rw-r--r--gnucash.cc10
-rw-r--r--journal.h14
-rw-r--r--main.cc6
-rw-r--r--qif.cc8
-rw-r--r--textual.cc32
10 files changed, 3 insertions, 112 deletions
diff --git a/Makefile.am b/Makefile.am
index 077a0484..8889b00d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,6 +7,7 @@ libledger_la_SOURCES = \
config.cc \
datetime.cc \
derive.cc \
+ emacs.cc \
format.cc \
journal.cc \
mask.cc \
@@ -20,10 +21,6 @@ libledger_la_SOURCES = \
valexpr.cc \
value.cc \
walk.cc
-if USE_EDITOR
-libledger_la_CXXFLAGS += -DUSE_EDITOR=1
-libledger_la_SOURCES += emacs.cc
-endif
if HAVE_EXPAT
libledger_la_CXXFLAGS += -DHAVE_EXPAT=1
libledger_la_SOURCES += gnucash.cc xml.cc
@@ -77,9 +74,6 @@ 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
diff --git a/NEWS b/NEWS
index 2c247f70..50d5d72c 100644
--- a/NEWS
+++ b/NEWS
@@ -10,12 +10,6 @@
- Added new @min(x,y) and @max(x,y) value expression functions.
-- A new configure option "--disable-emacs" will disable generation of
- transaction and entry location info, which is used by ledger.el and
- the "write" command. If you use neither of these, then disabling
- them will cut textual parsing time in half, and binary loading time
- (and cache file size) by a third.
-
- Effective dates may now be specified for entries:
2004/10/03=2004/09/30 Credit card company
diff --git a/binary.cc b/binary.cc
index 84885335..b41d2bab 100644
--- a/binary.cc
+++ b/binary.cc
@@ -11,18 +11,10 @@
namespace ledger {
static unsigned long binary_magic_number = 0xFFEED765;
-#ifdef USE_EDITOR
#ifdef DEBUG_ENABLED
-static unsigned long format_version = 0x00020589;
+static unsigned long format_version = 0x0002050b;
#else
-static unsigned long format_version = 0x00020588;
-#endif
-#else
-#ifdef DEBUG_ENABLED
-static unsigned long format_version = 0x00020509;
-#else
-static unsigned long format_version = 0x00020508;
-#endif
+static unsigned long format_version = 0x0002050a;
#endif
static account_t ** accounts;
@@ -322,12 +314,10 @@ inline void read_binary_transaction(char *& data, transaction_t * xact)
xact->flags |= TRANSACTION_BULK_ALLOC;
read_binary_string(data, &xact->note);
-#ifdef USE_EDITOR
xact->beg_pos = read_binary_long<unsigned long>(data);
read_binary_long(data, xact->beg_line);
xact->end_pos = read_binary_long<unsigned long>(data);
read_binary_long(data, xact->end_line);
-#endif
xact->data = NULL;
@@ -340,13 +330,11 @@ 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, bool& finalize)
{
-#ifdef USE_EDITOR
read_binary_long(data, entry->src_idx);
entry->beg_pos = read_binary_long<unsigned long>(data);
read_binary_long(data, entry->beg_line);
entry->end_pos = read_binary_long<unsigned long>(data);
read_binary_long(data, entry->end_line);
-#endif
bool ignore_calculated = read_binary_number<char>(data) == 1;
@@ -809,23 +797,19 @@ void write_binary_transaction(std::ostream& out, transaction_t * xact,
write_binary_number(out, xact->flags);
write_binary_string(out, xact->note);
-#ifdef USE_EDITOR
write_binary_long(out, xact->beg_pos);
write_binary_long(out, xact->beg_line);
write_binary_long(out, xact->end_pos);
write_binary_long(out, xact->end_line);
-#endif
}
void write_binary_entry_base(std::ostream& out, entry_base_t * entry)
{
-#ifdef USE_EDITOR
write_binary_long(out, entry->src_idx);
write_binary_long(out, entry->beg_pos);
write_binary_long(out, entry->beg_line);
write_binary_long(out, entry->end_pos);
write_binary_long(out, entry->end_line);
-#endif
bool ignore_calculated = false;
for (transactions_list::const_iterator i = entry->transactions.begin();
diff --git a/configure.in b/configure.in
index ce50acc5..88acb260 100644
--- a/configure.in
+++ b/configure.in
@@ -200,15 +200,6 @@ AC_ARG_ENABLE(debug,
esac],[debug=false])
AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
-AC_ARG_ENABLE(emacs,
- [ --enable-emacs Turn on Emacs support],
- [case "${enableval}" in
- yes) emacs=true ;;
- no) emacs=false ;;
- *) AC_MSG_ERROR(bad value ${enableval} for --enable-emacs) ;;
- esac],[emacs=true])
-AM_CONDITIONAL(USE_EDITOR, test x$emacs = xtrue)
-
# Checks for header files.
AC_STDC_HEADERS
AC_HAVE_HEADERS(sys/stat.h)
diff --git a/format.cc b/format.cc
index 98bedff5..bf769e3e 100644
--- a/format.cc
+++ b/format.cc
@@ -388,7 +388,6 @@ void format_t::format(std::ostream& out_str, const details_t& details) const
}
break;
-#ifdef USE_EDITOR
case element_t::SOURCE:
if (details.entry && details.entry->journal) {
int idx = details.entry->src_idx;
@@ -441,7 +440,6 @@ void format_t::format(std::ostream& out_str, const details_t& details) const
if (details.xact)
out << details.xact->end_line;
break;
-#endif
case element_t::DATE_STRING: {
std::time_t date = 0;
diff --git a/gnucash.cc b/gnucash.cc
index 4b537959..8b27490c 100644
--- a/gnucash.cc
+++ b/gnucash.cc
@@ -45,11 +45,9 @@ static std::istream * instreamp;
static unsigned int offset;
static XML_Parser parser;
static std::string path;
-#ifdef USE_EDITOR
static unsigned int src_idx;
static istream_pos_type beg_pos;
static unsigned long beg_line;
-#endif
static transaction_t::state_t curr_state;
@@ -148,13 +146,11 @@ static void endElement(void *userData, const char *name)
have_error = "The above entry does not balance";
delete curr_entry;
} else {
-#ifdef USE_EDITOR
curr_entry->src_idx = src_idx;
curr_entry->beg_pos = beg_pos;
curr_entry->beg_line = beg_line;
curr_entry->end_pos = instreamp->tellg();
curr_entry->end_line = XML_GetCurrentLineNumber(parser) - offset;
-#endif
count++;
}
@@ -193,12 +189,10 @@ static void endElement(void *userData, const char *name)
if (value != curr_value)
xact->cost = new amount_t(curr_value);
-#ifdef USE_EDITOR
xact->beg_pos = beg_pos;
xact->beg_line = beg_line;
xact->end_pos = instreamp->tellg();
xact->end_line = XML_GetCurrentLineNumber(parser) - offset;
-#endif
// Clear the relevant variables for the next run
curr_state = transaction_t::UNCLEARED;
@@ -382,9 +376,7 @@ unsigned int gnucash_parser_t::parse(std::istream& in,
instreamp = &in;
path = original_file ? *original_file : "<gnucash>";
-#ifdef USE_EDITOR
src_idx = journal->sources.size() - 1;
-#endif
// GnuCash uses the USD commodity without defining it, which really
// means $.
@@ -401,10 +393,8 @@ unsigned int gnucash_parser_t::parse(std::istream& in,
XML_SetCharacterDataHandler(parser, dataHandler);
while (in.good() && ! in.eof()) {
-#ifdef USE_EDITOR
beg_pos = in.tellg();
beg_line = (XML_GetCurrentLineNumber(parser) - offset) + 1;
-#endif
in.getline(buf, BUFSIZ - 1);
std::strcat(buf, "\n");
diff --git a/journal.h b/journal.h
index e0007634..8a6ac32b 100644
--- a/journal.h
+++ b/journal.h
@@ -44,12 +44,10 @@ class transaction_t
state_t state;
unsigned short flags;
std::string note;
-#ifdef USE_EDITOR
istream_pos_type beg_pos;
unsigned long beg_line;
istream_pos_type end_pos;
unsigned long end_line;
-#endif
mutable void * data;
static bool use_effective_date;
@@ -58,9 +56,7 @@ class transaction_t
: entry(NULL), _date(0), _date_eff(0), account(_account),
amount_expr(NULL), cost(NULL), cost_expr(NULL),
state(UNCLEARED), flags(TRANSACTION_NORMAL),
-#ifdef USE_EDITOR
beg_pos(0), beg_line(0), end_pos(0), end_line(0),
-#endif
data(NULL) {
DEBUG_PRINT("ledger.memory.ctors", "ctor transaction_t");
}
@@ -72,9 +68,7 @@ class transaction_t
: entry(NULL), _date(0), _date_eff(0), account(_account),
amount(_amount), amount_expr(NULL), cost(NULL), cost_expr(NULL),
state(UNCLEARED), flags(_flags), note(_note),
-#ifdef USE_EDITOR
beg_pos(0), beg_line(0), end_pos(0), end_line(0),
-#endif
data(NULL) {
DEBUG_PRINT("ledger.memory.ctors", "ctor transaction_t");
}
@@ -84,9 +78,7 @@ class transaction_t
amount(xact.amount), amount_expr(NULL),
cost(xact.cost ? new amount_t(*xact.cost) : NULL), cost_expr(NULL),
state(xact.state), flags(xact.flags), note(xact.note),
-#ifdef USE_EDITOR
beg_pos(0), beg_line(0), end_pos(0), end_line(0),
-#endif
data(NULL) {
DEBUG_PRINT("ledger.memory.ctors", "ctor transaction_t");
}
@@ -124,26 +116,20 @@ class entry_base_t
{
public:
journal_t * journal;
-#ifdef USE_EDITOR
unsigned long src_idx;
istream_pos_type beg_pos;
unsigned long beg_line;
istream_pos_type end_pos;
unsigned long end_line;
-#endif
transactions_list transactions;
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),
-#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();
diff --git a/main.cc b/main.cc
index b727b23b..7145a477 100644
--- a/main.cc
+++ b/main.cc
@@ -104,10 +104,8 @@ int parse_and_report(int argc, char * argv[], char * envp[])
command = "p";
else if (command == "output")
command = "w";
-#ifdef USE_EDITOR
else if (command == "emacs")
command = "x";
-#endif
else if (command == "xml")
command = "X";
else if (command == "entry")
@@ -245,10 +243,8 @@ int parse_and_report(int argc, char * argv[], char * envp[])
formatter = new set_account_value;
else if (command == "p" || command == "e")
formatter = new format_entries(*out, *format);
-#ifdef USE_EDITOR
else if (command == "x")
formatter = new format_emacs_transactions(*out);
-#endif
else if (command == "X") {
#if defined(HAVE_EXPAT) || defined(HAVE_XMLPARSE)
formatter = new format_xml_entries(*out, config.show_totals);
@@ -259,10 +255,8 @@ int parse_and_report(int argc, char * argv[], char * envp[])
formatter = new format_transactions(*out, *format);
if (command == "w") {
-#ifdef USE_EDITOR
write_textual_journal(*journal, first_arg, *formatter,
config.write_hdr_format, *out);
-#endif
} else {
formatter = config.chain_xact_handlers(command, formatter, journal.get(),
journal->master, formatter_ptrs);
diff --git a/qif.cc b/qif.cc
index 9bce9f04..629ce289 100644
--- a/qif.cc
+++ b/qif.cc
@@ -63,7 +63,6 @@ unsigned int qif_parser_t::parse(std::istream& in,
src_idx = journal->sources.size() - 1;
linenum = 1;
-#ifdef USE_EDITOR
istream_pos_type beg_pos = 0;
unsigned long beg_line = 0;
@@ -72,9 +71,6 @@ unsigned int qif_parser_t::parse(std::istream& in,
beg_pos = in.tellg(); \
beg_line = linenum; \
}
-#else
-#define SET_BEG_POS_AND_LINE()
-#endif
while (in.good() && ! in.eof()) {
char c;
@@ -221,13 +217,11 @@ unsigned int qif_parser_t::parse(std::istream& in,
}
if (journal->add_entry(entry.get())) {
-#ifdef USE_EDITOR
entry->src_idx = src_idx;
entry->beg_pos = beg_pos;
entry->beg_line = beg_line;
entry->end_pos = in.tellg();
entry->end_line = linenum;
-#endif
entry.release();
count++;
}
@@ -240,9 +234,7 @@ unsigned int qif_parser_t::parse(std::istream& in,
saw_splits = false;
saw_category = false;
total = NULL;
-#ifdef USE_EDITOR
beg_line = 0;
-#endif
break;
}
diff --git a/textual.cc b/textual.cc
index 4fd9d837..f6844125 100644
--- a/textual.cc
+++ b/textual.cc
@@ -318,9 +318,7 @@ bool parse_transactions(std::istream& in,
in.getline(line, MAX_LINE);
if (in.eof())
break;
-#ifdef USE_EDITOR
beg_pos += istream_pos_type(std::strlen(line) + 1);
-#endif
linenum++;
if (line[0] == ' ' || line[0] == '\t' || line[0] == '\r') {
char * p = skip_ws(line);
@@ -403,18 +401,14 @@ entry_t * parse_entry(std::istream& in, char * line, account_t * master,
TIMER_START(entry_xacts);
-#ifdef USE_EDITOR
istream_pos_type end_pos;
unsigned long beg_line = linenum;
-#endif
while (! in.eof() && (in.peek() == ' ' || in.peek() == '\t')) {
line[0] = '\0';
in.getline(line, MAX_LINE);
if (in.eof() && line[0] == '\0')
break;
-#ifdef USE_EDITOR
end_pos = beg_pos + istream_pos_type(std::strlen(line) + 1);
-#endif
linenum++;
if (line[0] == ' ' || line[0] == '\t' || line[0] == '\r') {
@@ -428,13 +422,11 @@ entry_t * parse_entry(std::istream& in, char * line, account_t * master,
xact->state == transaction_t::UNCLEARED)
xact->state = state;
-#ifdef USE_EDITOR
xact->beg_pos = beg_pos;
xact->beg_line = beg_line;
xact->end_pos = end_pos;
xact->end_line = linenum;
beg_pos = end_pos;
-#endif
curr->add_transaction(xact);
}
@@ -547,20 +539,16 @@ unsigned int textual_parser_t::parse(std::istream& in,
src_idx = journal->sources.size() - 1;
linenum = 1;
-#ifdef USE_EDITOR
istream_pos_type beg_pos = in.tellg();
istream_pos_type end_pos;
unsigned long beg_line = linenum;
-#endif
while (in.good() && ! in.eof()) {
try {
in.getline(line, MAX_LINE);
if (in.eof())
break;
linenum++;
-#ifdef USE_EDITOR
end_pos = beg_pos + istream_pos_type(std::strlen(line) + 1);
-#endif
switch (line[0]) {
case '\0':
@@ -710,13 +698,11 @@ unsigned int textual_parser_t::parse(std::istream& in,
if (parse_transactions(in, account_stack.front(), *ae,
"automated", end_pos)) {
journal->auto_entries.push_back(ae);
-#ifdef USE_EDITOR
ae->src_idx = src_idx;
ae->beg_pos = beg_pos;
ae->beg_line = beg_line;
ae->end_pos = end_pos;
ae->end_line = linenum;
-#endif
}
break;
}
@@ -732,13 +718,11 @@ unsigned int textual_parser_t::parse(std::istream& in,
if (pe->finalize()) {
extend_entry_base(journal, *pe);
journal->period_entries.push_back(pe);
-#ifdef USE_EDITOR
pe->src_idx = src_idx;
pe->beg_pos = beg_pos;
pe->beg_line = beg_line;
pe->end_pos = end_pos;
pe->end_line = linenum;
-#endif
} else {
throw parse_error(path, linenum, "Period entry failed to balance");
}
@@ -752,10 +736,8 @@ unsigned int textual_parser_t::parse(std::istream& in,
if (word == "include") {
push_var<std::string> save_path(path);
push_var<unsigned int> save_src_idx(src_idx);
-#ifdef USE_EDITOR
push_var<istream_pos_type> save_beg_pos(beg_pos);
push_var<istream_pos_type> save_end_pos(end_pos);
-#endif
push_var<unsigned int> save_linenum(linenum);
path = p;
@@ -804,21 +786,15 @@ unsigned int textual_parser_t::parse(std::istream& in,
default: {
unsigned int first_line = linenum;
-#ifdef USE_EDITOR
istream_pos_type pos = end_pos;
-#else
- istream_pos_type pos;
-#endif
if (entry_t * entry =
parse_entry(in, line, account_stack.front(), *this, pos)) {
if (journal->add_entry(entry)) {
-#ifdef USE_EDITOR
entry->src_idx = src_idx;
entry->beg_pos = beg_pos;
entry->beg_line = beg_line;
entry->end_pos = end_pos;
entry->end_line = linenum;
-#endif
count++;
} else {
print_entry(std::cerr, *entry);
@@ -833,9 +809,7 @@ unsigned int textual_parser_t::parse(std::istream& in,
} else {
throw parse_error(path, first_line, "Failed to parse entry");
}
-#ifdef USE_EDITOR
end_pos = pos;
-#endif
break;
}
}
@@ -854,9 +828,7 @@ unsigned int textual_parser_t::parse(std::istream& in,
<< err.what() << std::endl;;
errors++;
}
-#ifdef USE_EDITOR
beg_pos = end_pos;
-#endif
}
done:
@@ -876,8 +848,6 @@ unsigned int textual_parser_t::parse(std::istream& in,
return count;
}
-#ifdef USE_EDITOR
-
void write_textual_journal(journal_t& journal, std::string path,
item_handler<transaction_t>& formatter,
const std::string& write_hdr_format,
@@ -964,6 +934,4 @@ void write_textual_journal(journal_t& journal, std::string path,
}
}
-#endif // USE_EDITOR
-
} // namespace ledger