summaryrefslogtreecommitdiff
path: root/lib/mktime.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1998-10-18 14:08:35 +0000
committerJim Meyering <jim@meyering.net>1998-10-18 14:08:35 +0000
commitc8503930321eaaedc7c72c094288d3b3121daa89 (patch)
tree4ae51536e76fa9dcb50f615a5dd221da54865a62 /lib/mktime.c
parent61ece919c69f84e27a63a653a79c96364eb59be0 (diff)
downloadcoreutils-c8503930321eaaedc7c72c094288d3b3121daa89.tar.xz
Don't invoke localtime_r or gmtime_r unless it's the GNU C
library's localtime_r and gmtime_r; there are too many buggy implementations of localtime_r and gmtime_r out there, and it's not worth keeping track of all the different bugs. * mktime.c (__EXTENSIONS__, HAVE_LOCALTIME_R): Remove. (my_mktime_localtime_r): Renamed from localtime_r; all uses changed. Base it on localtime unless _LIBC.
Diffstat (limited to 'lib/mktime.c')
-rw-r--r--lib/mktime.c37
1 files changed, 7 insertions, 30 deletions
diff --git a/lib/mktime.c b/lib/mktime.c
index 587aaf12c..b63fa0560 100644
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -1,4 +1,4 @@
-/* mktime: convert a `struct tm' to a time_t value zzzzzz
+/* mktime: convert a `struct tm' to a time_t value
Copyright (C) 1993-1997, 1998 Free Software Foundation, Inc.
Contributed by Paul Eggert (eggert@twinsun.com).
@@ -28,14 +28,8 @@
# include <config.h>
#endif
-/* Some systems need this in order to declare localtime_r properly. */
-#ifndef __EXTENSIONS__
-# define __EXTENSIONS__ 1
-#endif
-
#ifdef _LIBC
# define HAVE_LIMITS_H 1
-# define HAVE_LOCALTIME_R 1
# define STDC_HEADERS 1
#endif
@@ -49,11 +43,6 @@
#include <sys/types.h> /* Some systems define `time_t' here. */
#include <time.h>
-/* Provide a declaration of localtime_r on systems that lack it. */
-#if ! defined HAVE_DECL_LOCALTIME_R
-extern struct tm* localtime_r ();
-#endif
-
#if HAVE_LIMITS_H
# include <limits.h>
#endif
@@ -130,35 +119,23 @@ time_t __mktime_internal __P ((struct tm *,
#ifdef _LIBC
-# define localtime_r __localtime_r
+# define my_mktime_localtime_r __localtime_r
#else
-# if HAVE_LOCALTIME_R == defined localtime_r
-/* Provide our own substitute for a missing or possibly broken localtime_r. */
+/* If we're a mktime substitute in a GNU program, then prefer
+ localtime to localtime_r, since many localtime_r implementations
+ are buggy. */
static struct tm *my_mktime_localtime_r __P ((const time_t *, struct tm *));
static struct tm *
my_mktime_localtime_r (t, tp)
const time_t *t;
struct tm *tp;
{
-# ifdef localtime_r
- /* Digital Unix 4.0A and 4.0D have a macro localtime_r with the
- standard meaning, along with an unwanted, nonstandard function
- localtime_r. The placeholder function my_mktime_localtime_r
- invokes the macro; use that instead of the system's bogus
- localtime_r. */
- return localtime_r (t, tp);
-# undef localtime_r
-# else /* ! defined (localtime_r) */
- /* Approximate localtime_r as best we can in its absence. */
struct tm *l = localtime (t);
if (! l)
return 0;
*tp = *l;
return tp;
-# endif /* ! defined localtime_r */
}
-# define localtime_r my_mktime_localtime_r
-# endif /* HAVE_LOCALTIME_R == defined localtime_r */
#endif /* ! _LIBC */
@@ -213,7 +190,7 @@ mktime (tp)
__tzset ();
#endif
- return __mktime_internal (tp, localtime_r, &localtime_offset);
+ return __mktime_internal (tp, my_mktime_localtime_r, &localtime_offset);
}
/* Use CONVERT to convert *T to a broken down time in *TP.
@@ -559,6 +536,6 @@ main (argc, argv)
/*
Local Variables:
-compile-command: "gcc -DDEBUG -D__EXTENSIONS__ -DHAVE_LIMITS_H -DHAVE_LOCALTIME_R -DSTDC_HEADERS -Wall -W -O -g mktime.c -o mktime"
+compile-command: "gcc -DDEBUG -DHAVE_LIMITS_H -DSTDC_HEADERS -Wall -W -O -g mktime.c -o mktime"
End:
*/