about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog21
-rwxr-xr-xdebug/catchsegv.sh8
-rw-r--r--time/strftime.c28
3 files changed, 36 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index fb356736bd..c0a3218970 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,13 +1,30 @@
+1998-09-24  Ulrich Drepper  <drepper@cygnus.com>
+
+	* debug/catchsegv.sh: Also produce output if cloned process died.
+
+1998-09-24  Paul Eggert  <eggert@twinsun.com>
+
+	* strftime.c (f_wkday): Remove duplicate definition.
+	(f_wkday, f_month, a_wkday, a_month, ampm): Define as macros when
+	!defined _NL_CURRENT && !HAVE_STRFTIME; this propagates the
+	1998-09-11 fix to this case.
+	(wkday_len, month_len): Remove these macros; they're no longer needed.
+
+1998-09-24  Paul Eggert  <eggert@twinsun.com>
+
+	* strftime.c (my_strftime): Don't store past the end of a
+	zero-sized buffer.
+
 1998-09-24  Paul Eggert  <eggert@twinsun.com>
 
-	* strftime.c (underlying_strftime):
+	* time/strftime.c (underlying_strftime):
 	Set the buffer to a nonzero value before calling
 	strftime, and check to see whether strftime has set the buffer to zero.
 	This lets us distinguish between an empty buffer and an error.
 
 1998-09-24  Paul Eggert  <eggert@shade.twinsun.com>
 
-	* strftime.c (INT_STRLEN_BOUND): Fix typo by changing 100 to 1000.
+	* time/strftime.c (INT_STRLEN_BOUND): Fix typo by changing 100 to 1000.
 	This fix is propagated from tzcode1998g.tar.gz.
 
 1998-09-24  Mark Kettenis  <kettenis@phys.uva.nl>
diff --git a/debug/catchsegv.sh b/debug/catchsegv.sh
index 6ca404da08..3af6570b10 100755
--- a/debug/catchsegv.sh
+++ b/debug/catchsegv.sh
@@ -51,6 +51,8 @@ Written by Ulrich Drepper.'
 fi
 
 segv_output=`basename "$prog"`.segv.$$
+# Make sure this output file does not exist.
+rm -f "$segv_output"
 
 # Redirect stderr to avoid termination message from shell.
 (exec 3>&2 2>/dev/null
@@ -60,8 +62,10 @@ SEGFAULT_OUTPUT_NAME=$segv_output \
 "$prog" ${1+"$@"} 2>&3 3>&-)
 exval=$?
 
-# Check for signal termination.
-if test $exval -gt 128 && test -f "$segv_output"; then
+# Check for output.  Even if the program terminated correctly it might
+# be that a inor process (clone) failed.  Therefore we do not check the
+# exit code.
+if test -f "$segv_output"; then
   # The program caught a signal.  The output is in the file with the
   # name we have in SEGFAULT_OUTPUT_NAME.  In the output the names of
   # functions in shared objects are available, but names in the static
diff --git a/time/strftime.c b/time/strftime.c
index 61f688e1b2..04d0e565df 100644
--- a/time/strftime.c
+++ b/time/strftime.c
@@ -416,15 +416,14 @@ my_strftime (s, maxsize, format, tp)
 {
   int hour12 = tp->tm_hour;
 #ifdef _NL_CURRENT
-  /* We cannot make the following values variables since we must dealy
+  /* We cannot make the following values variables since we must delay
      the evaluation of these values until really needed since some
      expressions might not be valid in every situation.  The `struct tm'
-     might be generated by a strptime() call and therefore initialized
+     might be generated by a strptime() call that initialized
      only a few elements.  Dereference the pointers only if the format
      requires this.  Then it is ok to fail if the pointers are invalid.  */
 # define a_wkday _NL_CURRENT (LC_TIME, ABDAY_1 + tp->tm_wday)
 # define f_wkday _NL_CURRENT (LC_TIME, DAY_1 + tp->tm_wday)
-# define f_wkday _NL_CURRENT (LC_TIME, DAY_1 + tp->tm_wday)
 # define a_month _NL_CURRENT (LC_TIME, ABMON_1 + tp->tm_mon)
 # define f_month _NL_CURRENT (LC_TIME, MON_1 + tp->tm_mon)
 # define ampm _NL_CURRENT (LC_TIME, tp->tm_hour > 11 ? PM_STR : AM_STR)
@@ -432,22 +431,17 @@ my_strftime (s, maxsize, format, tp)
 # define aw_len strlen (a_wkday)
 # define am_len strlen (a_month)
 # define ap_len strlen (ampm)
-
-# define wkday_len strlen (f_wkday)
-# define month_len strlen (f_month)
 #else
 # if !HAVE_STRFTIME
-  const char *const f_wkday = weekday_name[tp->tm_wday];
-  const char *const f_month = month_name[tp->tm_mon];
-  const char *const a_wkday = f_wkday;
-  const char *const a_month = f_month;
-  const char *const ampm = "AMPM" + 2 * (hour12 > 11);
+# define f_wkday (weekday_name[tp->tm_wday])
+# define f_month (month_name[tp->tm_mon])
+# define a_wkday f_wkday
+# define a_month f_month
+# define ampm ("AMPM" + 2 * (tp->tm_hour > 11))
+
   size_t aw_len = 3;
   size_t am_len = 3;
   size_t ap_len = 2;
-
-  size_t wkday_len = strlen (f_wkday);
-  size_t month_len = strlen (f_month);
 # endif
 #endif
   const char *zone;
@@ -669,7 +663,7 @@ my_strftime (s, maxsize, format, tp)
 	      to_lowcase = 0;
 	    }
 #if defined _NL_CURRENT || !HAVE_STRFTIME
-	  cpy (wkday_len, f_wkday);
+	  cpy (strlen (f_wkday), f_wkday);
 	  break;
 #else
 	  goto underlying_strftime;
@@ -695,7 +689,7 @@ my_strftime (s, maxsize, format, tp)
 	      to_lowcase = 0;
 	    }
 #if defined _NL_CURRENT || !HAVE_STRFTIME
-	  cpy (month_len, f_month);
+	  cpy (strlen (f_month), f_month);
 	  break;
 #else
 	  goto underlying_strftime;
@@ -1227,7 +1221,7 @@ my_strftime (s, maxsize, format, tp)
 	}
     }
 
-  if (p)
+  if (p && i < maxsize)
     *p = '\0';
   return i;
 }