mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Use #elif where appropriate to make chaining of #if ... #else ...
more readable.
This commit is contained in:
parent
0f65283528
commit
7d48e6d057
@ -1,3 +1,8 @@
|
|||||||
|
2005-06-20 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
|
* main.c, ptimer.c, sysdep.h, utils.c: Use #elif to simplify reading of
|
||||||
|
chained if-else-else-else-... statements.
|
||||||
|
|
||||||
2005-06-20 Hrvoje Niksic <hniksic@xemacs.org>
|
2005-06-20 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
* all: Return type of signal handlers is `void'. Include signal.h
|
* all: Return type of signal handlers is `void'. Include signal.h
|
||||||
|
@ -36,11 +36,9 @@ so, delete this exception statement from your version. */
|
|||||||
#endif /* HAVE_UNISTD_H */
|
#endif /* HAVE_UNISTD_H */
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#ifdef HAVE_NLS
|
#if defined(HAVE_NLS) && defined(HAVE_LOCALE_H)
|
||||||
#ifdef HAVE_LOCALE_H
|
|
||||||
# include <locale.h>
|
# include <locale.h>
|
||||||
#endif /* HAVE_LOCALE_H */
|
#endif
|
||||||
#endif /* HAVE_NLS */
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
@ -83,17 +83,13 @@ so, delete this exception statement from your version. */
|
|||||||
|
|
||||||
#if defined(WINDOWS) || defined(__CYGWIN__)
|
#if defined(WINDOWS) || defined(__CYGWIN__)
|
||||||
# define PTIMER_WINDOWS /* use Windows timers */
|
# define PTIMER_WINDOWS /* use Windows timers */
|
||||||
#else
|
#elif _POSIX_TIMERS - 0 > 0
|
||||||
# if _POSIX_TIMERS - 0 > 0
|
|
||||||
# define PTIMER_POSIX /* use POSIX timers (clock_gettime) */
|
# define PTIMER_POSIX /* use POSIX timers (clock_gettime) */
|
||||||
# else
|
#elif defined(HAVE_GETTIMEOFDAY)
|
||||||
# ifdef HAVE_GETTIMEOFDAY
|
|
||||||
# define PTIMER_GETTIMEOFDAY /* use gettimeofday */
|
# define PTIMER_GETTIMEOFDAY /* use gettimeofday */
|
||||||
#else
|
#else
|
||||||
# define PTIMER_TIME
|
# define PTIMER_TIME
|
||||||
#endif
|
#endif
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PTIMER_POSIX
|
#ifdef PTIMER_POSIX
|
||||||
/* Elapsed time measurement using POSIX timers: system time is held in
|
/* Elapsed time measurement using POSIX timers: system time is held in
|
||||||
|
10
src/sysdep.h
10
src/sysdep.h
@ -104,23 +104,19 @@ so, delete this exception statement from your version. */
|
|||||||
/* Long is large enough: use it. */
|
/* Long is large enough: use it. */
|
||||||
typedef long LARGE_INT;
|
typedef long LARGE_INT;
|
||||||
# define LARGE_INT_FMT "%ld"
|
# define LARGE_INT_FMT "%ld"
|
||||||
#else
|
#elif SIZEOF_LONG_LONG >= 8
|
||||||
# if SIZEOF_LONG_LONG >= 8
|
|
||||||
/* Long long is large enough: use it. */
|
/* Long long is large enough: use it. */
|
||||||
typedef long long LARGE_INT;
|
typedef long long LARGE_INT;
|
||||||
# define LARGE_INT_FMT "%lld"
|
# define LARGE_INT_FMT "%lld"
|
||||||
# else
|
#elif _MSC_VER
|
||||||
# if _MSC_VER
|
|
||||||
/* Use __int64 under Windows. */
|
/* Use __int64 under Windows. */
|
||||||
typedef __int64 LARGE_INT;
|
typedef __int64 LARGE_INT;
|
||||||
# define LARGE_INT_FMT "%I64"
|
# define LARGE_INT_FMT "%I64"
|
||||||
#else
|
#else
|
||||||
/* Large integer type unavailable; use `double' instead. */
|
/* Large integer type unavailable; fake it with `double'. */
|
||||||
typedef double LARGE_INT;
|
typedef double LARGE_INT;
|
||||||
# define LARGE_INT_FMT "%.0f"
|
# define LARGE_INT_FMT "%.0f"
|
||||||
#endif
|
#endif
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Under Windows we #define struct_stat to struct _stati64. */
|
/* Under Windows we #define struct_stat to struct _stati64. */
|
||||||
#ifndef struct_stat
|
#ifndef struct_stat
|
||||||
|
28
src/utils.c
28
src/utils.c
@ -1355,17 +1355,13 @@ numdigit (wgint number)
|
|||||||
it, so it's used only if nothing else works. */
|
it, so it's used only if nothing else works. */
|
||||||
#if SIZEOF_LONG >= SIZEOF_WGINT
|
#if SIZEOF_LONG >= SIZEOF_WGINT
|
||||||
# define SPRINTF_WGINT(buf, n) sprintf (buf, "%ld", (long) (n))
|
# define SPRINTF_WGINT(buf, n) sprintf (buf, "%ld", (long) (n))
|
||||||
#else
|
#elif SIZEOF_LONG_LONG >= SIZEOF_WGINT
|
||||||
# if SIZEOF_LONG_LONG >= SIZEOF_WGINT
|
|
||||||
# define SPRINTF_WGINT(buf, n) sprintf (buf, "%lld", (long long) (n))
|
# define SPRINTF_WGINT(buf, n) sprintf (buf, "%lld", (long long) (n))
|
||||||
# else
|
#elif defined(WINDOWS)
|
||||||
# ifdef WINDOWS
|
|
||||||
# define SPRINTF_WGINT(buf, n) sprintf (buf, "%I64", (__int64) (n))
|
# define SPRINTF_WGINT(buf, n) sprintf (buf, "%I64", (__int64) (n))
|
||||||
#else
|
#else
|
||||||
# define SPRINTF_WGINT(buf, n) sprintf (buf, "%j", (intmax_t) (n))
|
# define SPRINTF_WGINT(buf, n) sprintf (buf, "%j", (intmax_t) (n))
|
||||||
#endif
|
#endif
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Shorthand for casting to wgint. */
|
/* Shorthand for casting to wgint. */
|
||||||
#define W wgint
|
#define W wgint
|
||||||
@ -1541,16 +1537,14 @@ determine_screen_width (void)
|
|||||||
return 0; /* most likely ENOTTY */
|
return 0; /* most likely ENOTTY */
|
||||||
|
|
||||||
return wsz.ws_col;
|
return wsz.ws_col;
|
||||||
#else /* not TIOCGWINSZ */
|
#elif defined(WINDOWS)
|
||||||
# ifdef WINDOWS
|
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
if (!GetConsoleScreenBufferInfo (GetStdHandle (STD_ERROR_HANDLE), &csbi))
|
if (!GetConsoleScreenBufferInfo (GetStdHandle (STD_ERROR_HANDLE), &csbi))
|
||||||
return 0;
|
return 0;
|
||||||
return csbi.dwSize.X;
|
return csbi.dwSize.X;
|
||||||
# else /* neither WINDOWS nor TIOCGWINSZ */
|
#else /* neither TIOCGWINSZ nor WINDOWS */
|
||||||
return 0;
|
return 0;
|
||||||
#endif /* neither WINDOWS nor TIOCGWINSZ */
|
#endif /* neither TIOCGWINSZ nor WINDOWS */
|
||||||
#endif /* not TIOCGWINSZ */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a random number between 0 and MAX-1, inclusive.
|
/* Return a random number between 0 and MAX-1, inclusive.
|
||||||
@ -1795,8 +1789,7 @@ xsleep (double seconds)
|
|||||||
/* If nanosleep has been interrupted by a signal, adjust the
|
/* If nanosleep has been interrupted by a signal, adjust the
|
||||||
sleeping period and return to sleep. */
|
sleeping period and return to sleep. */
|
||||||
sleep = remaining;
|
sleep = remaining;
|
||||||
#else /* not HAVE_NANOSLEEP */
|
#elif defined(HAVE_USLEEP)
|
||||||
#ifdef HAVE_USLEEP
|
|
||||||
/* If usleep is available, use it in preference to select. */
|
/* If usleep is available, use it in preference to select. */
|
||||||
if (seconds >= 1)
|
if (seconds >= 1)
|
||||||
{
|
{
|
||||||
@ -1807,8 +1800,7 @@ xsleep (double seconds)
|
|||||||
seconds -= (long) seconds;
|
seconds -= (long) seconds;
|
||||||
}
|
}
|
||||||
usleep (seconds * 1000000);
|
usleep (seconds * 1000000);
|
||||||
#else /* not HAVE_USLEEP */
|
#elif defined(HAVE_SELECT)
|
||||||
#ifdef HAVE_SELECT
|
|
||||||
/* Note that, although Windows supports select, this sleeping
|
/* Note that, although Windows supports select, this sleeping
|
||||||
strategy doesn't work there because Winsock's select doesn't
|
strategy doesn't work there because Winsock's select doesn't
|
||||||
implement timeout when it is passed NULL pointers for all fd
|
implement timeout when it is passed NULL pointers for all fd
|
||||||
@ -1822,11 +1814,9 @@ 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 /* not HAVE_SELECT */
|
#else /* none of the above */
|
||||||
sleep (seconds);
|
sleep (seconds);
|
||||||
#endif /* not HAVE_SELECT */
|
#endif
|
||||||
#endif /* not HAVE_USLEEP */
|
|
||||||
#endif /* not HAVE_NANOSLEEP */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* not WINDOWS */
|
#endif /* not WINDOWS */
|
||||||
|
Loading…
Reference in New Issue
Block a user