Commit Diff


commit - 7100fec23ecb5b29fc48094dfc0c63b0a9f8f32f
commit + 40c37b5c53a2635cfb1f4cb3a29c2a5f6648a0ea
blob - 8384944b147e78e3f13a458ee7c35535b43f794b
blob + fe0fd00b63ee0a618639f0f923f0c06ab1db8b3a
--- teach.c
+++ teach.c
@@ -4,6 +4,7 @@
  */
 
 #include <stdio.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
@@ -325,7 +326,6 @@ teach(void)
 	mistake = initmis;
 	avgtime = initrsp;
 	vartime = initvar;
-	srand(time(NULL));
 
 	puts("\n"
 	    "    Type what you hear!\n"
@@ -361,7 +361,7 @@ teach(void)
 		l = 0;
 		for (i = 0; i < nactive; i++)
 			l += basemul * overall + failprob[i];
-		x = l * rand() / RAND_MAX;
+		x = l * ((double)arc4random() / UINT32_MAX);
 		assert(nactive > 1);
 		for (i = 0; i < nactive - 1; i++) {
 			x -= basemul * overall + failprob[i];
@@ -370,7 +370,7 @@ teach(void)
 		}
 		assert (i < nactive);
 		/* avoid too many direct repeats */
-		if (nactive > 2 && alphabet[i] == ch && rand() <= RAND_MAX/2)
+		if (nactive > 2 && alphabet[i] == ch && arc4random() % 2)
 			continue;
 		ch = alphabet[i];