nissy-fmc

A Rubik's cube FMC assistant
git clone https://git.tronto.net/nissy-fmc
Download | Log | Files | Refs | README | LICENSE

commit b57c17fde23cb8aece148eda9a9b816cb56d836b
parent d171279acb5f522e7dac010d86ccf12784759013
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Sat,  6 May 2023 14:35:14 +0200

Add sanitizer compile option + other changes (wip)

Diffstat:
MMakefile | 4+++-
Msrc/nissy.c | 29+++++++++++++++++++++--------
Msrc/solve.c | 2+-
Msrc/steps.c | 2+-
4 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile @@ -6,7 +6,9 @@ PREFIX = /usr/local CPPFLAGS = -DVERSION=\"${VERSION}\" CFLAGS = -std=c99 -pedantic -Wall -Wextra -Wno-unused-parameter -O3 ${CPPFLAGS} -DBFLAGS = -std=c99 -pedantic -Wall -Wextra -Wno-unused-parameter -g ${CPPFLAGS} +DBFLAGS = -std=c99 -pedantic -Wall -Wextra -Wno-unused-parameter \ + -Wno-unused-function -fsanitize=address -fsanitize=undefined \ + -g3 ${CPPFLAGS} CC = cc diff --git a/src/nissy.c b/src/nissy.c @@ -1,5 +1,5 @@ -#include <string.h> #include <inttypes.h> +#include <stddef.h> #include "cube.h" #include "coord.h" @@ -9,6 +9,19 @@ static bool set_step(char *, Step **); static bool set_solutiontype(char *, SolutionType *); static bool set_trans(char *, Trans *); +static bool strequal(char *, char *); + +static bool +strequal(char *s1, char *s2) +{ + int i; + + for (i = 0; s1[i] && s2[i]; i++) + if (s1[i] != s2[i]) + return false; + + return true; +} static bool set_step(char *str, Step **step) @@ -16,7 +29,7 @@ set_step(char *str, Step **step) int i; for (i = 0; steps[i] != NULL; i++) { - if (!strcmp(steps[i]->shortname, str)) { + if (strequal(steps[i]->shortname, str)) { *step = steps[i]; return true; } @@ -28,15 +41,15 @@ set_step(char *str, Step **step) static bool set_solutiontype(char *str, SolutionType *st) { - if (!strcmp(str, "normal")) { + if (strequal(str, "normal")) { *st = NORMAL; return true; } - if (!strcmp(str, "inverse")) { + if (strequal(str, "inverse")) { *st = INVERSE; return true; } - if (!strcmp(str, "niss")) { + if (strequal(str, "niss")) { *st = NISS; return true; } @@ -47,15 +60,15 @@ set_solutiontype(char *str, SolutionType *st) static bool set_trans(char *str, Trans *t) { - if (!strcmp(str, "uf")) { + if (strequal(str, "uf")) { *t = uf; return true; } - if (!strcmp(str, "fr")) { + if (strequal(str, "fr")) { *t = fr; return true; } - if (!strcmp(str, "rd")) { + if (strequal(str, "rd")) { *t = rd; return true; } diff --git a/src/solve.c b/src/solve.c @@ -1,4 +1,4 @@ -#include <string.h> +#include <stddef.h> #include <inttypes.h> #include "cube.h" diff --git a/src/steps.c b/src/steps.c @@ -1,5 +1,5 @@ -#include <string.h> #include <inttypes.h> +#include <stddef.h> #include "cube.h" #include "coord.h"