This is the mail archive of the
libc-alpha@cygnus.com
mailing list for the glibc project.
glibc strftime.c patch to propagate recent fix to !HAVE_STRFTIME case
- To: libc-alpha@cygnus.com
- Subject: glibc strftime.c patch to propagate recent fix to !HAVE_STRFTIME case
- From: Paul Eggert <eggert@twinsun.com>
- Date: Thu, 24 Sep 1998 13:00:11 -0700 (PDT)
The 1998-09-11 fix to strftime.c applies to the case where _NL_CURRENT
is is defined. A similar fix is needed for the case when (!defined
_NL_CURRENT && !HAVE_STRFTIME).
Also, the 1998-09-11 fix has some minor spelling and grammar errors
in a comment, and a duplicate macro definition.
Here is a patch.
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.
--- strftime.c 1998/09/24 19:19:27 2.0.96.1
+++ strftime.c 1998/09/24 19:55:01 2.0.96.2
@@ -417,13 +417,12 @@ 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)
@@ -433,20 +432,15 @@ my_strftime (s, maxsize, format, tp)
# 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
@@ -670,5 +664,5 @@ my_strftime (s, maxsize, format, tp)
}
#if defined _NL_CURRENT || !HAVE_STRFTIME
- cpy (wkday_len, f_wkday);
+ cpy (strlen (f_wkday), f_wkday);
break;
#else
@@ -696,5 +690,5 @@ my_strftime (s, maxsize, format, tp)
}
#if defined _NL_CURRENT || !HAVE_STRFTIME
- cpy (month_len, f_month);
+ cpy (strlen (f_month), f_month);
break;
#else