aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/coord/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/solvers/coord/utils.h')
-rw-r--r--src/solvers/coord/utils.h32
1 files changed, 11 insertions, 21 deletions
diff --git a/src/solvers/coord/utils.h b/src/solvers/coord/utils.h
index 5b8f538..93704cc 100644
--- a/src/solvers/coord/utils.h
+++ b/src/solvers/coord/utils.h
@@ -1,6 +1,5 @@
1STATIC coord_t *parse_coord(size_t, const char *); 1STATIC coord_t *parse_coord(size_t, const char *);
2STATIC uint8_t parse_axis(const char [static 2]); 2STATIC void parse_coord_and_trans(const char *, coord_t **, uint8_t *);
3STATIC void parse_coord_and_axis(const char *, coord_t **, uint8_t *);
4STATIC long long dataid_coord(const char *, char [static NISSY_SIZE_DATAID]); 3STATIC long long dataid_coord(const char *, char [static NISSY_SIZE_DATAID]);
5 4
6STATIC coord_t * 5STATIC coord_t *
@@ -8,6 +7,10 @@ parse_coord(size_t n, const char *coord)
8{ 7{
9 int i; 8 int i;
10 9
10 /*
11 TODO Some coordinates are parsed incorrectly, e.g. DRFINNOE
12 TODO is matched by DRFIN. Check that strncmp is used correctly.
13 */
11 for (i = 0; all_coordinates[i] != NULL; i++) 14 for (i = 0; all_coordinates[i] != NULL; i++)
12 if (!strncmp(all_coordinates[i]->name, coord, n)) 15 if (!strncmp(all_coordinates[i]->name, coord, n))
13 return all_coordinates[i]; 16 return all_coordinates[i];
@@ -15,25 +18,11 @@ parse_coord(size_t n, const char *coord)
15 return NULL; 18 return NULL;
16} 19}
17 20
18STATIC uint8_t
19parse_axis(const char axis[static 2])
20{
21 if (!strcmp(axis, "UD") || !strcmp(axis, "DU")) {
22 return AXIS_UD;
23 } else if (!strcmp(axis, "RL") || !strcmp(axis, "LR")) {
24 return AXIS_RL;
25 } else if (!strcmp(axis, "FB") || !strcmp(axis, "BF")) {
26 return AXIS_FB;
27 }
28
29 return UINT8_ERROR;
30}
31
32STATIC void 21STATIC void
33parse_coord_and_axis( 22parse_coord_and_trans(
34 const char *str, 23 const char *str,
35 coord_t **coord, 24 coord_t **coord,
36 uint8_t *axis 25 uint8_t *trans
37) 26)
38{ 27{
39 size_t i; 28 size_t i;
@@ -45,8 +34,9 @@ parse_coord_and_axis(
45 if (coord != NULL) 34 if (coord != NULL)
46 *coord = parse_coord(i-6, str+6); 35 *coord = parse_coord(i-6, str+6);
47 36
48 if (axis != NULL) 37 if (trans != NULL)
49 *axis = i == strlen(str) ? UINT8_ERROR : parse_axis(str+i+1); 38 *trans = i == strlen(str) ?
39 UINT8_ERROR : readrotation(str+i+1);
50} 40}
51 41
52STATIC long long 42STATIC long long
@@ -54,7 +44,7 @@ dataid_coord(const char *ca, char dataid[static NISSY_SIZE_DATAID])
54{ 44{
55 coord_t *c; 45 coord_t *c;
56 46
57 parse_coord_and_axis(ca, &c, NULL); 47 parse_coord_and_trans(ca, &c, NULL);
58 48
59 if (c == NULL) { 49 if (c == NULL) {
60 LOG("Error: cannot parse coordinate from '%s'\n", ca); 50 LOG("Error: cannot parse coordinate from '%s'\n", ca);

Generated with cgit - Back to sebastiano.tronto.net