diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index b084e5a45..7a88b4446 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -2092,4 +2092,6 @@ add TT_NONE==0, renumber other u.utraptype values so that TT_BEARTRAP isn't 0 for Planes of Water and Air, save the air bubbles and clouds with the level rather than as game state; affects wizard mode ^V and #wizmakemap switch to a flags arg on newcham() in place of the pair of boolean args +replace some old 'time_t' hackery in system.h and hacklib.c with something + less obtrusive in unixconf.h diff --git a/include/system.h b/include/system.h index 98bdfdc27..4c126fb10 100644 --- a/include/system.h +++ b/include/system.h @@ -534,22 +534,13 @@ E genericptr_t realloc(genericptr_t, size_t); /* time functions */ -#ifndef LATTICE -#if !(defined(ULTRIX_PROTO) && defined(__GNUC__)) +#ifdef NEED_TIME_DECL +E time_t time(time_t *); +#endif +#ifdef NEED_LOCALTIME_DECL E struct tm *localtime(const time_t *); #endif -#endif - -#if defined(ULTRIX) || (defined(BSD) && defined(POSIX_TYPES)) \ - || defined(SYSV) || defined(MICRO) || defined(VMS) || defined(MAC) \ - || (defined(HPUX) && defined(_POSIX_SOURCE)) -E time_t time(time_t *); -#else -E long time(time_t *); -#endif /* ULTRIX */ - -#ifdef VMS -/* used in makedefs.c, but missing from gcc-vms's */ +#ifdef NEED_CTIME_DECL E char *ctime(const time_t *); #endif diff --git a/include/unixconf.h b/include/unixconf.h index 9a9b77de6..e3e1aee18 100644 --- a/include/unixconf.h +++ b/include/unixconf.h @@ -296,6 +296,16 @@ #include #endif +/* these might be needed for include/system.h; + default comes from system's time.h */ +/* #define NEED_TIME_DECL 1 */ +/* #define NEED_LOCALTIME_DECL 1 */ +/* #define NEED_CTIME_DECL 1 */ +/* these might be needed for src/hacklib.c; + default is 'time_t *' */ +/* #define TIME_type long * */ +/* #define LOCALTIME_type long * */ + #define HLOCK "perm" /* an empty file used for locking purposes */ #define tgetch getchar diff --git a/src/hacklib.c b/src/hacklib.c index 2e644b244..c5e6d9a21 100644 --- a/src/hacklib.c +++ b/src/hacklib.c @@ -910,24 +910,15 @@ fuzzymatch(const char *s1, const char *s2, const char *ignore_chars, * - determination of what files are "very old" */ -/* TIME_type: type of the argument to time(); we actually use &(time_t) */ -#if defined(BSD) && !defined(POSIX_TYPES) -#define TIME_type long * -#else +/* TIME_type: type of the argument to time(); we actually use &(time_t); + you might need to define either or both of these to 'long *' in *conf.h */ +#ifndef TIME_type #define TIME_type time_t * #endif -/* LOCALTIME_type: type of the argument to localtime() */ -#if (defined(ULTRIX) && !(defined(ULTRIX_PROTO) || defined(NHSTDC))) \ - || (defined(BSD) && !defined(POSIX_TYPES)) -#define LOCALTIME_type long * -#else +#ifndef LOCALTIME_type #define LOCALTIME_type time_t * #endif -#if defined(AMIGA) && !defined(AZTEC_C) && !defined(__SASC_60) \ - && !defined(_DCC) && !defined(__GNUC__) -extern struct tm *localtime(time_t *); -#endif static struct tm *getlt(void); /* Sets the seed for the random number generator */ @@ -1088,12 +1079,8 @@ yyyymmddhhmmss(time_t date) if (date == 0) lt = getlt(); else -#if (defined(ULTRIX) && !(defined(ULTRIX_PROTO) || defined(NHSTDC))) \ - || defined(BSD) - lt = localtime((long *) (&date)); -#else - lt = localtime(&date); -#endif + lt = localtime((LOCALTIME_type) &date); + /* just in case somebody's localtime supplies (year % 100) rather than the expected (year - 1900) */ if (lt->tm_year < 70)