Marcus Rueckert
00b5524e84
Copy from home:jengelh:branches:Base:System/bash via accept of submit request 26308 revision 2. Request was accepted with message: reviewed OBS-URL: https://build.opensuse.org/request/show/26308 OBS-URL: https://build.opensuse.org/package/show/Base:System/bash?expand=0&rev=16
44 lines
944 B
Diff
44 lines
944 B
Diff
--- variables.c
|
|
+++ variables.c 2009-12-04 09:31:06.579929599 +0000
|
|
@@ -1216,6 +1216,7 @@ static unsigned long rseed = 1;
|
|
static int last_random_value;
|
|
static int seeded_subshell = 0;
|
|
|
|
+#if !defined(linux)
|
|
/* A linear congruential random number generator based on the example
|
|
one in the ANSI C standard. This one isn't very good, but a more
|
|
complicated one is overkill. */
|
|
@@ -1264,6 +1265,32 @@ seedrand ()
|
|
sbrand (tv.tv_sec ^ tv.tv_usec ^ getpid ());
|
|
}
|
|
|
|
+#else
|
|
+/* Use ISO C Random Number Functions of the glibc */
|
|
+static int
|
|
+brand (void)
|
|
+{
|
|
+ if (rseed == 0)
|
|
+ seedrand ();
|
|
+ return rand() & 32767;
|
|
+}
|
|
+
|
|
+static void
|
|
+sbrand (unsigned long seed)
|
|
+{
|
|
+ rseed = seed;
|
|
+ srand(seed);
|
|
+}
|
|
+
|
|
+static void
|
|
+seedrand (void)
|
|
+{
|
|
+ struct timeval tv;
|
|
+ gettimeofday (&tv, NULL);
|
|
+ srand (tv.tv_sec ^ tv.tv_usec ^ getpid ());
|
|
+}
|
|
+#endif
|
|
+
|
|
static SHELL_VAR *
|
|
assign_random (self, value, unused, key)
|
|
SHELL_VAR *self;
|