mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Expect existence of C89 functions, as well as of select and gettimeofday.
This commit is contained in:
parent
63dcf343f1
commit
b317cb1c6d
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
2005-06-22 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
|
* configure.in: Assume existence of gettimeofday and select.
|
||||||
|
gettimeofday exists on all platforms we care about (except for
|
||||||
|
Windows where Windows-specific functions are used instead), and
|
||||||
|
select exists virtually everywhere.
|
||||||
|
|
||||||
|
* configure.in: Assume existence of strerror, signal, strstr, and
|
||||||
|
memmove, which are all required by ANSI C.
|
||||||
|
|
||||||
2005-06-21 Hrvoje Niksic <hniksic@xemacs.org>
|
2005-06-21 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
* Makefile.cvs: Renamed to Makefile.svn.
|
* Makefile.cvs: Renamed to Makefile.svn.
|
||||||
|
@ -208,10 +208,10 @@ dnl
|
|||||||
AC_FUNC_ALLOCA
|
AC_FUNC_ALLOCA
|
||||||
AC_FUNC_MMAP
|
AC_FUNC_MMAP
|
||||||
AC_FUNC_FSEEKO
|
AC_FUNC_FSEEKO
|
||||||
AC_CHECK_FUNCS(strdup strstr strcasecmp strncasecmp strpbrk memmove)
|
AC_CHECK_FUNCS(strdup strcasecmp strncasecmp strpbrk)
|
||||||
AC_CHECK_FUNCS(gettimeofday mktime strptime strerror snprintf vsnprintf)
|
AC_CHECK_FUNCS(mktime strptime snprintf vsnprintf)
|
||||||
AC_CHECK_FUNCS(usleep select ftello sigblock sigsetjmp signal)
|
AC_CHECK_FUNCS(usleep ftello sigblock sigsetjmp)
|
||||||
AC_CHECK_FUNCS(symlink access isatty)
|
AC_CHECK_FUNCS(symlink isatty)
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl Call Wget's local macros defined in aclocal.
|
dnl Call Wget's local macros defined in aclocal.
|
||||||
|
@ -1,3 +1,18 @@
|
|||||||
|
2005-06-22 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
|
* connect.c (select_fd): Expect select() to exist.
|
||||||
|
|
||||||
|
* utils.c (xsleep): Always use select() as sleep fallback on
|
||||||
|
non-Windows platforms.
|
||||||
|
|
||||||
|
* ptimer.c: Delete the implementation of PTIMER_TIME.
|
||||||
|
|
||||||
|
* main.c: Assume existence of signal(), test for different signal
|
||||||
|
names instead.
|
||||||
|
|
||||||
|
* cmpt.c: Better document reasons why certain functions are
|
||||||
|
included.
|
||||||
|
|
||||||
2005-06-22 Hrvoje Niksic <hniksic@xemacs.org>
|
2005-06-22 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
* Makefile.in: Remove the manually maintained dependency list;
|
* Makefile.in: Remove the manually maintained dependency list;
|
||||||
|
44
src/cmpt.c
44
src/cmpt.c
@ -41,8 +41,19 @@ so, delete this exception statement from your version. */
|
|||||||
|
|
||||||
#include "wget.h"
|
#include "wget.h"
|
||||||
|
|
||||||
/* Some systems don't have some str* functions in libc. Here we
|
/* Some systems lack certain functions normally taken for granted.
|
||||||
define them. The same goes for strptime. */
|
For example, Windows doesn't have strptime, and some systems lack
|
||||||
|
strcasecmp and strncasecmp. This file should contain fallback
|
||||||
|
implementations of the missing functions. It should *not* define
|
||||||
|
new Wget-specific functions -- those should placed in utils.c or
|
||||||
|
elsewhere. */
|
||||||
|
|
||||||
|
/* strcasecmp and strncasecmp apparently originated with BSD 4.4.
|
||||||
|
SUSv3 seems to be the only standard out there (that I can find)
|
||||||
|
that requires their existence, so there are systems that lack them
|
||||||
|
still in use. Note that these don't get defined under Windows
|
||||||
|
because mswindows.h defines them to the equivalent Windows
|
||||||
|
functions stricmp and strnicmp. */
|
||||||
|
|
||||||
#ifndef HAVE_STRCASECMP
|
#ifndef HAVE_STRCASECMP
|
||||||
/* From GNU libc. */
|
/* From GNU libc. */
|
||||||
@ -99,6 +110,9 @@ strncasecmp (const char *s1, const char *s2, size_t n)
|
|||||||
return c1 - c2;
|
return c1 - c2;
|
||||||
}
|
}
|
||||||
#endif /* not HAVE_STRNCASECMP */
|
#endif /* not HAVE_STRNCASECMP */
|
||||||
|
|
||||||
|
/* strpbrk is required by POSIX and C99, but it is missing from some
|
||||||
|
older systems and from Windows. */
|
||||||
|
|
||||||
#ifndef HAVE_STRPBRK
|
#ifndef HAVE_STRPBRK
|
||||||
/* Find the first ocurrence in S of any character in ACCEPT. */
|
/* Find the first ocurrence in S of any character in ACCEPT. */
|
||||||
@ -117,6 +131,10 @@ strpbrk (const char *s, const char *accept)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_STRPBRK */
|
#endif /* HAVE_STRPBRK */
|
||||||
|
|
||||||
|
/* mktime is a BSD 4.3 function also required by POSIX and C99. I
|
||||||
|
don't know if there is a widely used system that lacks it, so it
|
||||||
|
might be a candidate for removal. */
|
||||||
|
|
||||||
#ifndef HAVE_MKTIME
|
#ifndef HAVE_MKTIME
|
||||||
/* From GNU libc 2.0. */
|
/* From GNU libc 2.0. */
|
||||||
@ -390,7 +408,10 @@ __mktime_internal (tp, convert, offset)
|
|||||||
weak_alias (mktime, timelocal)
|
weak_alias (mktime, timelocal)
|
||||||
#endif
|
#endif
|
||||||
#endif /* not HAVE_MKTIME */
|
#endif /* not HAVE_MKTIME */
|
||||||
|
|
||||||
|
/* strptime is required by POSIX, but it is missing from Windows,
|
||||||
|
which means we must keep a fallback implementation. It is
|
||||||
|
reportedly missing or broken on many older systems as well. */
|
||||||
|
|
||||||
#ifndef HAVE_STRPTIME
|
#ifndef HAVE_STRPTIME
|
||||||
/* From GNU libc 2.1.3. */
|
/* From GNU libc 2.1.3. */
|
||||||
@ -1314,14 +1335,17 @@ const unsigned short int __mon_yday[2][13] =
|
|||||||
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
|
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* fnmatch is required by POSIX, but we include an implementation for
|
||||||
|
the sake of systems that don't have it, most notably Windows. Some
|
||||||
|
systems do have fnmatch, but Apache's installation process installs
|
||||||
|
its own fnmatch.h (incompatible with the system one!) in a system
|
||||||
|
include directory, effectively rendering fnmatch unusable. This
|
||||||
|
has been fixed with Apache 2, where fnmatch has been moved to apr
|
||||||
|
and given a prefix, but many systems out there are still (as of
|
||||||
|
this writing in 2005) broken and we must cater to them.
|
||||||
|
|
||||||
/* fnmatch is defined by POSIX, but we include an implementation for
|
Additionally, according to anecdotal evidence and conventional
|
||||||
the sake of systems that don't have it. Some systems do have
|
|
||||||
fnmatch, but Apache installs its own fnmatch.h (incompatible with
|
|
||||||
the system one) in a system include directory, effectively
|
|
||||||
rendering fnmatch unusable.
|
|
||||||
|
|
||||||
Additionally according to anecdotal evidence and conventional
|
|
||||||
wisdom I lack courage to challenge, many implementations of fnmatch
|
wisdom I lack courage to challenge, many implementations of fnmatch
|
||||||
are notoriously buggy and unreliable. So we use our version by
|
are notoriously buggy and unreliable. So we use our version by
|
||||||
default, except when compiling under systems where fnmatch is known
|
default, except when compiling under systems where fnmatch is known
|
||||||
|
@ -611,7 +611,6 @@ retryable_socket_connect_error (int err)
|
|||||||
int
|
int
|
||||||
select_fd (int fd, double maxtime, int wait_for)
|
select_fd (int fd, double maxtime, int wait_for)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SELECT
|
|
||||||
fd_set fdset;
|
fd_set fdset;
|
||||||
fd_set *rd = NULL, *wr = NULL;
|
fd_set *rd = NULL, *wr = NULL;
|
||||||
struct timeval tmout;
|
struct timeval tmout;
|
||||||
@ -632,23 +631,11 @@ select_fd (int fd, double maxtime, int wait_for)
|
|||||||
while (result < 0 && errno == EINTR);
|
while (result < 0 && errno == EINTR);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
#else /* not HAVE_SELECT */
|
|
||||||
|
|
||||||
/* If select() unavailable, just return 1. In most usages in Wget,
|
|
||||||
this is the appropriate response -- "if we can't poll, go ahead
|
|
||||||
with the blocking operation". If a specific part of code needs
|
|
||||||
different behavior, it can use #ifdef HAVE_SELECT to test whether
|
|
||||||
polling really occurs. */
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
#endif /* not HAVE_SELECT */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
test_socket_open (int sock)
|
test_socket_open (int sock)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SELECT
|
|
||||||
fd_set check_set;
|
fd_set check_set;
|
||||||
struct timeval to;
|
struct timeval to;
|
||||||
|
|
||||||
@ -670,10 +657,6 @@ test_socket_open (int sock)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
|
||||||
/* Without select, it's hard to know for sure. */
|
|
||||||
return 1;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Basic socket operations, mostly EINTR wrappers. */
|
/* Basic socket operations, mostly EINTR wrappers. */
|
||||||
|
12
src/main.c
12
src/main.c
@ -900,21 +900,25 @@ Can't timestamp and not clobber old files at the same time.\n"));
|
|||||||
ws_startup ();
|
ws_startup ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SIGHUP
|
||||||
/* Setup the signal handler to redirect output when hangup is
|
/* Setup the signal handler to redirect output when hangup is
|
||||||
received. */
|
received. */
|
||||||
#ifdef HAVE_SIGNAL
|
|
||||||
if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
|
if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
|
||||||
signal(SIGHUP, redirect_output_signal);
|
signal(SIGHUP, redirect_output_signal);
|
||||||
|
#endif
|
||||||
/* ...and do the same for SIGUSR1. */
|
/* ...and do the same for SIGUSR1. */
|
||||||
|
#ifdef SIGUSR1
|
||||||
signal (SIGUSR1, redirect_output_signal);
|
signal (SIGUSR1, redirect_output_signal);
|
||||||
|
#endif
|
||||||
|
#ifdef SIGPIPE
|
||||||
/* Writing to a closed socket normally signals SIGPIPE, and the
|
/* Writing to a closed socket normally signals SIGPIPE, and the
|
||||||
process exits. What we want is to ignore SIGPIPE and just check
|
process exits. What we want is to ignore SIGPIPE and just check
|
||||||
for the return value of write(). */
|
for the return value of write(). */
|
||||||
signal (SIGPIPE, SIG_IGN);
|
signal (SIGPIPE, SIG_IGN);
|
||||||
|
#endif
|
||||||
#ifdef SIGWINCH
|
#ifdef SIGWINCH
|
||||||
signal (SIGWINCH, progress_handle_sigwinch);
|
signal (SIGWINCH, progress_handle_sigwinch);
|
||||||
#endif
|
#endif
|
||||||
#endif /* HAVE_SIGNAL */
|
|
||||||
|
|
||||||
status = RETROK; /* initialize it, just-in-case */
|
status = RETROK; /* initialize it, just-in-case */
|
||||||
/* Retrieve the URLs from argument list. */
|
/* Retrieve the URLs from argument list. */
|
||||||
@ -986,7 +990,7 @@ Can't timestamp and not clobber old files at the same time.\n"));
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SIGNAL
|
#if defined(SIGHUP) || defined(SIGUSR1)
|
||||||
/* Hangup signal handler. When wget receives SIGHUP or SIGUSR1, it
|
/* Hangup signal handler. When wget receives SIGHUP or SIGUSR1, it
|
||||||
will proceed operation as usual, trying to write into a log file.
|
will proceed operation as usual, trying to write into a log file.
|
||||||
If that is impossible, the output will be turned off. */
|
If that is impossible, the output will be turned off. */
|
||||||
@ -1001,4 +1005,4 @@ redirect_output_signal (int sig)
|
|||||||
progress_schedule_redirect ();
|
progress_schedule_redirect ();
|
||||||
signal (sig, redirect_output_signal);
|
signal (sig, redirect_output_signal);
|
||||||
}
|
}
|
||||||
#endif /* HAVE_SIGNAL */
|
#endif
|
||||||
|
43
src/ptimer.c
43
src/ptimer.c
@ -72,23 +72,19 @@ so, delete this exception statement from your version. */
|
|||||||
#include "wget.h"
|
#include "wget.h"
|
||||||
#include "ptimer.h"
|
#include "ptimer.h"
|
||||||
|
|
||||||
/* Depending on the OS and availability of gettimeofday(), one and
|
/* Depending on the OS, one and only one of PTIMER_POSIX,
|
||||||
only one of PTIMER_POSIX, PTIMER_GETTIMEOFDAY, PTIMER_WINDOWS, or
|
PTIMER_GETTIMEOFDAY, or PTIMER_WINDOWS will be defined. */
|
||||||
PTIMER_TIME will be defined. */
|
|
||||||
|
|
||||||
#undef PTIMER_POSIX
|
#undef PTIMER_POSIX
|
||||||
#undef PTIMER_GETTIMEOFDAY
|
#undef PTIMER_GETTIMEOFDAY
|
||||||
#undef PTIMER_TIME
|
|
||||||
#undef PTIMER_WINDOWS
|
#undef PTIMER_WINDOWS
|
||||||
|
|
||||||
#if defined(WINDOWS) || defined(__CYGWIN__)
|
#if defined(WINDOWS) || defined(__CYGWIN__)
|
||||||
# define PTIMER_WINDOWS /* use Windows timers */
|
# define PTIMER_WINDOWS /* use Windows timers */
|
||||||
#elif _POSIX_TIMERS - 0 > 0
|
#elif _POSIX_TIMERS - 0 > 0
|
||||||
# define PTIMER_POSIX /* use POSIX timers (clock_gettime) */
|
# define PTIMER_POSIX /* use POSIX timers (clock_gettime) */
|
||||||
#elif defined(HAVE_GETTIMEOFDAY)
|
|
||||||
# define PTIMER_GETTIMEOFDAY /* use gettimeofday */
|
|
||||||
#else
|
#else
|
||||||
# define PTIMER_TIME
|
# define PTIMER_GETTIMEOFDAY /* use gettimeofday */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PTIMER_POSIX
|
#ifdef PTIMER_POSIX
|
||||||
@ -225,39 +221,6 @@ gettimeofday_resolution (void)
|
|||||||
}
|
}
|
||||||
#endif /* PTIMER_GETTIMEOFDAY */
|
#endif /* PTIMER_GETTIMEOFDAY */
|
||||||
|
|
||||||
#ifdef PTIMER_TIME
|
|
||||||
/* Elapsed time measurement using the time(2) call: system time is
|
|
||||||
held in time_t, retrieved using time, and resolution is 1 second.
|
|
||||||
|
|
||||||
This method is a catch-all for non-Windows systems without
|
|
||||||
gettimeofday -- e.g. DOS or really old or non-standard Unix
|
|
||||||
systems. */
|
|
||||||
|
|
||||||
typedef time_t ptimer_system_time;
|
|
||||||
|
|
||||||
#define IMPL_measure time_measure
|
|
||||||
#define IMPL_diff time_diff
|
|
||||||
#define IMPL_resolution time_resolution
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
time_measure (ptimer_system_time *pst)
|
|
||||||
{
|
|
||||||
time (pst);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline double
|
|
||||||
time_diff (ptimer_system_time *pst1, ptimer_system_time *pst2)
|
|
||||||
{
|
|
||||||
return 1000.0 * (*pst1 - *pst2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline double
|
|
||||||
time_resolution (void)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif /* PTIMER_TIME */
|
|
||||||
|
|
||||||
#ifdef PTIMER_WINDOWS
|
#ifdef PTIMER_WINDOWS
|
||||||
/* Elapsed time measurement on Windows: where high-resolution timers
|
/* Elapsed time measurement on Windows: where high-resolution timers
|
||||||
are available, time is stored in a LARGE_INTEGER and retrieved
|
are available, time is stored in a LARGE_INTEGER and retrieved
|
||||||
|
19
src/utils.c
19
src/utils.c
@ -81,10 +81,8 @@ so, delete this exception statement from your version. */
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef USE_SIGNAL_TIMEOUT
|
#undef USE_SIGNAL_TIMEOUT
|
||||||
#ifdef HAVE_SIGNAL
|
#if defined(HAVE_SIGSETJMP) || defined(HAVE_SIGBLOCK)
|
||||||
# if defined(HAVE_SIGSETJMP) || defined(HAVE_SIGBLOCK)
|
# define USE_SIGNAL_TIMEOUT
|
||||||
# define USE_SIGNAL_TIMEOUT
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wget.h"
|
#include "wget.h"
|
||||||
@ -1800,12 +1798,11 @@ xsleep (double seconds)
|
|||||||
seconds -= (long) seconds;
|
seconds -= (long) seconds;
|
||||||
}
|
}
|
||||||
usleep (seconds * 1000000);
|
usleep (seconds * 1000000);
|
||||||
#elif defined(HAVE_SELECT)
|
#else /* fall back select */
|
||||||
/* Note that, although Windows supports select, this sleeping
|
/* Note that, although Windows supports select, it can't be used to
|
||||||
strategy doesn't work there because Winsock's select doesn't
|
implement sleeping because Winsock's select doesn't implement
|
||||||
implement timeout when it is passed NULL pointers for all fd
|
timeout when it is passed NULL pointers for all fd sets. (But it
|
||||||
sets. (But it does work under Cygwin, which implements its own
|
does under Cygwin, which implements Unix-compatible select.) */
|
||||||
select.) */
|
|
||||||
struct timeval sleep;
|
struct timeval sleep;
|
||||||
sleep.tv_sec = (long) seconds;
|
sleep.tv_sec = (long) seconds;
|
||||||
sleep.tv_usec = 1000000 * (seconds - (long) seconds);
|
sleep.tv_usec = 1000000 * (seconds - (long) seconds);
|
||||||
@ -1814,8 +1811,6 @@ xsleep (double seconds)
|
|||||||
interrupted by a signal. But without knowing how long we've
|
interrupted by a signal. But without knowing how long we've
|
||||||
actually slept, we can't return to sleep. Using gettimeofday to
|
actually slept, we can't return to sleep. Using gettimeofday to
|
||||||
track sleeps is slow and unreliable due to clock skew. */
|
track sleeps is slow and unreliable due to clock skew. */
|
||||||
#else /* none of the above */
|
|
||||||
sleep (seconds);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user