From 62d87e063318cc4c842b1b2d8c184f48aeaf6659 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 19 May 2025 17:45:14 +0200 Subject: Refactored checkdata Relevant changes include: - Changed the signature of nissy_checkdata(). - Removed expected_distribution.h from tools; this data is now included in each solver's src/ code. - Removed distribution check for cocsep; may add back later. --- src/solvers/coord/utils.h | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'src/solvers/coord/utils.h') diff --git a/src/solvers/coord/utils.h b/src/solvers/coord/utils.h index aa4d74c..6066049 100644 --- a/src/solvers/coord/utils.h +++ b/src/solvers/coord/utils.h @@ -1,7 +1,6 @@ STATIC coord_t *parse_coord(size_t n, const char [n]); -STATIC uint8_t parse_axis(size_t n, const char [n]); -STATIC void parse_coord_and_axis( - size_t n, const char [n], coord_t **, uint8_t *); +STATIC uint8_t parse_axis(const char [static 2]); +STATIC void parse_coord_and_axis(const char *, coord_t **, uint8_t *); STATIC long long dataid_coord(const char *, char [static NISSY_SIZE_DATAID]); STATIC coord_t * @@ -17,13 +16,13 @@ parse_coord(size_t n, const char coord[n]) } STATIC uint8_t -parse_axis(size_t n, const char axis[n]) +parse_axis(const char axis[static 2]) { - if (!strncmp(axis, "UD", n) || !strncmp(axis, "DU", n)) { + if (!strcmp(axis, "UD") || !strcmp(axis, "DU")) { return AXIS_UD; - } else if (!strncmp(axis, "RL", n) || !strncmp(axis, "LR", n)) { + } else if (!strcmp(axis, "RL") || !strcmp(axis, "LR")) { return AXIS_RL; - } else if (!strncmp(axis, "FB", n) || !strncmp(axis, "BF", n)) { + } else if (!strcmp(axis, "FB") || !strcmp(axis, "BF")) { return AXIS_FB; } @@ -32,25 +31,22 @@ parse_axis(size_t n, const char axis[n]) STATIC void parse_coord_and_axis( - size_t n, - const char str[n], + const char *str, coord_t **coord, uint8_t *axis ) { - const char *s; size_t i; - s = str + 6; - for (i = 0; i < n; i++) - if (s[i] == '_') + for (i = 6; i < strlen(str); i++) + if (str[i] == '_') break; if (coord != NULL) - *coord = parse_coord(i, s); + *coord = parse_coord(i-6, str+6); if (axis != NULL) - *axis = i == n ? UINT8_ERROR : parse_axis(n-i-1, s+i+1); + *axis = i == strlen(str) ? UINT8_ERROR : parse_axis(str+i+1); } STATIC long long @@ -58,7 +54,7 @@ dataid_coord(const char *ca, char dataid[static NISSY_SIZE_DATAID]) { coord_t *c; - parse_coord_and_axis(strlen(ca), ca, &c, NULL); + parse_coord_and_axis(ca, &c, NULL); if (c == NULL) { LOG("Error: cannot parse coordinate from '%s'\n", ca); -- cgit v1.3