1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-07 06:43:00 +03:00
* time/strftime.c [emacs]: Define my_strftime to emacs_strftimeu.
	Define ut_argument, ut_argument_spec, and ut_argument_spec_iso to
	allow using `ut' parameter.
	[!emacs]: Define ut_argument, ut_argument_spec, and
	ut_argument_spec_iso as empty.  Define ut to 0.  Add ut_argument and
	argument_spec to prototypes and definitions.
	(my_strftime): Don't call tzset of ut != 0.
	Compute diff as 0 is ut != 0;
	[emacs]: Define new emacs_strftime function.
	Based on a patch by Paul Eggert.

1998-09-24  Paul Eggert  <eggert@twinsun.com>

	* time/strftime.c (my_strftime): When asking for the length of the
	subformatted buffer, do not limit the length to look for;
	otherwise, we have no reliable way to distinguish between the
	empty buffer and an error.

1998-09-25  Ulrich Drepper  <drepper@cygnus.com>

	* debug/catchsegv.sh: Also produce output if clone process died.
This commit is contained in:
Ulrich Drepper
1998-09-25 22:23:09 +00:00
parent 390a4882ff
commit e07a51b539
2 changed files with 97 additions and 38 deletions

View File

@@ -1,3 +1,23 @@
1998-09-25 Ulrich Drepper <drepper@cygnus.com>
* time/strftime.c [emacs]: Define my_strftime to emacs_strftimeu.
Define ut_argument, ut_argument_spec, and ut_argument_spec_iso to
allow using `ut' parameter.
[!emacs]: Define ut_argument, ut_argument_spec, and
ut_argument_spec_iso as empty. Define ut to 0. Add ut_argument and
argument_spec to prototypes and definitions.
(my_strftime): Don't call tzset of ut != 0.
Compute diff as 0 is ut != 0;
[emacs]: Define new emacs_strftime function.
Based on a patch by Paul Eggert.
1998-09-24 Paul Eggert <eggert@twinsun.com>
* time/strftime.c (my_strftime): When asking for the length of the
subformatted buffer, do not limit the length to look for;
otherwise, we have no reliable way to distinguish between the
empty buffer and an error.
1998-09-25 Ulrich Drepper <drepper@cygnus.com> 1998-09-25 Ulrich Drepper <drepper@cygnus.com>
* math/Makefile (gmp-objs): Add mp_clz_tab. * math/Makefile (gmp-objs): Add mp_clz_tab.
@@ -25,7 +45,7 @@
1998-09-24 Ulrich Drepper <drepper@cygnus.com> 1998-09-24 Ulrich Drepper <drepper@cygnus.com>
* debug/catchsegv.sh: Also produce output if cloned process died. * debug/catchsegv.sh: Also produce output if clone process died.
1998-09-24 Paul Eggert <eggert@twinsun.com> 1998-09-24 Paul Eggert <eggert@twinsun.com>

View File

@@ -374,26 +374,35 @@ static char const month_name[][10] =
#ifdef emacs #ifdef emacs
# define my_strftime emacs_strftime # define my_strftime emacs_strftimeu
# define ut_argument , ut
# define ut_argument_spec int ut;
# define ut_argument_spec_iso , int ut
#else #else
# define my_strftime strftime # define my_strftime strftime
# define ut_argument
# define ut_argument_spec
# define ut_argument_spec_iso
/* We don't have this information in general. */
# define ut 0
#endif #endif
#if !defined _LIBC && HAVE_TZNAME && HAVE_TZSET #if !defined _LIBC && HAVE_TZNAME && HAVE_TZSET
/* Solaris 2.5 tzset sometimes modifies the storage returned by localtime. /* Solaris 2.5 tzset sometimes modifies the storage returned by localtime.
Work around this bug by copying *tp before it might be munged. */ Work around this bug by copying *tp before it might be munged. */
size_t _strftime_copytm __P ((char *, size_t, const char *, size_t _strftime_copytm __P ((char *, size_t, const char *,
const struct tm *)); const struct tm * ut_argument_spec_iso));
size_t size_t
my_strftime (s, maxsize, format, tp) my_strftime (s, maxsize, format, tp ut_argument)
char *s; char *s;
size_t maxsize; size_t maxsize;
const char *format; const char *format;
const struct tm *tp; const struct tm *tp;
ut_argument_spec
{ {
struct tm tmcopy; struct tm tmcopy;
tmcopy = *tp; tmcopy = *tp;
return _strftime_copytm (s, maxsize, format, &tmcopy); return _strftime_copytm (s, maxsize, format, &tmcopy ut_argument);
} }
# undef my_strftime # undef my_strftime
# define my_strftime(S, Maxsize, Format, Tp) \ # define my_strftime(S, Maxsize, Format, Tp) \
@@ -408,11 +417,12 @@ static char const month_name[][10] =
anywhere, so to determine how many characters would be anywhere, so to determine how many characters would be
written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */ written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */
size_t size_t
my_strftime (s, maxsize, format, tp) my_strftime (s, maxsize, format, tp ut_argument)
char *s; char *s;
size_t maxsize; size_t maxsize;
const char *format; const char *format;
const struct tm *tp; const struct tm *tp;
ut_argument_spec
{ {
int hour12 = tp->tm_hour; int hour12 = tp->tm_hour;
#ifdef _NL_CURRENT #ifdef _NL_CURRENT
@@ -459,11 +469,21 @@ my_strftime (s, maxsize, format, tp)
POSIX does not require it. Do the right thing instead. */ POSIX does not require it. Do the right thing instead. */
zone = (const char *) tp->tm_zone; zone = (const char *) tp->tm_zone;
#endif #endif
#if HAVE_TZNAME && HAVE_TZSET #if HAVE_TZNAME
/* POSIX.1 8.1.1 requires that whenever strftime() is called, the if (ut)
time zone names contained in the external variable `tzname' shall {
be set as if the tzset() function had been called. */ if (! (zone && *zone))
tzset (); zone = "GMT";
}
else
{
/* POSIX.1 8.1.1 requires that whenever strftime() is called, the
time zone names contained in the external variable `tzname' shall
be set as if the tzset() function had been called. */
# if HAVE_TZSET
tzset ();
# endif
}
#endif #endif
if (hour12 > 12) if (hour12 > 12)
@@ -713,9 +733,7 @@ my_strftime (s, maxsize, format, tp)
subformat: subformat:
{ {
char *old_start = p; char *old_start = p;
size_t len = my_strftime (NULL, maxsize - i, subfmt, tp); size_t len = my_strftime (NULL, (size_t) -1, subfmt, tp);
if (len == 0 && *subfmt)
return 0;
add (len, my_strftime (p, maxsize - i, subfmt, tp)); add (len, my_strftime (p, maxsize - i, subfmt, tp));
if (to_uppcase) if (to_uppcase)
@@ -1161,34 +1179,39 @@ my_strftime (s, maxsize, format, tp)
#if HAVE_TM_GMTOFF #if HAVE_TM_GMTOFF
diff = tp->tm_gmtoff; diff = tp->tm_gmtoff;
#else #else
struct tm gtm; if (ut)
struct tm ltm; diff = 0;
time_t lt; else
ltm = *tp;
lt = mktime (&ltm);
if (lt == (time_t) -1)
{ {
/* mktime returns -1 for errors, but -1 is also a struct tm gtm;
valid time_t value. Check whether an error really struct tm ltm;
occurred. */ time_t lt;
struct tm tm;
if (! localtime_r (&lt, &tm) ltm = *tp;
|| ((ltm.tm_sec ^ tm.tm_sec) lt = mktime (&ltm);
| (ltm.tm_min ^ tm.tm_min)
| (ltm.tm_hour ^ tm.tm_hour) if (lt == (time_t) -1)
| (ltm.tm_mday ^ tm.tm_mday) {
| (ltm.tm_mon ^ tm.tm_mon) /* mktime returns -1 for errors, but -1 is also a
| (ltm.tm_year ^ tm.tm_year))) valid time_t value. Check whether an error really
occurred. */
struct tm tm;
if (! localtime_r (&lt, &tm)
|| ((ltm.tm_sec ^ tm.tm_sec)
| (ltm.tm_min ^ tm.tm_min)
| (ltm.tm_hour ^ tm.tm_hour)
| (ltm.tm_mday ^ tm.tm_mday)
| (ltm.tm_mon ^ tm.tm_mon)
| (ltm.tm_year ^ tm.tm_year)))
break;
}
if (! gmtime_r (&lt, &gtm))
break; break;
diff = tm_diff (&ltm, &gtm);
} }
if (! gmtime_r (&lt, &gtm))
break;
diff = tm_diff (&ltm, &gtm);
#endif #endif
if (diff < 0) if (diff < 0)
@@ -1225,3 +1248,19 @@ my_strftime (s, maxsize, format, tp)
*p = '\0'; *p = '\0';
return i; return i;
} }
#ifdef emacs
/* For Emacs we have a separate interface which corresponds to the normal
strftime function and does not have the extra information whether the
TP arguments comes from a `gmtime' call or not. */
size_t
emacs_strftime (s, maxsize, format, tp)
char *s;
size_t maxsize;
const char *format;
const struct tm *tp;
{
return my_strftime (s, maxsize, format, tp, 0);
}
#endif