+2003-11-04 Hrvoje Niksic <hniksic@xemacs.org>
+
+ * configure.in: Check whether volatile is supported. Don't check
+ for gethostname and uname, which are not used.
+
2003-11-04 Hrvoje Niksic <hniksic@xemacs.org>
* configure.in: Move some checks into aclocal.m4. Check whether
AM_C_PROTOTYPES
dnl
-dnl Checks for typedefs, structures, and compiler characteristics.
+dnl Checks for basic compiler characteristics.
dnl
AC_C_CONST
AC_C_INLINE
-AC_TYPE_SIZE_T
-AC_TYPE_PID_T
+AC_C_VOLATILE
AC_C_BIGENDIAN
+dnl
+dnl Checks for headers
+dnl
+AC_CHECK_HEADERS(string.h stdarg.h unistd.h sys/time.h utime.h sys/utime.h)
+AC_CHECK_HEADERS(termios.h sys/ioctl.h sys/select.h sys/utsname.h)
+AC_CHECK_HEADERS(inttypes.h signal.h setjmp.h pwd.h)
+AC_HEADER_TIME
+
dnl
dnl Check integral type sizes.
dnl
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
-AC_CHECK_HEADERS(inttypes.h)
-AC_CHECK_TYPES(uint32_t)
dnl
-dnl Checks for headers
+dnl Checks for system-specific types.
dnl
-AC_CHECK_HEADERS(string.h stdarg.h unistd.h sys/time.h utime.h sys/utime.h pwd.h)
-AC_CHECK_HEADERS(termios.h sys/ioctl.h sys/select.h sys/utsname.h)
-AC_CHECK_HEADERS(signal.h setjmp.h)
-AC_HEADER_TIME
+AC_TYPE_SIZE_T
+AC_TYPE_PID_T
+AC_CHECK_TYPES(uint32_t)
+AC_CHECK_TYPES(sig_atomic_t, [], [], [
+#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_SIGNAL_H
+# include <signal.h>
+#endif
+])
dnl
dnl Return type of signal-handlers
AC_FUNC_MMAP
AC_CHECK_FUNCS(strdup strstr strcasecmp strncasecmp strpbrk memmove)
AC_CHECK_FUNCS(gettimeofday mktime strptime strerror snprintf vsnprintf)
-AC_CHECK_FUNCS(select sigblock sigsetjmp signal symlink access isatty)
-AC_CHECK_FUNCS(uname gethostname usleep)
+AC_CHECK_FUNCS(usleep select sigblock sigsetjmp signal symlink access isatty)
dnl
dnl Call Wget's local macros defined in aclocal.
2003-11-04 Hrvoje Niksic <hniksic@xemacs.org>
+ * progress.c (progress_handle_sigwinch): Don't call
+ determine_screen_width() from the signal handler. Instead, just
+ set a volatile variable.
+ (bar_create): Check whether SIGWINCH was received.
+ (bar_update): Ditto.
+
* sysdep.h: Define SYSTEM_FNMATCH only if HAVE_FNMATCH_H is true.
2003-11-03 Hrvoje Niksic <hniksic@xemacs.org>
/* Define to empty or __inline__ or __inline. */
#undef inline
+/* Define `volatile' to be empty if the compiler doesn't support it. */
+#undef volatile
+
/* Define to `unsigned' if <sys/types.h> doesn't define. */
#undef size_t
/* Define if you have struct utimbuf. */
#undef HAVE_STRUCT_UTIMBUF
-/* Define if you have the uname function. */
-#undef HAVE_UNAME
-
/* Define if you have a working version of mmap. */
#undef HAVE_MMAP
-/* Define if you have the gethostname function. */
-#undef HAVE_GETHOSTNAME
-
/* Define if you have the select function. */
#undef HAVE_SELECT
/* Define if you have uint32_t. */
#undef HAVE_UINT32_T
+/* Define if you have sig_atomic_t. */
+#undef HAVE_SIG_ATOMIC_T
+
/* Some autoconf-unrelated preprocessor magic that cannot be in
sysdep.h because it must be done before including the system
headers. */
create_image will overflow the buffer. */
#define MINIMUM_SCREEN_WIDTH 45
-static int screen_width = DEFAULT_SCREEN_WIDTH;
+/* The last known screen width. This can be updated by the code that
+ detects that SIGWINCH was received (but it's never updated from the
+ signal handler). */
+static int screen_width;
+
+/* A flag that, when set, means SIGWINCH was received. */
+static volatile sig_atomic_t received_sigwinch;
/* Size of the download speed history ring. */
#define DLSPEED_HISTORY_SIZE 20
bp->initial_length = initial;
bp->total_length = total;
+ /* Initialize screen_width if this hasn't been done or if it might
+ have changed, as indicated by receiving SIGWINCH. */
+ if (!screen_width || received_sigwinch)
+ {
+ screen_width = determine_screen_width ();
+ if (!screen_width)
+ screen_width = DEFAULT_SCREEN_WIDTH;
+ else if (screen_width < MINIMUM_SCREEN_WIDTH)
+ screen_width = MINIMUM_SCREEN_WIDTH;
+ received_sigwinch = 0;
+ }
+
/* - 1 because we don't want to use the last screen column. */
bp->width = screen_width - 1;
/* + 1 for the terminating zero. */
update_speed_ring (bp, howmuch, dltime);
- if (screen_width - 1 != bp->width)
+ /* If SIGWINCH (the window size change signal) been received,
+ determine the new screen size and update the screen. */
+ if (received_sigwinch)
{
- bp->width = screen_width - 1;
- bp->buffer = xrealloc (bp->buffer, bp->width + 1);
- force_screen_update = 1;
+ int old_width = screen_width;
+ screen_width = determine_screen_width ();
+ if (!screen_width)
+ screen_width = DEFAULT_SCREEN_WIDTH;
+ else if (screen_width < MINIMUM_SCREEN_WIDTH)
+ screen_width = MINIMUM_SCREEN_WIDTH;
+ if (screen_width != old_width)
+ {
+ bp->width = screen_width - 1;
+ bp->buffer = xrealloc (bp->buffer, bp->width + 1);
+ force_screen_update = 1;
+ }
+ received_sigwinch = 0;
}
if (dltime - bp->last_screen_update < 200 && !force_screen_update)
static void
bar_set_params (const char *params)
{
- int sw;
char *term = getenv ("TERM");
if (params
set_progress_implementation (FALLBACK_PROGRESS_IMPLEMENTATION);
return;
}
-
- sw = determine_screen_width ();
- if (sw && sw >= MINIMUM_SCREEN_WIDTH)
- screen_width = sw;
}
#ifdef SIGWINCH
RETSIGTYPE
progress_handle_sigwinch (int sig)
{
- int sw = determine_screen_width ();
- if (sw && sw >= MINIMUM_SCREEN_WIDTH)
- screen_width = sw;
+ received_sigwinch = 1;
signal (SIGWINCH, progress_handle_sigwinch);
}
#endif
int fnmatch ();
#endif
+/* 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.