aboutsummaryrefslogtreecommitdiff
path: root/src/shuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shuf.c')
-rw-r--r--src/shuf.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/shuf.c b/src/shuf.c
index 5b4808a..e97f1f0 100644
--- a/src/shuf.c
+++ b/src/shuf.c
@@ -8,6 +8,10 @@
#include <errno.h>
#include <limits.h>
+#ifdef USE_TRAND
+# include "trand.h"
+#endif
+
#define NUMBER_LEN(x) strlen(#x);
static char *g_name = "shuf";
@@ -192,7 +196,11 @@ int main(int argc, char **argv)
}
for (size_t i = lines.len - 1; i > 0; i--)
{
+#ifndef USE_TRAND
size_t j = rand() % i;
+#else
+ size_t j = trand() % i;
+#endif
char *tmp = lines.data[i];
lines.data[i] = lines.data[j];
lines.data[j] = tmp;