From 97b8d0a50b7f27f1d31740f52c214e1a6f226b0b Mon Sep 17 00:00:00 2001 From: Patric Mueller Date: Thu, 17 Jan 2019 11:48:58 +0100 Subject: [PATCH] Don't define Rand() if isaac64 is used --- include/ntconf.h | 16 +++++++--------- include/os2conf.h | 14 ++++++-------- include/pcconf.h | 14 ++++++-------- include/unixconf.h | 14 ++++++-------- include/vmsconf.h | 22 ++++++++++------------ include/wceconf.h | 14 ++++++-------- src/rumors.c | 6 +++--- 7 files changed, 44 insertions(+), 56 deletions(-) diff --git a/include/ntconf.h b/include/ntconf.h index f7e8ca9cd..4edc63c76 100644 --- a/include/ntconf.h +++ b/include/ntconf.h @@ -182,15 +182,13 @@ extern void FDECL(interject, (int)); #define USE_STDARG /* Use the high quality random number routines. */ -#ifdef USE_ISAAC64 -#define Rand() rn2(RAND_MAX) -#else -#define RANDOM -#ifdef RANDOM -#define Rand() random() -#else -#define Rand() rand() -#endif +#ifndef USE_ISAAC64 +# define RANDOM +# ifdef RANDOM +# define Rand() random() +# else +# define Rand() rand() +# endif #endif #include diff --git a/include/os2conf.h b/include/os2conf.h index cde929982..fd625512a 100644 --- a/include/os2conf.h +++ b/include/os2conf.h @@ -78,14 +78,12 @@ #include /* the high quality random number routines */ -#ifdef USE_ISAAC64 -#define Rand() rn2(RAND_MAX) -#else -#ifdef RANDOM -#define Rand() random() -#else -#define Rand() rand() -#endif +#ifndef USE_ISAAC64 +# ifdef RANDOM +# define Rand() random() +# else +# define Rand() rand() +# endif #endif /* file creation mask */ diff --git a/include/pcconf.h b/include/pcconf.h index 9b4928831..fb210b8ca 100644 --- a/include/pcconf.h +++ b/include/pcconf.h @@ -237,14 +237,12 @@ #endif /* the high quality random number routines */ -#ifdef USE_ISAAC64 -#define Rand() rn2(RAND_MAX) -#else -#ifdef RANDOM -#define Rand() random() -#else -#define Rand() rand() -#endif +#ifndef USE_ISAAC64 +# ifdef RANDOM +# define Rand() random() +# else +# define Rand() rand() +# endif #endif #ifndef TOS diff --git a/include/unixconf.h b/include/unixconf.h index c494d5307..c0c80ccda 100644 --- a/include/unixconf.h +++ b/include/unixconf.h @@ -348,15 +348,13 @@ /* Use the high quality random number routines. */ /* the high quality random number routines */ -#ifdef USE_ISAAC64 -#define Rand() rn2(RAND_MAX) -#else -#if defined(BSD) || defined(LINUX) || defined(ULTRIX) || defined(CYGWIN32) \ +#ifndef USE_ISAAC64 +# if defined(BSD) || defined(LINUX) || defined(ULTRIX) || defined(CYGWIN32) \ || defined(RANDOM) || defined(__APPLE__) -#define Rand() random() -#else -#define Rand() lrand48() -#endif +# define Rand() random() +# else +# define Rand() lrand48() +# endif #endif #ifdef TIMED_DELAY diff --git a/include/vmsconf.h b/include/vmsconf.h index 1c6ea27f9..95749bbd6 100644 --- a/include/vmsconf.h +++ b/include/vmsconf.h @@ -243,21 +243,19 @@ typedef __mode_t mode_t; #define rindex strrchr /* Use the high quality random number routines. */ -#ifdef USE_ISAAC64 -#define Rand() rn2(RAND_MAX) -#else -#if defined(RANDOM) -#define Rand() random() +#ifndef USE_ISAAC64 +# if defined(RANDOM) +# define Rand() random() /* VMS V7 adds these entry points to DECC$SHR; stick with the nethack-supplied code to avoid having to deal with version-specific conditionalized builds */ -#define random nh_random -#define srandom nh_srandom -#define initstate nh_initstate -#define setstate nh_setstate -#else -#define Rand() rand() -#endif +# define random nh_random +# define srandom nh_srandom +# define initstate nh_initstate +# define setstate nh_setstate +# else +# define Rand() rand() +# endif #endif #define SYS_RANDOM_SEED diff --git a/include/wceconf.h b/include/wceconf.h index bc6492ab9..dcc7b6f95 100644 --- a/include/wceconf.h +++ b/include/wceconf.h @@ -143,14 +143,12 @@ #define USE_STDARG /* Use the high quality random number routines. */ -#ifdef USE_ISAAC64 -#define Rand() rn2(RAND_MAX) -#else -#ifdef RANDOM -#define Rand() random() -#else -#define Rand() rand() -#endif +#ifndef USE_ISAAC64 +# ifdef RANDOM +# define Rand() random() +# else +# define Rand() rand() +# endif #endif #define FCMASK 0660 /* file creation mask */ diff --git a/src/rumors.c b/src/rumors.c index 033a0126c..5215c105f 100644 --- a/src/rumors.c +++ b/src/rumors.c @@ -125,12 +125,12 @@ boolean exclude_cookie; case 2: /*(might let a bogus input arg sneak thru)*/ case 1: beginning = (long) true_rumor_start; - tidbit = Rand() % true_rumor_size; + tidbit = rn2(true_rumor_size); break; case 0: /* once here, 0 => false rather than "either"*/ case -1: beginning = (long) false_rumor_start; - tidbit = Rand() % false_rumor_size; + tidbit = rn2(false_rumor_size); break; default: impossible("strange truth value for rumor"); @@ -305,7 +305,7 @@ char *buf; (void) dlb_fseek(fh, 0L, SEEK_END); endtxt = dlb_ftell(fh); sizetxt = endtxt - starttxt; - tidbit = Rand() % sizetxt; + tidbit = rn2(sizetxt); (void) dlb_fseek(fh, starttxt + tidbit, SEEK_SET); (void) dlb_fgets(line, sizeof line, fh);