]> sjero.net Git - wget/commitdiff
[svn] Only set a flag in the SIGWINCH handler.
authorhniksic <devnull@localhost>
Tue, 4 Nov 2003 13:37:14 +0000 (05:37 -0800)
committerhniksic <devnull@localhost>
Tue, 4 Nov 2003 13:37:14 +0000 (05:37 -0800)
ChangeLog
configure.in
src/ChangeLog
src/config.h.in
src/progress.c
src/sysdep.h

index 29fe44efc6fab8f16ca893275494337c8f969972..4a470d3bf6ffe62afc052a834ba07e3d7a5a8aea 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+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
index be2f9ffe95424a6ec8892a799e91f565f507a72e..85234e8097e456c501e83b5bcb8f6c0813a45dea 100644 (file)
@@ -149,14 +149,21 @@ dnl
 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
@@ -164,16 +171,25 @@ AC_CHECK_SIZEOF(short)
 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
@@ -187,8 +203,7 @@ AC_FUNC_ALLOCA
 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.
index 4352716fa08fbd22d794b2cccf5c97f2282eee6f..59f0c8c4d16cf33b82111675d908c1c829aca68b 100644 (file)
@@ -1,5 +1,11 @@
 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>
index abfbb8d814ab575647292ca8faf3a1076fffb8c1..459904162bfabcb147952731298107188371caa3 100644 (file)
@@ -64,6 +64,9 @@ char *alloca ();
 /* 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
 
@@ -116,15 +119,9 @@ char *alloca ();
 /* 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
 
@@ -287,6 +284,9 @@ char *alloca ();
 /* 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.  */
index 99bdd5b616881d06078eeb5de6768e6cb6f945c3..8ae09c32689df0492222116eee374749080aebab 100644 (file)
@@ -408,7 +408,13 @@ dot_set_params (const char *params)
    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
@@ -484,6 +490,18 @@ bar_create (long initial, long total)
   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. */
@@ -517,11 +535,23 @@ bar_update (void *progress, long howmuch, double dltime)
 
   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)
@@ -844,7 +874,6 @@ display_image (char *buf)
 static void
 bar_set_params (const char *params)
 {
-  int sw;
   char *term = getenv ("TERM");
 
   if (params
@@ -877,19 +906,13 @@ bar_set_params (const char *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
index e58daf331e5776017ab8eed830f8a695aec68ff5..3275ad4c7a6f3d8482b7848aeb9f0ae5a4b46398 100644 (file)
@@ -252,6 +252,11 @@ void *memcpy ();
 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.