aboutsummaryrefslogtreecommitdiff
path: root/src/commands.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/commands.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/commands.c b/src/commands.c
index fc63e7c..9ecc9c7 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -4,7 +4,6 @@
4 4
5CommandArgs * gen_parse_args(int c, char **v); 5CommandArgs * gen_parse_args(int c, char **v);
6CommandArgs * help_parse_args(int c, char **v); 6CommandArgs * help_parse_args(int c, char **v);
7CommandArgs * print_parse_args(int c, char **v);
8CommandArgs * parse_only_scramble(int c, char **v); 7CommandArgs * parse_only_scramble(int c, char **v);
9CommandArgs * parse_no_arg(int c, char **v); 8CommandArgs * parse_no_arg(int c, char **v);
10CommandArgs * solve_parse_args(int c, char **v); 9CommandArgs * solve_parse_args(int c, char **v);
@@ -92,7 +91,7 @@ print_cmd = {
92 .name = "print", 91 .name = "print",
93 .usage = "print SCRAMBLE", 92 .usage = "print SCRAMBLE",
94 .description = "Print written description of the cube", 93 .description = "Print written description of the cube",
95 .parse_args = print_parse_args, 94 .parse_args = parse_only_scramble,
96 .exec = print_exec, 95 .exec = print_exec,
97}; 96};
98 97
@@ -235,6 +234,8 @@ solve_parse_args(int c, char **v)
235 infinitesols = true; 234 infinitesols = true;
236 } else if (!strcmp(v[i], "-N")) { 235 } else if (!strcmp(v[i], "-N")) {
237 a->opts->can_niss = true; 236 a->opts->can_niss = true;
237 } else if (!strcmp(v[i], "-i")) {
238 a->scrstdin = true;
238 } else if (!strcmp(v[i], "-v")) { 239 } else if (!strcmp(v[i], "-v")) {
239 a->opts->verbose = true; 240 a->opts->verbose = true;
240 } else if (!strcmp(v[i], "-a")) { 241 } else if (!strcmp(v[i], "-a")) {
@@ -251,7 +252,7 @@ solve_parse_args(int c, char **v)
251 if (infinitesols && !fixedmsols) 252 if (infinitesols && !fixedmsols)
252 a->opts->max_solutions = 1000000; /* 1M = +infty */ 253 a->opts->max_solutions = 1000000; /* 1M = +infty */
253 254
254 a->success = read_scramble(c-i, &v[i], a); 255 a->success = (a->scrstdin && i == c) || read_scramble(c-i, &v[i], a);
255 return a; 256 return a;
256} 257}
257 258
@@ -338,7 +339,12 @@ parse_only_scramble(int c, char **v)
338{ 339{
339 CommandArgs *a = new_args(); 340 CommandArgs *a = new_args();
340 341
341 a->success = read_scramble(c, v, a); 342 if (!strcmp(v[0], "-i")) {
343 a->scrstdin = true;
344 a->success = c == 1;
345 } else {
346 a->success = read_scramble(c, v, a);
347 }
342 348
343 return a; 349 return a;
344} 350}
@@ -353,16 +359,6 @@ parse_no_arg(int c, char **v)
353 return a; 359 return a;
354} 360}
355 361
356CommandArgs *
357print_parse_args(int c, char **v)
358{
359 CommandArgs *a = new_args();
360
361 a->success = read_scramble(c, v, a);
362
363 return a;
364}
365
366/* Exec functions implementation *********************************************/ 362/* Exec functions implementation *********************************************/
367 363
368static void 364static void
@@ -611,6 +607,7 @@ new_args()
611 CommandArgs *args = malloc(sizeof(CommandArgs)); 607 CommandArgs *args = malloc(sizeof(CommandArgs));
612 608
613 args->success = false; 609 args->success = false;
610 args->scrstdin = false;
614 args->scramble = NULL; /* initialized in read_scramble */ 611 args->scramble = NULL; /* initialized in read_scramble */
615 args->opts = malloc(sizeof(SolveOptions)); 612 args->opts = malloc(sizeof(SolveOptions));
616 613

Generated with cgit - Back to sebastiano.tronto.net