aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/coord/utils.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-05-19 17:45:14 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-05-19 17:45:14 +0200
commit62d87e063318cc4c842b1b2d8c184f48aeaf6659 (patch)
tree832bf338232c477975bea69f7370ca13f350fb07 /src/solvers/coord/utils.h
parent8b94d135429a9f3253cc7f25a1453b412065c4a0 (diff)
downloadnissy-core-62d87e063318cc4c842b1b2d8c184f48aeaf6659.tar.gz
nissy-core-62d87e063318cc4c842b1b2d8c184f48aeaf6659.zip
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.
Diffstat (limited to 'src/solvers/coord/utils.h')
-rw-r--r--src/solvers/coord/utils.h28
1 files changed, 12 insertions, 16 deletions
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 @@
1STATIC coord_t *parse_coord(size_t n, const char [n]); 1STATIC coord_t *parse_coord(size_t n, const char [n]);
2STATIC uint8_t parse_axis(size_t n, const char [n]); 2STATIC uint8_t parse_axis(const char [static 2]);
3STATIC void parse_coord_and_axis( 3STATIC void parse_coord_and_axis(const char *, coord_t **, uint8_t *);
4 size_t n, const char [n], coord_t **, uint8_t *);
5STATIC long long dataid_coord(const char *, char [static NISSY_SIZE_DATAID]); 4STATIC long long dataid_coord(const char *, char [static NISSY_SIZE_DATAID]);
6 5
7STATIC coord_t * 6STATIC coord_t *
@@ -17,13 +16,13 @@ parse_coord(size_t n, const char coord[n])
17} 16}
18 17
19STATIC uint8_t 18STATIC uint8_t
20parse_axis(size_t n, const char axis[n]) 19parse_axis(const char axis[static 2])
21{ 20{
22 if (!strncmp(axis, "UD", n) || !strncmp(axis, "DU", n)) { 21 if (!strcmp(axis, "UD") || !strcmp(axis, "DU")) {
23 return AXIS_UD; 22 return AXIS_UD;
24 } else if (!strncmp(axis, "RL", n) || !strncmp(axis, "LR", n)) { 23 } else if (!strcmp(axis, "RL") || !strcmp(axis, "LR")) {
25 return AXIS_RL; 24 return AXIS_RL;
26 } else if (!strncmp(axis, "FB", n) || !strncmp(axis, "BF", n)) { 25 } else if (!strcmp(axis, "FB") || !strcmp(axis, "BF")) {
27 return AXIS_FB; 26 return AXIS_FB;
28 } 27 }
29 28
@@ -32,25 +31,22 @@ parse_axis(size_t n, const char axis[n])
32 31
33STATIC void 32STATIC void
34parse_coord_and_axis( 33parse_coord_and_axis(
35 size_t n, 34 const char *str,
36 const char str[n],
37 coord_t **coord, 35 coord_t **coord,
38 uint8_t *axis 36 uint8_t *axis
39) 37)
40{ 38{
41 const char *s;
42 size_t i; 39 size_t i;
43 40
44 s = str + 6; 41 for (i = 6; i < strlen(str); i++)
45 for (i = 0; i < n; i++) 42 if (str[i] == '_')
46 if (s[i] == '_')
47 break; 43 break;
48 44
49 if (coord != NULL) 45 if (coord != NULL)
50 *coord = parse_coord(i, s); 46 *coord = parse_coord(i-6, str+6);
51 47
52 if (axis != NULL) 48 if (axis != NULL)
53 *axis = i == n ? UINT8_ERROR : parse_axis(n-i-1, s+i+1); 49 *axis = i == strlen(str) ? UINT8_ERROR : parse_axis(str+i+1);
54} 50}
55 51
56STATIC long long 52STATIC long long
@@ -58,7 +54,7 @@ dataid_coord(const char *ca, char dataid[static NISSY_SIZE_DATAID])
58{ 54{
59 coord_t *c; 55 coord_t *c;
60 56
61 parse_coord_and_axis(strlen(ca), ca, &c, NULL); 57 parse_coord_and_axis(ca, &c, NULL);
62 58
63 if (c == NULL) { 59 if (c == NULL) {
64 LOG("Error: cannot parse coordinate from '%s'\n", ca); 60 LOG("Error: cannot parse coordinate from '%s'\n", ca);

Generated with cgit - Back to sebastiano.tronto.net