nissy-classic

Stable branch of nissy
git clone https://git.tronto.net/nissy-classic
Download | Log | Files | Refs | README | LICENSE

commit 98b8339bceb833eb2419bc349547cb8342e4be1a
parent 9afb1a31f456b82f87539569055a76d23d0490b4
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Tue, 27 Feb 2024 18:33:31 +0100

Print solutions to stderr when using -v

Diffstat:
MMakefile | 2+-
Msrc/alg.c | 14+++++++-------
Msrc/alg.h | 4++--
Msrc/commands.c | 12++++++------
Msrc/solve.c | 3++-
5 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,6 +1,6 @@ # See LICENSE file for copyright and license details. -VERSION = 2.0.7 +VERSION = 2.0.7-next PREFIX = /usr/local MANPREFIX = ${PREFIX}/share/man diff --git a/src/alg.c b/src/alg.c @@ -423,7 +423,7 @@ on_inverse(Alg *alg) } void -print_alg(Alg *alg, bool l) +print_alg(FILE *out, Alg *alg, bool l) { char fill[4]; int i; @@ -437,25 +437,25 @@ print_alg(Alg *alg, bool l) if (niss == alg->inv[i]) strcpy(fill, i == 0 ? "" : " "); - printf("%s%s", fill, move_string(alg->move[i])); + fprintf(out, "%s%s", fill, move_string(alg->move[i])); niss = alg->inv[i]; } if (niss) - printf(")"); + fprintf(out, ")"); if (l) - printf(" (%d)", alg->len); + fprintf(out, " (%d)", alg->len); - printf("\n"); + fprintf(out, "\n"); } void -print_alglist(AlgList *al, bool l) +print_alglist(FILE *out, AlgList *al, bool l) { AlgListNode *i; for (i = al->first; i != NULL; i = i->next) - print_alg(i->alg, l); + print_alg(out, i->alg, l); } static void diff --git a/src/alg.h b/src/alg.h @@ -32,8 +32,8 @@ void moveset_to_list(Moveset ms, Move *lst); Alg * new_alg(char *str); AlgList * new_alglist(void); Alg * on_inverse(Alg *alg); -void print_alg(Alg *alg, bool l); -void print_alglist(AlgList *al, bool l); +void print_alg(FILE *out, Alg *alg, bool l); +void print_alglist(FILE *out, AlgList *al, bool l); void sort_alglist(AlgList *al); void swapmove(Move *m1, Move *m2); Alg * unniss(Alg *alg); diff --git a/src/commands.c b/src/commands.c @@ -435,7 +435,7 @@ solve_exec(CommandArgs *args) printf("%d\n", sols->len); } else { sort_alglist(sols); - print_alglist(sols, args->opts->print_number); + print_alglist(stdout, sols, args->opts->print_number); } free_alglist(sols); @@ -543,7 +543,7 @@ scramble_exec(CommandArgs *args) free_alg(aux); free_alg(ruf); } - print_alg(scr, false); + print_alg(stdout, scr, false); free_alg(scr); } } @@ -570,7 +570,7 @@ invert_exec(CommandArgs *args) Alg *inv; inv = inverse_alg(args->scramble); - print_alg(inv, false); + print_alg(stdout, inv, false); free_alg(inv); } @@ -645,7 +645,7 @@ twophase_exec(CommandArgs *args) c = apply_alg(args->scramble, (Cube){0}); sol = solve_2phase(c, 1); - print_alg(sol, false); + print_alg(stdout, sol, false); free_alg(sol); } @@ -685,7 +685,7 @@ cleanup_exec(CommandArgs *args) init_moves(); alg = cleanup(args->scramble); - print_alg(alg, false); + print_alg(stdout, alg, false); free_alg(alg); } @@ -696,7 +696,7 @@ unniss_exec(CommandArgs *args) Alg *aux; aux = unniss(args->scramble); - print_alg(aux, false); + print_alg(stdout, aux, false); free(aux); } diff --git a/src/solve.c b/src/solve.c @@ -156,7 +156,8 @@ dfs_check_solved(DfsArg *arg) inplace(unniss, arg->sols->last->alg); if (arg->opts->verbose) - print_alg(arg->sols->last->alg, false); + print_alg(stderr, + arg->sols->last->alg, false); } pthread_mutex_unlock(arg->sols_mutex);