From: hniksic Date: Thu, 5 May 2005 18:45:05 +0000 (-0700) Subject: [svn] Propagate option name to init.c code so error messages mention the X-Git-Tag: v1.13~1091 X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=bb60858a3f02ce9c755b43bcca75e015d5bc1f1a [svn] Propagate option name to init.c code so error messages mention the failed command-line option. --- diff --git a/src/ChangeLog b/src/ChangeLog index 1724adde..3811d130 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2005-05-05 Hrvoje Niksic + + * main.c (main): Propagate option name to setoptval. + + * init.c (setoptval): Accept another argument, OPTNAME. Propagate + that argument as the option name independently of the actual + command, determined by command_by_name(com). + 2005-05-05 Hrvoje Niksic * init.c (parse_line): Make the return value indicate whether diff --git a/src/init.c b/src/init.c index f4dfdd9a..b70a7c6e 100644 --- a/src/init.c +++ b/src/init.c @@ -627,10 +627,16 @@ setval_internal (int comind, const char *com, const char *val) to accept COMIND directly. */ void -setoptval (const char *com, const char *val) +setoptval (const char *com, const char *val, const char *optname) { + /* Prepend "--" to OPTNAME. */ + char *dd_optname = (char *) alloca (2 + strlen (optname) + 1); + dd_optname[0] = '-'; + dd_optname[1] = '-'; + strcpy (dd_optname + 2, optname); + assert (val != NULL); - if (!setval_internal (command_by_name (com), com, val)) + if (!setval_internal (command_by_name (com), dd_optname, val)) exit (2); } diff --git a/src/init.h b/src/init.h index 048653ba..3bddd16d 100644 --- a/src/init.h +++ b/src/init.h @@ -32,7 +32,7 @@ so, delete this exception statement from your version. */ void initialize PARAMS ((void)); void run_command PARAMS ((const char *)); -void setoptval PARAMS ((const char *, const char *)); +void setoptval PARAMS ((const char *, const char *, const char *)); char *home_dir PARAMS ((void)); void cleanup PARAMS ((void)); diff --git a/src/main.c b/src/main.c index a1191ad6..836ae3c8 100644 --- a/src/main.c +++ b/src/main.c @@ -721,17 +721,17 @@ main (int argc, char *const *argv) switch (opt->type) { case OPT_VALUE: - setoptval (opt->data, optarg); + setoptval (opt->data, optarg, opt->long_name); break; case OPT_BOOLEAN: if (optarg) /* The user has specified a value -- use it. */ - setoptval (opt->data, optarg); + setoptval (opt->data, optarg, opt->long_name); else { /* NEG is true for `--no-FOO' style boolean options. */ int neg = val & BOOLEAN_NEG_MARKER; - setoptval (opt->data, neg ? "0" : "1"); + setoptval (opt->data, neg ? "0" : "1", opt->long_name); } break; case OPT_FUNCALL: @@ -741,7 +741,7 @@ main (int argc, char *const *argv) } break; case OPT__APPEND_OUTPUT: - setoptval ("logfile", optarg); + setoptval ("logfile", optarg, opt->long_name); append_to_log = 1; break; case OPT__EXECUTE: @@ -757,19 +757,19 @@ main (int argc, char *const *argv) switch (*p) { case 'v': - setoptval ("verbose", "0"); + setoptval ("verbose", "0", opt->long_name); break; case 'H': - setoptval ("addhostdir", "0"); + setoptval ("addhostdir", "0", opt->long_name); break; case 'd': - setoptval ("dirstruct", "0"); + setoptval ("dirstruct", "0", opt->long_name); break; case 'c': - setoptval ("noclobber", "1"); + setoptval ("noclobber", "1", opt->long_name); break; case 'p': - setoptval ("noparent", "1"); + setoptval ("noparent", "1", opt->long_name); break; default: printf (_("%s: illegal option -- `-n%c'\n"), exec_name, *p); @@ -792,11 +792,11 @@ main (int argc, char *const *argv) || (TOLOWER (optarg[0]) == 'o' && TOLOWER (optarg[1]) == 'n')); setoptval (opt->type == OPT__PARENT ? "noparent" : "noclobber", - flag ? "0" : "1"); + flag ? "0" : "1", opt->long_name); break; } case OPT__DONT_REMOVE_LISTING: - setoptval ("removelisting", "0"); + setoptval ("removelisting", "0", opt->long_name); break; }