mirror of
https://github.com/mirror/wget.git
synced 2025-01-27 04:40:41 +08:00
Replace home-grown portability code by gnulib modules
* bootstrap.conf: Add intprops, inttypes, limits-h, signal-h, stat, sys_types * src/ftp.c: Replace 'struct_stat' by 'struct stat' * src/hsts.c: Likewise * src/http.c: Likewise * src/main.c: Likewise * src/netrc.c: Likewise * src/retr.c: Likewise * src/url.c: Likewise * src/utils.c: Likewise * src/sysdep.h: Remove old portability code Further portability issues should be addressed by gnulib.
This commit is contained in:
parent
a384f5e2e9
commit
fd0f759597
@ -58,7 +58,10 @@ ioctl
|
||||
iconv
|
||||
iconv-h
|
||||
inet_ntop
|
||||
intprops
|
||||
inttypes
|
||||
langinfo
|
||||
limits-h
|
||||
link
|
||||
listen
|
||||
maintainer-makefile
|
||||
@ -85,11 +88,13 @@ regex
|
||||
select
|
||||
send
|
||||
setsockopt
|
||||
signal-h
|
||||
sigprocmask
|
||||
sigpipe
|
||||
snprintf
|
||||
socket
|
||||
spawn-pipe
|
||||
stat
|
||||
stdbool
|
||||
stdint
|
||||
strcase
|
||||
@ -99,6 +104,7 @@ strptime
|
||||
strtok_r
|
||||
strtoll
|
||||
symlink
|
||||
sys_types
|
||||
timegm
|
||||
tmpdir
|
||||
unlink
|
||||
|
@ -1826,7 +1826,7 @@ ftp_loop_internal (struct url *u, struct url *original_url, struct fileinfo *f,
|
||||
char *tms, *locf;
|
||||
const char *tmrate = NULL;
|
||||
uerr_t err;
|
||||
struct_stat st;
|
||||
struct stat st;
|
||||
|
||||
/* Declare WARC variables. */
|
||||
bool warc_enabled = (opt.warc_filename != NULL);
|
||||
@ -2249,7 +2249,7 @@ ftp_retrieve_list (struct url *u, struct url *original_url,
|
||||
dlthis = true;
|
||||
if (opt.timestamping && f->type == FT_PLAINFILE)
|
||||
{
|
||||
struct_stat st;
|
||||
struct stat st;
|
||||
/* If conversion of HTML files retrieved via FTP is ever implemented,
|
||||
we'll need to stat() <file>.orig here when -K has been specified.
|
||||
I'm not implementing it now since files on an FTP server are much
|
||||
@ -2312,7 +2312,7 @@ The sizes do not match (local %s) -- retrieving.\n\n"),
|
||||
_("Invalid name of the symlink, skipping.\n"));
|
||||
else
|
||||
{
|
||||
struct_stat st;
|
||||
struct stat st;
|
||||
/* Check whether we already have the correct
|
||||
symbolic link. */
|
||||
int rc = lstat (con->target, &st);
|
||||
@ -2740,7 +2740,7 @@ ftp_loop (struct url *u, struct url *original_url, char **local_file, int *dt,
|
||||
{
|
||||
if (!opt.output_document)
|
||||
{
|
||||
struct_stat st;
|
||||
struct stat st;
|
||||
wgint sz;
|
||||
if (stat (filename, &st) == 0)
|
||||
sz = st.st_size;
|
||||
|
@ -343,7 +343,7 @@ hsts_store_dump (hsts_store_t store, FILE *fp)
|
||||
static bool
|
||||
hsts_file_access_valid (const char *filename)
|
||||
{
|
||||
struct_stat st;
|
||||
struct stat st;
|
||||
|
||||
if (stat (filename, &st) == -1)
|
||||
return false;
|
||||
@ -510,7 +510,7 @@ hsts_store_open (const char *filename)
|
||||
{
|
||||
if (hsts_file_access_valid (filename))
|
||||
{
|
||||
struct_stat st;
|
||||
struct stat st;
|
||||
FILE *fp = fopen (filename, "r");
|
||||
|
||||
if (!fp || !hsts_read_database (store, fp, false))
|
||||
@ -549,7 +549,7 @@ out:
|
||||
void
|
||||
hsts_store_save (hsts_store_t store, const char *filename)
|
||||
{
|
||||
struct_stat st;
|
||||
struct stat st;
|
||||
FILE *fp = NULL;
|
||||
int fd = 0;
|
||||
|
||||
|
@ -2195,7 +2195,7 @@ set_file_timestamp (struct http_stat *hs)
|
||||
char *filename_plus_orig_suffix = alloca (filename_len + sizeof (ORIG_SFX));
|
||||
bool local_dot_orig_file_exists = false;
|
||||
char *local_filename = NULL;
|
||||
struct_stat st;
|
||||
struct stat st;
|
||||
|
||||
if (opt.backup_converted)
|
||||
/* If -K is specified, we'll act on the assumption that it was specified
|
||||
@ -3998,7 +3998,7 @@ http_loop (const struct url *u, struct url *original_url, char **newloc,
|
||||
uerr_t err, ret = TRYLIMEXC;
|
||||
time_t tmr = -1; /* remote time-stamp */
|
||||
struct http_stat hstat; /* HTTP status */
|
||||
struct_stat st;
|
||||
struct stat st;
|
||||
bool send_head_first = true;
|
||||
bool force_full_retrieve = false;
|
||||
|
||||
|
@ -1893,7 +1893,7 @@ for details.\n\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
struct_fstat st;
|
||||
struct stat st;
|
||||
|
||||
#ifdef __VMS
|
||||
/* Common fopen() optional arguments:
|
||||
|
@ -75,7 +75,7 @@ search_netrc (const char *host, const char **acc, const char **passwd,
|
||||
#ifdef __VMS
|
||||
|
||||
int err;
|
||||
struct_stat buf;
|
||||
struct stat buf;
|
||||
char *path = "SYS$LOGIN:.netrc";
|
||||
|
||||
netrc_list = NULL;
|
||||
@ -94,7 +94,7 @@ search_netrc (const char *host, const char **acc, const char **passwd,
|
||||
if (home)
|
||||
{
|
||||
int err;
|
||||
struct_stat buf;
|
||||
struct stat buf;
|
||||
char *path = (char *)alloca (strlen (home) + 1
|
||||
+ strlen (NETRC_FILE_NAME) + 1);
|
||||
sprintf (path, "%s/%s", home, NETRC_FILE_NAME);
|
||||
@ -439,7 +439,7 @@ free_netrc(acc_t *l)
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
struct_stat sb;
|
||||
struct stat sb;
|
||||
char *program_name, *file, *target;
|
||||
acc_t *head, *a;
|
||||
|
||||
|
@ -1250,7 +1250,7 @@ rotate_backups(const char *fname)
|
||||
int maxlen = strlen (fname) + sizeof (SEP) + numdigit (opt.backups) + AVSL;
|
||||
char *from = alloca (maxlen);
|
||||
char *to = alloca (maxlen);
|
||||
struct_stat sb;
|
||||
struct stat sb;
|
||||
int i;
|
||||
|
||||
if (stat (fname, &sb) == 0)
|
||||
|
137
src/sysdep.h
137
src/sysdep.h
@ -35,53 +35,11 @@ as that of the covered work. */
|
||||
#ifndef SYSDEP_H
|
||||
#define SYSDEP_H
|
||||
|
||||
/* Testing for __sun is not enough because it's also defined on SunOS. */
|
||||
#ifdef __sun
|
||||
# ifdef __SVR4
|
||||
# define solaris
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__INTERIX) && !defined(_ALL_SOURCE)
|
||||
# define _ALL_SOURCE
|
||||
#endif
|
||||
|
||||
/* The "namespace tweaks" below attempt to set a friendly "compilation
|
||||
environment" under popular operating systems. Default compilation
|
||||
environment often means that some functions that are "extensions"
|
||||
are not declared -- `strptime' is one example.
|
||||
|
||||
But non-default environments can expose bugs in the system header
|
||||
files, crippling compilation in _very_ non-obvious ways. Because
|
||||
of that, we define them only on well-tested architectures where we
|
||||
know they will work. */
|
||||
|
||||
#undef NAMESPACE_TWEAKS
|
||||
|
||||
#ifdef solaris
|
||||
# define NAMESPACE_TWEAKS
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(__GLIBC__)
|
||||
# define NAMESPACE_TWEAKS
|
||||
#endif
|
||||
|
||||
#ifdef NAMESPACE_TWEAKS
|
||||
|
||||
#endif /* NAMESPACE_TWEAKS */
|
||||
|
||||
|
||||
/* Alloca declaration, based on recommendation in the Autoconf manual.
|
||||
These have to be after the above namespace tweaks, but before any
|
||||
non-preprocessor code. */
|
||||
/* Provided by gnulib on systems that don't have it: */
|
||||
|
||||
#include <alloca.h>
|
||||
|
||||
/* Must include these, so we can test for the missing stat macros and
|
||||
define them as necessary. */
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
@ -95,98 +53,9 @@ as that of the covered work. */
|
||||
# include "mswindows.h"
|
||||
#endif
|
||||
|
||||
/* Provided by gnulib on systems that don't have it: */
|
||||
# include <stdbool.h>
|
||||
|
||||
#ifndef struct_stat
|
||||
# define struct_stat struct stat
|
||||
#endif
|
||||
#ifndef struct_fstat
|
||||
# define struct_fstat struct stat
|
||||
#endif
|
||||
|
||||
#include <intprops.h>
|
||||
|
||||
/* For CHAR_BIT, LONG_MAX, etc. */
|
||||
#include <stdbool.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
|
||||
/* These are defined in cmpt.c if missing, so we must declare
|
||||
them. */
|
||||
#ifndef HAVE_STRCASECMP
|
||||
int strcasecmp ();
|
||||
#endif
|
||||
#ifndef HAVE_STRNCASECMP
|
||||
int strncasecmp ();
|
||||
#endif
|
||||
#ifndef HAVE_STRPTIME
|
||||
char *strptime ();
|
||||
#endif
|
||||
#ifndef HAVE_TIMEGM
|
||||
# include <time.h>
|
||||
time_t timegm (struct tm *);
|
||||
#endif
|
||||
#ifndef HAVE_MEMRCHR
|
||||
void *memrchr (const void *, int, size_t);
|
||||
#endif
|
||||
|
||||
/* These are defined in snprintf.c. It would be nice to have an
|
||||
snprintf.h, though. */
|
||||
#ifndef HAVE_SNPRINTF
|
||||
int snprintf (char *str, size_t count, const char *fmt, ...);
|
||||
#endif
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
#include <stdarg.h>
|
||||
int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
|
||||
#endif
|
||||
|
||||
/* Enable system fnmatch only on systems where fnmatch.h is usable.
|
||||
If the fnmatch on your system is buggy, undef this symbol and a
|
||||
replacement implementation will be used instead. */
|
||||
#ifdef HAVE_WORKING_FNMATCH_H
|
||||
# define SYSTEM_FNMATCH
|
||||
#endif
|
||||
|
||||
#include <fnmatch.h>
|
||||
|
||||
/* Provide sig_atomic_t if the system doesn't. */
|
||||
#ifndef HAVE_SIG_ATOMIC_T
|
||||
typedef int sig_atomic_t;
|
||||
#endif
|
||||
|
||||
/* Provide uint32_t on the platforms that don't define it. Although
|
||||
most code should be agnostic about integer sizes, some code really
|
||||
does need a 32-bit integral type. Such code should use uint32_t.
|
||||
(The exception is gnu-md5.[ch], which uses its own detection for
|
||||
portability across platforms.) */
|
||||
|
||||
#ifndef HAVE_UINT32_T
|
||||
# if SIZEOF_INT == 4
|
||||
typedef unsigned int uint32_t;
|
||||
# else
|
||||
# if SIZEOF_LONG == 4
|
||||
typedef unsigned long uint32_t;
|
||||
# else
|
||||
# if SIZEOF_SHORT == 4
|
||||
typedef unsigned short uint32_t;
|
||||
# else
|
||||
#error "Cannot determine a 32-bit unsigned integer type"
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* If uintptr_t isn't defined, simply typedef it to unsigned long. */
|
||||
#ifndef HAVE_UINTPTR_T
|
||||
typedef unsigned long uintptr_t;
|
||||
#endif
|
||||
|
||||
/* If intptr_t isn't defined, simply typedef it to long. */
|
||||
#ifndef HAVE_INTPTR_T
|
||||
typedef long intptr_t;
|
||||
#endif
|
||||
#include "intprops.h"
|
||||
|
||||
#endif /* SYSDEP_H */
|
||||
|
@ -1242,7 +1242,7 @@ mkalldirs (const char *path)
|
||||
{
|
||||
const char *p;
|
||||
char *t;
|
||||
struct_stat st;
|
||||
struct stat st;
|
||||
int res;
|
||||
|
||||
p = path + strlen (path);
|
||||
|
10
src/utils.c
10
src/utils.c
@ -573,7 +573,7 @@ int
|
||||
remove_link (const char *file)
|
||||
{
|
||||
int err = 0;
|
||||
struct_stat st;
|
||||
struct stat st;
|
||||
|
||||
if (lstat (file, &st) == 0 && S_ISLNK (st.st_mode))
|
||||
{
|
||||
@ -599,7 +599,7 @@ file_exists_p (const char *filename)
|
||||
#ifdef HAVE_ACCESS
|
||||
return access (filename, F_OK) >= 0;
|
||||
#else
|
||||
struct_stat buf;
|
||||
struct stat buf;
|
||||
return stat (filename, &buf) >= 0;
|
||||
#endif
|
||||
}
|
||||
@ -609,7 +609,7 @@ file_exists_p (const char *filename)
|
||||
bool
|
||||
file_non_directory_p (const char *path)
|
||||
{
|
||||
struct_stat buf;
|
||||
struct stat buf;
|
||||
/* Use lstat() rather than stat() so that symbolic links pointing to
|
||||
directories can be identified correctly. */
|
||||
if (lstat (path, &buf) != 0)
|
||||
@ -636,7 +636,7 @@ file_size (const char *filename)
|
||||
fclose (fp);
|
||||
return size;
|
||||
#else
|
||||
struct_stat st;
|
||||
struct stat st;
|
||||
if (stat (filename, &st) < 0)
|
||||
return -1;
|
||||
return st.st_size;
|
||||
@ -1190,7 +1190,7 @@ wget_read_file (const char *file)
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
{
|
||||
struct_fstat buf;
|
||||
struct stat buf;
|
||||
if (fstat (fd, &buf) < 0)
|
||||
goto mmap_lose;
|
||||
fm->length = buf.st_size;
|
||||
|
Loading…
Reference in New Issue
Block a user