diff --git a/src/main.c b/src/main.c index 05b11c63..d9068ae0 100644 --- a/src/main.c +++ b/src/main.c @@ -2318,6 +2318,9 @@ main (int argc, char **argv, char **envp) OUTPUT_UNSET (); output_close (&make_sync); + if (shuffle_mode) + DB (DB_BASIC, (_("Enabled shuffle mode: %s\n"), shuffle_mode)); + if (read_files) { /* Update any makefiles if necessary. */ diff --git a/src/misc.c b/src/misc.c index 011e4f22..264eeb6a 100644 --- a/src/misc.c +++ b/src/misc.c @@ -75,23 +75,22 @@ make_ulltoa (unsigned long long val, char *buf) /* Simple random number generator, for use with shuffle. This doesn't need to be truly random, just pretty random. Use our own implementation rather than relying on the C runtime's rand() so we always - get the same results for a given seed, regardless of OS. */ + get the same results for a given seed, regardless of C runtime. */ static unsigned int mk_state = 0; void -make_seed(unsigned int seed) +make_seed (unsigned int seed) { mk_state = seed; } unsigned int -make_rand() +make_rand () { /* mk_state must never be 0. */ - if (mk_state == 0) { + if (mk_state == 0) mk_state = (unsigned int)(time (NULL) ^ make_pid ()) + 1; - } /* A simple xorshift RNG. */ mk_state ^= mk_state << 13; diff --git a/src/shuffle.c b/src/shuffle.c index 4cfdc943..17731e8f 100644 --- a/src/shuffle.c +++ b/src/shuffle.c @@ -82,7 +82,9 @@ shuffle_set_mode (const char *cmdarg) } else { - if (strcasecmp (cmdarg, "random") != 0) + if (strcasecmp (cmdarg, "random") == 0) + config.seed = make_rand (); + else { /* Assume explicit seed. */ const char *err;