From 65c411dcb3fd33122cbc314ca5b2a94542bc1e87 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sat, 22 Aug 2020 20:09:13 +0200 Subject: Added shuf with trand --- src/shuf.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/shuf.c') 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 #include +#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; -- cgit