summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cc61
-rw-r--r--src/report.h15
-rw-r--r--src/session.cc2
3 files changed, 52 insertions, 26 deletions
diff --git a/src/main.cc b/src/main.cc
index 0c9c901a..35efaa90 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -58,8 +58,49 @@ namespace ledger {
session_t& session(report.session);
+ // Setup global defaults
+
+ optional<path> home;
+ if (const char * home_var = std::getenv("HOME"))
+ home = home_var;
+
+ session.init_file = home ? *home / ".ledgerrc" : "./.ledgerrc";
+ session.price_db = home ? *home / ".pricedb" : "./.pricedb";
+ session.cache_file = home ? *home / ".ledger-cache" : "./.ledger-cache";
+
+ // Process the environment settings
+
+ TRACE_START(environment, 1, "Processed environment variables");
+
+ process_environment(const_cast<const char **>(envp), "LEDGER_", report);
+
+#if 1
+ // These are here for backwards compatability, but are deprecated.
+
+ if (const char * p = std::getenv("LEDGER"))
+ process_option("file", report, p);
+ if (const char * p = std::getenv("LEDGER_INIT"))
+ process_option("init-file", report, p);
+ if (const char * p = std::getenv("PRICE_HIST"))
+ process_option("price-db", report, p);
+ if (const char * p = std::getenv("PRICE_EXP"))
+ process_option("price-exp", report, p);
+#endif
+
+ TRACE_FINISH(environment, 1);
+
+ // Read the initialization file
+
+ TRACE_START(init, 1, "Read initialization file");
+
+ session.read_init();
+
+ TRACE_FINISH(init, 1);
+
// Handle the command-line arguments
+ TRACE_START(arguments, 1, "Processing command-line arguments");
+
strings_list args;
process_arguments(argc - 1, argv + 1, false, report, args);
@@ -76,24 +117,6 @@ namespace ledger {
DEBUG("ledger.session.cache", "1. use_cache = " << session.use_cache);
- // Process the environment settings
-
- TRACE_START(environment, 1, "Processed environment variables");
- process_environment(const_cast<const char **>(envp), "LEDGER_", report);
- TRACE_FINISH(environment, 1);
-
- optional<path> home;
- if (const char * home_var = std::getenv("HOME"))
- home = home_var;
-
- if (! session.init_file)
- session.init_file = home ? *home / ".ledgerrc" : "./.ledgerrc";
- if (! session.price_db)
- session.price_db = home ? *home / ".pricedb" : "./.pricedb";
-
- if (! session.cache_file)
- session.cache_file = home ? *home / ".ledger-cache" : "./.ledger-cache";
-
if (session.data_file == *session.cache_file)
session.use_cache = false;
@@ -107,6 +130,8 @@ namespace ledger {
if (! session.use_cache)
INFO("Binary cache mechanism will not be used");
+ TRACE_FINISH(arguments, 1);
+
// Configure the output stream
#ifdef HAVE_UNIX_PIPES
diff --git a/src/report.h b/src/report.h
index 61720a0a..59380949 100644
--- a/src/report.h
+++ b/src/report.h
@@ -730,20 +730,23 @@ public:
}
value_t option_quantity(call_scope_t& args) { // O
- amount_expr = "amount";
- total_expr = "total";
+ show_revalued = false;
+ amount_expr = "amount";
+ total_expr = "total";
return true;
}
value_t option_cost(call_scope_t& args) { // B
- amount_expr = "cost";
- total_expr = "total_cost";
+ show_revalued = false;
+ amount_expr = "cost";
+ total_expr = "total_cost";
return true;
}
value_t option_price(call_scope_t& args) { // I
- amount_expr = "price";
- total_expr = "price_total";
+ show_revalued = false;
+ amount_expr = "price";
+ total_expr = "price_total";
return true;
}
diff --git a/src/session.cc b/src/session.cc
index fa61e08b..4183e417 100644
--- a/src/session.cc
+++ b/src/session.cc
@@ -179,8 +179,6 @@ std::size_t session_t::read_data(journal_t& journal,
std::size_t entry_count = 0;
- read_init();
-
DEBUG("ledger.cache", "3. use_cache = " << use_cache);
if (use_cache && cache_file) {