#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
-#include <sys/types.h>
-#ifdef HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-#endif /* HAVE_STRING_H */
+#include <string.h>
#ifdef HAVE_SIGNAL_H
# include <signal.h>
#endif
#endif /* HAVE_LOCALE_H */
#endif /* HAVE_NLS */
#include <assert.h>
-
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
#include "wget.h"
#include "utils.h"
extern struct cookie_jar *wget_cookie_jar;
-static RETSIGTYPE redirect_output_signal PARAMS ((int));
+static RETSIGTYPE redirect_output_signal (int);
const char *exec_name;
\f
-/* Initialize I18N. The initialization amounts to invoking
- setlocale(), bindtextdomain() and textdomain().
- Does nothing if NLS is disabled or missing. */
+/* Initialize I18N/L10N. That amounts to invoking setlocale, and
+ setting up gettext's message catalog using bindtextdomain and
+ textdomain. Does nothing if NLS is disabled or missing. */
+
static void
i18n_initialize (void)
{
- /* If HAVE_NLS is defined, assume the existence of the three
- functions invoked here. */
+ /* HAVE_NLS implies existence of functions invoked here. */
#ifdef HAVE_NLS
/* Set the current locale. */
- /* Here we use LC_MESSAGES instead of LC_ALL, for two reasons.
- First, message catalogs are all of I18N Wget uses anyway.
- Second, setting LC_ALL has a dangerous potential of messing
- things up. For example, when in a foreign locale, Solaris
- strptime() fails to handle international dates correctly, which
- makes http_atotm() malfunction. */
-#ifdef LC_MESSAGES
+ /* Where possible, sets only LC_MESSAGES and LC_CTYPE. Other
+ categories, such as numeric, time, or collation, break code that
+ parses data received from the network and relies on C-locale
+ behavior of libc functions. For example, Solaris strptime fails
+ to recognize English month names in non-English locales, which
+ breaks http_atotm. Some implementations of fnmatch perform
+ unwanted case folding in non-C locales. ctype macros, while they
+ were used, provided another example against LC_ALL. */
+#if defined(LC_MESSAGES) && defined(LC_CTYPE)
setlocale (LC_MESSAGES, "");
- setlocale (LC_CTYPE, "");
+ setlocale (LC_CTYPE, ""); /* safe because we use safe-ctype */
#else
setlocale (LC_ALL, "");
#endif
\f
/* Definition of command-line options. */
-static void print_help PARAMS ((void));
-static void print_version PARAMS ((void));
+static void print_help (void);
+static void print_version (void);
#ifdef HAVE_SSL
# define IF_SSL(x) x
OPT__DONT_REMOVE_LISTING,
OPT__EXECUTE,
OPT__NO,
- OPT__PARENT,
+ OPT__PARENT
} type;
const void *data; /* for standard options */
int argtype; /* for non-standard options */
N_("\
HTTPS (SSL/TLS) options:\n"),
N_("\
- --secure-protocol=PR choose SSL protocol, one of auto, SSLv2, SSLv3,\n\
- and TLSv1.\n"),
+ --secure-protocol=PR choose secure protocol, one of auto, SSLv2,\n\
+ SSLv3, and TLSv1.\n"),
N_("\
--no-check-certificate don't validate the server's certificate.\n"),
N_("\
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:
{
- void (*func) PARAMS ((void)) = (void (*) PARAMS ((void))) opt->data;
+ void (*func) (void) = (void (*) (void)) opt->data;
func ();
}
break;
case OPT__APPEND_OUTPUT:
- setoptval ("logfile", optarg);
+ setoptval ("logfile", optarg, opt->long_name);
append_to_log = 1;
break;
case OPT__EXECUTE:
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);
|| (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;
}