diff options
author | Steve Bennett <steveb@workware.net.au> | 2011-06-09 10:54:12 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2011-06-09 11:45:39 +1000 |
commit | fb30e73b7cf6b9ad0ad75aadf73679796789f51c (patch) | |
tree | 2b36460db2bf41ce18a01515065e1a60dd70b2cb | |
parent | f25d6276ee487d583e35c48f3125ef388c9f7d3f (diff) | |
download | jimtcl-fb30e73b7cf6b9ad0ad75aadf73679796789f51c.zip jimtcl-fb30e73b7cf6b9ad0ad75aadf73679796789f51c.tar.gz jimtcl-fb30e73b7cf6b9ad0ad75aadf73679796789f51c.tar.bz2 |
Revert to using localtime() and rand()
Some platforms don't have localtime_r() and rand_r()
-rw-r--r-- | jim-clock.c | 3 | ||||
-rw-r--r-- | jim-win32compat.h | 2 | ||||
-rw-r--r-- | jim.c | 3 |
3 files changed, 2 insertions, 6 deletions
diff --git a/jim-clock.c b/jim-clock.c index f771f71..51ffb51 100644 --- a/jim-clock.c +++ b/jim-clock.c @@ -26,7 +26,6 @@ static int clock_cmd_format(Jim_Interp *interp, int argc, Jim_Obj *const *argv) char buf[100]; time_t t; long seconds; - struct tm tm; const char *format = "%a %b %d %H:%M:%S %Z %Y"; @@ -43,7 +42,7 @@ static int clock_cmd_format(Jim_Interp *interp, int argc, Jim_Obj *const *argv) } t = seconds; - strftime(buf, sizeof(buf), format, localtime_r(&t, &tm)); + strftime(buf, sizeof(buf), format, localtime(&t)); Jim_SetResultString(interp, buf, -1); diff --git a/jim-win32compat.h b/jim-win32compat.h index 22a1502..dab0a01 100644 --- a/jim-win32compat.h +++ b/jim-win32compat.h @@ -14,8 +14,6 @@ #define JIM_ANSIC #define MKDIR_ONE_ARG -#define rand_r(S) ((void)(S), rand()) -#define localtime_r(T,TM) ((void)(TM), localtime(T)) #define RTLD_LAZY 0 void *dlopen(const char *path, int mode); @@ -9294,11 +9294,10 @@ static void JimPrngInit(Jim_Interp *interp) int i; /* XXX: Move off stack */ unsigned int seed[256]; - unsigned rseed; /* uninitialized! */ interp->prngState = Jim_Alloc(sizeof(Jim_PrngState)); for (i = 0; i < 256; i++) - seed[i] = (rand_r(&rseed) ^ time(NULL) ^ clock()); + seed[i] = (rand() ^ time(NULL) ^ clock()); JimPrngSeed(interp, (unsigned char *)seed, sizeof(int) * 256); } |