1
0
mirror of https://gittea.dev/nova/th.git synced 2025-10-22 02:40:15 -04:00

removal of rand() in sort_rand

This commit is contained in:
nova
2025-10-05 00:57:18 +02:00
parent e979209de3
commit f0ad6295f7
3 changed files with 27 additions and 10 deletions

View File

@@ -4,12 +4,11 @@
#include <strings.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>
#include "defines.h"
extern time_t seed;
extern unsigned int settings;
extern unsigned int file_modifiers;
extern time_t *seed;
int skip_hidden_files(const struct dirent *entry){
@@ -119,8 +118,21 @@ int sort_random(const void *file0, const void *file1){
if (!(((file*)file0)->file_type & FILE_TYPE_DIR) && (((file*)file1)->file_type & FILE_TYPE_DIR)) {
return 1;
}
time_t num = (time_t)&seed;
unsigned long i;
for (i = 0; i < 6; i++){
num ^= *seed;
if (num%2) {
num ^= (time_t)&num;
num ^= num << i;
} else {
num ^= (time_t)&seed;
num ^= num >> i;
}
}
num ^= getpid();
return ((rand()%3)-1);
return ((num%3) - 1);
}
int sort_type(const void *file0, const void *file1){