#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 */
-#ifdef HAVE_SIGNAL_H
-# include <signal.h>
-#endif
+#include <string.h>
+#include <signal.h>
#ifdef HAVE_NLS
#ifdef HAVE_LOCALE_H
# include <locale.h>
#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 void 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_("\
break;
case OPT_FUNCALL:
{
- void (*func) PARAMS ((void)) = (void (*) PARAMS ((void))) opt->data;
+ void (*func) (void) = (void (*) (void)) opt->data;
func ();
}
break;
#ifdef HAVE_SIGNAL
/* Hangup signal handler. When wget receives SIGHUP or SIGUSR1, it
will proceed operation as usual, trying to write into a log file.
- If that is impossible, the output will be turned off.
-
- #### It is unsafe to do call libc functions from a signal handler.
- What we should do is, set a global variable, and have the code in
- log.c pick it up. */
+ If that is impossible, the output will be turned off. */
-static RETSIGTYPE
+static void
redirect_output_signal (int sig)
{
const char *signal_name = (sig == SIGHUP ? "SIGHUP" :