summaryrefslogtreecommitdiff
path: root/src/option.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-06-02 19:14:46 +0100
committerJohn Wiegley <johnw@newartisans.com>2009-06-02 19:14:46 +0100
commitc79fd9e72de4c2355ddb867bf269973bdd2cfd00 (patch)
treed5dcc657961a3d1b6cfee3d49e7f5169b44fc13b /src/option.cc
parente2092d07d85079215a0e068eb46c0d41bbd28a54 (diff)
downloadfork-ledger-c79fd9e72de4c2355ddb867bf269973bdd2cfd00.tar.gz
fork-ledger-c79fd9e72de4c2355ddb867bf269973bdd2cfd00.tar.bz2
fork-ledger-c79fd9e72de4c2355ddb867bf269973bdd2cfd00.zip
Added new debug option --options
This reports which options are in place before invoking a command, and where exactly each option value came from.
Diffstat (limited to 'src/option.cc')
-rw-r--r--src/option.cc18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/option.cc b/src/option.cc
index 7d5b272d..1275e270 100644
--- a/src/option.cc
+++ b/src/option.cc
@@ -76,11 +76,13 @@ namespace {
return op_bool_tuple(scope.lookup(buf), false);
}
- void process_option(const function_t& opt, scope_t& scope,
- const char * arg, const string& name)
+ void process_option(const string& whence, const function_t& opt,
+ scope_t& scope, const char * arg, const string& name)
{
try {
call_scope_t args(scope);
+
+ args.push_back(string_value(whence));
if (arg)
args.push_back(string_value(arg));
@@ -97,12 +99,12 @@ namespace {
}
}
-void process_option(const string& name, scope_t& scope,
+void process_option(const string& whence, const string& name, scope_t& scope,
const char * arg, const string& varname)
{
op_bool_tuple opt(find_option(scope, name));
if (opt.first)
- process_option(opt.first->as_function(), scope, arg, varname);
+ process_option(whence, opt.first->as_function(), scope, arg, varname);
}
void process_environment(const char ** envp, const string& tag,
@@ -129,7 +131,7 @@ void process_environment(const char ** envp, const string& tag,
try {
string value = string(*p, q - *p);
if (! value.empty())
- process_option(string(buf), scope, q + 1, value);
+ process_option(string("$") + buf, string(buf), scope, q + 1, value);
}
catch (const std::exception& err) {
add_error_context(_("While parsing environment variable option '%1':")
@@ -201,7 +203,8 @@ strings_list process_arguments(strings_list args, scope_t& scope)
if (value == NULL)
throw_(option_error, _("Missing option argument for --%1") << name);
}
- process_option(opt.first->as_function(), scope, value,
+ process_option(string("--") + name,
+ opt.first->as_function(), scope, value,
string("--") + name);
}
else if ((*i)[1] == '\0') {
@@ -230,7 +233,8 @@ strings_list process_arguments(strings_list args, scope_t& scope)
throw_(option_error,
_("Missing option argument for -%1") << o.ch);
}
- process_option(o.op->as_function(), scope, value, string("-") + o.ch);
+ process_option(string("-") + o.ch, o.op->as_function(), scope, value,
+ string("-") + o.ch);
}
}
}