git issue #838 - old time manipulation for BSD
Issue #838 from clausecker, relayed by copperwater: old workarounds for lack of type 'time_t' from pre-standard days aren't suitable any more. One of the instances was incorrect (diagnosed by entrez) and no one had noticed for years (or possibly just ignored a compiler warning). Remove most of the old cruft from hacklib.c and some from system.h but put in commented workarounds in unixconf.h in case someone needs to resurrect it. It would have been better to do things this way back in the old days. Resurrecting some non-Unix port might need to clone the unixconf.h bits in its own *conf.h, but that probably won't be necessary for a standard C compliant system. Closes #838
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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 <time.h> */
|
||||
#ifdef NEED_CTIME_DECL
|
||||
E char *ctime(const time_t *);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -296,6 +296,16 @@
|
||||
#include <time.h>
|
||||
#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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user