aboutsummaryrefslogtreecommitdiff
path: root/src/nissy.c
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-08-26 15:35:09 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-08-26 15:35:09 +0200
commitf2907e471b3caddc5844bc6994e1cbd249019747 (patch)
tree36669614893b38a7b10535720841cac74094838e /src/nissy.c
parent25c16cc4350a659ede2a2503c4c5be36264e853d (diff)
downloadnissy-core-f2907e471b3caddc5844bc6994e1cbd249019747.tar.gz
nissy-core-f2907e471b3caddc5844bc6994e1cbd249019747.zip
Fixed bug in run solve
Diffstat (limited to 'src/nissy.c')
-rw-r--r--src/nissy.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/nissy.c b/src/nissy.c
index 5641dd9..f8c1f4d 100644
--- a/src/nissy.c
+++ b/src/nissy.c
@@ -26,23 +26,31 @@ struct {
26_static int 26_static int
27parse_h48_options(const char *buf, uint8_t *h, uint8_t *k, uint8_t *maxdepth) 27parse_h48_options(const char *buf, uint8_t *h, uint8_t *k, uint8_t *maxdepth)
28{ 28{
29 bool h_valid, k_valid, maxdepth_valid;
29 int i; 30 int i;
30 31
31 /* TODO temporarily, options are in the form "h;k;maxdepth" */ 32 /* TODO temporarily, options are in the form "h;k;maxdepth" */
32 if (h != NULL) 33 if (h != NULL)
33 *h = atoi(buf); 34 *h = atoi(buf);
35 h_valid = h == NULL || *h <= 11;
36
34 for (i = 0; buf[i] != ';'; i++) 37 for (i = 0; buf[i] != ';'; i++)
35 if (buf[i] == 0) 38 if (buf[i] == 0)
36 goto parse_h48_options_error; 39 goto parse_h48_options_error;
40
37 if (k != NULL) 41 if (k != NULL)
38 *k = atoi(&buf[i+1]); 42 *k = atoi(&buf[i+1]);
43 k_valid = k == NULL || (*k == 2 || *k == 4);
44
39 for (i = i+1; buf[i] != ';'; i++) 45 for (i = i+1; buf[i] != ';'; i++)
40 if (buf[i] == 0) 46 if (buf[i] == 0)
41 goto parse_h48_options_error; 47 goto parse_h48_options_error;
48
42 if (maxdepth != NULL) 49 if (maxdepth != NULL)
43 *maxdepth = atoi(&buf[i+1]); 50 *maxdepth = atoi(&buf[i+1]);
51 maxdepth_valid = maxdepth == NULL || *maxdepth <= 20;
44 52
45 return (*h <= 11 && (*k == 2 || *k == 4) && *maxdepth <= 20) ? 0 : 1; 53 return h_valid && k_valid && maxdepth_valid ? 0 : 1;
46 54
47parse_h48_options_error: 55parse_h48_options_error:
48 *h = 0; 56 *h = 0;
@@ -202,7 +210,7 @@ nissy_gendata(
202 if (!strcmp(solver, "h48")) { 210 if (!strcmp(solver, "h48")) {
203 p = parse_h48_options(options, &arg.h, &arg.k, &arg.maxdepth); 211 p = parse_h48_options(options, &arg.h, &arg.k, &arg.maxdepth);
204 if (p != 0) { 212 if (p != 0) {
205 LOG("gendata: ould not parse options\n"); 213 LOG("gendata: could not parse options\n");
206 ret = -1; 214 ret = -1;
207 } else { 215 } else {
208 ret = gendata_h48(&arg); 216 ret = gendata_h48(&arg);

Generated with cgit - Back to sebastiano.tronto.net