From bedc3ef9af6bc54f3ede135f1ad72565a8494f84 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 25 Dec 2021 00:06:50 +0100 Subject: Better error message when option for solve is unrecognized --- TODO.md | 1 + nissy | Bin 0 -> 321848 bytes src/commands.c | 15 ++++++++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100755 nissy diff --git a/TODO.md b/TODO.md index a7a41e1..1baf808 100644 --- a/TODO.md +++ b/TODO.md @@ -33,6 +33,7 @@ It's more of a personal reminder than anything else. * configure max ram to be used (via config file and/or command line option) * command to transform cube and alg * command notation to list available moves +* ## Distribution diff --git a/nissy b/nissy new file mode 100755 index 0000000..8bb98a2 Binary files /dev/null and b/nissy differ diff --git a/src/commands.c b/src/commands.c index 6afd5cd..d515042 100644 --- a/src/commands.c +++ b/src/commands.c @@ -385,15 +385,24 @@ read_scramble(int c, char **v, CommandArgs *args) int i, k, n; unsigned int j; char *algstr; + Alg *aux; - if (c < 1 || new_alg(v[0])->len == 0) { - fprintf(stderr, "Error reading scramble\n"); + if (c < 1) { + fprintf(stderr, "Error: no scramble given?\n"); return false; } n = 0; - for(i = 0; i < c; i++) + for(i = 0; i < c; i++) { + aux = new_alg(v[i]); + if (aux->len == 0) { + fprintf(stderr, "Error: %s unrecognized\n", v[i]); + free(aux); + return false; + } + free(aux); n += strlen(v[i]); + } algstr = malloc((n + 1) * sizeof(char)); k = 0; -- cgit v1.3