aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--weasel.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/weasel.c b/weasel.c
index a28b0e8..f85abf9 100644
--- a/weasel.c
+++ b/weasel.c
@@ -268,11 +268,13 @@ main(int argc, char **argv)
int display = 1;
int dontstop = 0;
int uflag = 1;
+ float threshold = 0.90;
+ int dieflag = 0;
alphabet = defalpha;
nthreads = ncpu();
- while ((c = getopt(argc, argv, "a:m:np:st:")) != -1)
+ while ((c = getopt(argc, argv, "a:m:np:sS:t:")) != -1)
switch (c) {
case 'a':
alphabet = strdup(optarg);
@@ -295,6 +297,10 @@ main(int argc, char **argv)
case 's':
dontstop = 1;
break;
+ case 'S':
+ dontstop = 1;
+ threshold = atof(optarg);
+ break;
case 't':
i = atoi(optarg);
if (i <= 0)
@@ -322,8 +328,9 @@ main(int argc, char **argv)
pthread_attr_init(&attr);
// pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- for (i = 0; !success(&best) || dontstop; i++) {
- if (dontstop && average > 0.99)
+ for (i = 0; !dieflag || dontstop; i++) {
+ dieflag = success(&best);
+ if (dontstop && average > threshold)
switchcase(aim, &uflag);
for (n = 0; n < nthreads; n++)
pthread_create(&threads[n], &attr, intercourse, NULL);