--- /dev/null
+ o Minor bugfixes (interface):
+ - Print usage information for --dump-config when it is used without
+ an argument. Also, fix the error message to use different wording
+ and add newline at the end. Fixes bug 15541; bugfix on 0.2.5.1-alpha.
+
return 0;
}
+typedef enum {
+ TAKES_NO_ARGUMENT = 0,
+ ARGUMENT_NECESSARY = 1,
+ ARGUMENT_OPTIONAL = 2
+} takes_argument_t;
+
static const struct {
const char *name;
- int takes_argument;
+ takes_argument_t takes_argument;
} CMDLINE_ONLY_OPTIONS[] = {
{ "-f", 1 },
{ "--allow-missing-torrc", 0 },
{ "--defaults-torrc", 1 },
{ "--hash-password", 1 },
- { "--dump-config", 1 },
+ { "--dump-config", ARGUMENT_OPTIONAL },
{ "--list-fingerprint", 0 },
{ "--verify-config", 0 },
{ "--ignore-missing-torrc", 0 },
while (i < argc) {
unsigned command = CONFIG_LINE_NORMAL;
- int want_arg = 1;
+ takes_argument_t want_arg = ARGUMENT_NECESSARY;
int is_cmdline = 0;
int j;
want_arg = 0;
}
- if (want_arg && i == argc-1) {
+ const int is_last = (i == argc-1);
+
+ if (want_arg == ARGUMENT_NECESSARY && is_last) {
if (ignore_errors) {
arg = strdup("");
} else {
config_free_lines(front_cmdline);
return -1;
}
+ } else if (want_arg == ARGUMENT_OPTIONAL && is_last) {
+ arg = tor_strdup("");
} else {
- arg = want_arg ? tor_strdup(argv[i+1]) : strdup("");
+ arg = (want_arg != TAKES_NO_ARGUMENT) ? tor_strdup(argv[i+1]) :
+ tor_strdup("");
}
param = tor_malloc_zero(sizeof(config_line_t));
} else if (!strcmp(arg, "full")) {
how = OPTIONS_DUMP_ALL;
} else {
- fprintf(stderr, "No recognizable option to --dump-config found!\n");
+ fprintf(stderr, "No valid argument to --dump-config found!\n");
fprintf(stderr, "Please select 'short', 'non-builtin', or 'full'.\n");
return -1;