diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-02-27 18:33:31 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-02-27 18:33:31 +0100 |
| commit | 98b8339bceb833eb2419bc349547cb8342e4be1a (patch) | |
| tree | ed8ee56446b874500f733b60985c6fcf645f829d | |
| parent | 9afb1a31f456b82f87539569055a76d23d0490b4 (diff) | |
| download | nissy-classic-98b8339bceb833eb2419bc349547cb8342e4be1a.tar.gz nissy-classic-98b8339bceb833eb2419bc349547cb8342e4be1a.zip | |
Print solutions to stderr when using -v
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | src/alg.c | 14 | ||||
| -rw-r--r-- | src/alg.h | 4 | ||||
| -rw-r--r-- | src/commands.c | 12 | ||||
| -rw-r--r-- | src/solve.c | 3 |
5 files changed, 18 insertions, 17 deletions
| @@ -1,6 +1,6 @@ | |||
| 1 | # See LICENSE file for copyright and license details. | 1 | # See LICENSE file for copyright and license details. |
| 2 | 2 | ||
| 3 | VERSION = 2.0.7 | 3 | VERSION = 2.0.7-next |
| 4 | 4 | ||
| 5 | PREFIX = /usr/local | 5 | PREFIX = /usr/local |
| 6 | MANPREFIX = ${PREFIX}/share/man | 6 | MANPREFIX = ${PREFIX}/share/man |
| @@ -423,7 +423,7 @@ on_inverse(Alg *alg) | |||
| 423 | } | 423 | } |
| 424 | 424 | ||
| 425 | void | 425 | void |
| 426 | print_alg(Alg *alg, bool l) | 426 | print_alg(FILE *out, Alg *alg, bool l) |
| 427 | { | 427 | { |
| 428 | char fill[4]; | 428 | char fill[4]; |
| 429 | int i; | 429 | int i; |
| @@ -437,25 +437,25 @@ print_alg(Alg *alg, bool l) | |||
| 437 | if (niss == alg->inv[i]) | 437 | if (niss == alg->inv[i]) |
| 438 | strcpy(fill, i == 0 ? "" : " "); | 438 | strcpy(fill, i == 0 ? "" : " "); |
| 439 | 439 | ||
| 440 | printf("%s%s", fill, move_string(alg->move[i])); | 440 | fprintf(out, "%s%s", fill, move_string(alg->move[i])); |
| 441 | niss = alg->inv[i]; | 441 | niss = alg->inv[i]; |
| 442 | } | 442 | } |
| 443 | 443 | ||
| 444 | if (niss) | 444 | if (niss) |
| 445 | printf(")"); | 445 | fprintf(out, ")"); |
| 446 | if (l) | 446 | if (l) |
| 447 | printf(" (%d)", alg->len); | 447 | fprintf(out, " (%d)", alg->len); |
| 448 | 448 | ||
| 449 | printf("\n"); | 449 | fprintf(out, "\n"); |
| 450 | } | 450 | } |
| 451 | 451 | ||
| 452 | void | 452 | void |
| 453 | print_alglist(AlgList *al, bool l) | 453 | print_alglist(FILE *out, AlgList *al, bool l) |
| 454 | { | 454 | { |
| 455 | AlgListNode *i; | 455 | AlgListNode *i; |
| 456 | 456 | ||
| 457 | for (i = al->first; i != NULL; i = i->next) | 457 | for (i = al->first; i != NULL; i = i->next) |
| 458 | print_alg(i->alg, l); | 458 | print_alg(out, i->alg, l); |
| 459 | } | 459 | } |
| 460 | 460 | ||
| 461 | static void | 461 | static void |
| @@ -32,8 +32,8 @@ void moveset_to_list(Moveset ms, Move *lst); | |||
| 32 | Alg * new_alg(char *str); | 32 | Alg * new_alg(char *str); |
| 33 | AlgList * new_alglist(void); | 33 | AlgList * new_alglist(void); |
| 34 | Alg * on_inverse(Alg *alg); | 34 | Alg * on_inverse(Alg *alg); |
| 35 | void print_alg(Alg *alg, bool l); | 35 | void print_alg(FILE *out, Alg *alg, bool l); |
| 36 | void print_alglist(AlgList *al, bool l); | 36 | void print_alglist(FILE *out, AlgList *al, bool l); |
| 37 | void sort_alglist(AlgList *al); | 37 | void sort_alglist(AlgList *al); |
| 38 | void swapmove(Move *m1, Move *m2); | 38 | void swapmove(Move *m1, Move *m2); |
| 39 | Alg * unniss(Alg *alg); | 39 | Alg * unniss(Alg *alg); |
diff --git a/src/commands.c b/src/commands.c index 1e5dd07..c65cc5f 100644 --- a/src/commands.c +++ b/src/commands.c | |||
| @@ -435,7 +435,7 @@ solve_exec(CommandArgs *args) | |||
| 435 | printf("%d\n", sols->len); | 435 | printf("%d\n", sols->len); |
| 436 | } else { | 436 | } else { |
| 437 | sort_alglist(sols); | 437 | sort_alglist(sols); |
| 438 | print_alglist(sols, args->opts->print_number); | 438 | print_alglist(stdout, sols, args->opts->print_number); |
| 439 | } | 439 | } |
| 440 | 440 | ||
| 441 | free_alglist(sols); | 441 | free_alglist(sols); |
| @@ -543,7 +543,7 @@ scramble_exec(CommandArgs *args) | |||
| 543 | free_alg(aux); | 543 | free_alg(aux); |
| 544 | free_alg(ruf); | 544 | free_alg(ruf); |
| 545 | } | 545 | } |
| 546 | print_alg(scr, false); | 546 | print_alg(stdout, scr, false); |
| 547 | free_alg(scr); | 547 | free_alg(scr); |
| 548 | } | 548 | } |
| 549 | } | 549 | } |
| @@ -570,7 +570,7 @@ invert_exec(CommandArgs *args) | |||
| 570 | Alg *inv; | 570 | Alg *inv; |
| 571 | 571 | ||
| 572 | inv = inverse_alg(args->scramble); | 572 | inv = inverse_alg(args->scramble); |
| 573 | print_alg(inv, false); | 573 | print_alg(stdout, inv, false); |
| 574 | 574 | ||
| 575 | free_alg(inv); | 575 | free_alg(inv); |
| 576 | } | 576 | } |
| @@ -645,7 +645,7 @@ twophase_exec(CommandArgs *args) | |||
| 645 | c = apply_alg(args->scramble, (Cube){0}); | 645 | c = apply_alg(args->scramble, (Cube){0}); |
| 646 | sol = solve_2phase(c, 1); | 646 | sol = solve_2phase(c, 1); |
| 647 | 647 | ||
| 648 | print_alg(sol, false); | 648 | print_alg(stdout, sol, false); |
| 649 | free_alg(sol); | 649 | free_alg(sol); |
| 650 | } | 650 | } |
| 651 | 651 | ||
| @@ -685,7 +685,7 @@ cleanup_exec(CommandArgs *args) | |||
| 685 | init_moves(); | 685 | init_moves(); |
| 686 | 686 | ||
| 687 | alg = cleanup(args->scramble); | 687 | alg = cleanup(args->scramble); |
| 688 | print_alg(alg, false); | 688 | print_alg(stdout, alg, false); |
| 689 | 689 | ||
| 690 | free_alg(alg); | 690 | free_alg(alg); |
| 691 | } | 691 | } |
| @@ -696,7 +696,7 @@ unniss_exec(CommandArgs *args) | |||
| 696 | Alg *aux; | 696 | Alg *aux; |
| 697 | 697 | ||
| 698 | aux = unniss(args->scramble); | 698 | aux = unniss(args->scramble); |
| 699 | print_alg(aux, false); | 699 | print_alg(stdout, aux, false); |
| 700 | free(aux); | 700 | free(aux); |
| 701 | } | 701 | } |
| 702 | 702 | ||
diff --git a/src/solve.c b/src/solve.c index 5581964..1078816 100644 --- a/src/solve.c +++ b/src/solve.c | |||
| @@ -156,7 +156,8 @@ dfs_check_solved(DfsArg *arg) | |||
| 156 | inplace(unniss, arg->sols->last->alg); | 156 | inplace(unniss, arg->sols->last->alg); |
| 157 | 157 | ||
| 158 | if (arg->opts->verbose) | 158 | if (arg->opts->verbose) |
| 159 | print_alg(arg->sols->last->alg, false); | 159 | print_alg(stderr, |
| 160 | arg->sols->last->alg, false); | ||
| 160 | } | 161 | } |
| 161 | 162 | ||
| 162 | pthread_mutex_unlock(arg->sols_mutex); | 163 | pthread_mutex_unlock(arg->sols_mutex); |
