diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-04-15 16:07:52 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-04-15 16:07:52 +0200 |
| commit | ba4e25810e0b845fe0488bc504bf3ab5bd1f3824 (patch) | |
| tree | 66b9e350084139e330f0ce90cb5f6749c48d5396 | |
| parent | 59ecc0ee72a180692fcccab88db310d60021f2ab (diff) | |
| download | cubecore-ba4e25810e0b845fe0488bc504bf3ab5bd1f3824.tar.gz cubecore-ba4e25810e0b845fe0488bc504bf3ab5bd1f3824.zip | |
const char *
| -rw-r--r-- | cube.c | 40 | ||||
| -rw-r--r-- | cube.h | 8 | ||||
| -rw-r--r-- | example/example.cpp | 4 |
3 files changed, 26 insertions, 26 deletions
| @@ -31,13 +31,13 @@ | |||
| 31 | 31 | ||
| 32 | _static_inline cube_t invertco(cube_t); | 32 | _static_inline cube_t invertco(cube_t); |
| 33 | _static int permsign(uint8_t *, int); | 33 | _static int permsign(uint8_t *, int); |
| 34 | _static uint8_t readco(char *); | 34 | _static uint8_t readco(const char *); |
| 35 | _static uint8_t readcp(char *); | 35 | _static uint8_t readcp(const char *); |
| 36 | _static uint8_t readeo(char *); | 36 | _static uint8_t readeo(const char *); |
| 37 | _static uint8_t readep(char *); | 37 | _static uint8_t readep(const char *); |
| 38 | _static cube_t read_H48(char *); | 38 | _static cube_t read_H48(const char *); |
| 39 | _static uint8_t readpiece_LST(char **); | 39 | _static uint8_t readpiece_LST(const char **); |
| 40 | _static cube_t read_LST(char *); | 40 | _static cube_t read_LST(const char *); |
| 41 | _static int writepiece_LST(uint8_t, char *); | 41 | _static int writepiece_LST(uint8_t, char *); |
| 42 | _static void write_H48(cube_t, char *); | 42 | _static void write_H48(cube_t, char *); |
| 43 | _static void write_LST(cube_t, char *); | 43 | _static void write_LST(cube_t, char *); |
| @@ -45,7 +45,7 @@ _static uint8_t readmove(char); | |||
| 45 | _static uint8_t readmodifier(char); | 45 | _static uint8_t readmodifier(char); |
| 46 | 46 | ||
| 47 | _static uint8_t | 47 | _static uint8_t |
| 48 | readco(char *str) | 48 | readco(const char *str) |
| 49 | { | 49 | { |
| 50 | if (*str == '0') | 50 | if (*str == '0') |
| 51 | return 0; | 51 | return 0; |
| @@ -59,7 +59,7 @@ readco(char *str) | |||
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | _static uint8_t | 61 | _static uint8_t |
| 62 | readcp(char *str) | 62 | readcp(const char *str) |
| 63 | { | 63 | { |
| 64 | uint8_t c; | 64 | uint8_t c; |
| 65 | 65 | ||
| @@ -73,7 +73,7 @@ readcp(char *str) | |||
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | _static uint8_t | 75 | _static uint8_t |
| 76 | readeo(char *str) | 76 | readeo(const char *str) |
| 77 | { | 77 | { |
| 78 | if (*str == '0') | 78 | if (*str == '0') |
| 79 | return 0; | 79 | return 0; |
| @@ -85,7 +85,7 @@ readeo(char *str) | |||
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | _static uint8_t | 87 | _static uint8_t |
| 88 | readep(char *str) | 88 | readep(const char *str) |
| 89 | { | 89 | { |
| 90 | uint8_t e; | 90 | uint8_t e; |
| 91 | 91 | ||
| @@ -98,12 +98,12 @@ readep(char *str) | |||
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | _static cube_t | 100 | _static cube_t |
| 101 | read_H48(char *buf) | 101 | read_H48(const char *buf) |
| 102 | { | 102 | { |
| 103 | int i; | 103 | int i; |
| 104 | uint8_t piece, orient; | 104 | uint8_t piece, orient; |
| 105 | cube_t ret = {0}; | 105 | cube_t ret = {0}; |
| 106 | char *b; | 106 | const char *b; |
| 107 | 107 | ||
| 108 | b = buf; | 108 | b = buf; |
| 109 | 109 | ||
| @@ -134,7 +134,7 @@ read_H48(char *buf) | |||
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | _static uint8_t | 136 | _static uint8_t |
| 137 | readpiece_LST(char **b) | 137 | readpiece_LST(const char **b) |
| 138 | { | 138 | { |
| 139 | uint8_t ret; | 139 | uint8_t ret; |
| 140 | bool read; | 140 | bool read; |
| @@ -151,7 +151,7 @@ readpiece_LST(char **b) | |||
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | _static cube_t | 153 | _static cube_t |
| 154 | read_LST(char *buf) | 154 | read_LST(const char *buf) |
| 155 | { | 155 | { |
| 156 | int i; | 156 | int i; |
| 157 | cube_t ret = {0}; | 157 | cube_t ret = {0}; |
| @@ -547,7 +547,7 @@ cube_coord_eo(cube_t c) | |||
| 547 | } | 547 | } |
| 548 | 548 | ||
| 549 | cube_t | 549 | cube_t |
| 550 | cube_read(char *format, char *buf) | 550 | cube_read(const char *format, const char *buf) |
| 551 | { | 551 | { |
| 552 | cube_t cube; | 552 | cube_t cube; |
| 553 | 553 | ||
| @@ -564,7 +564,7 @@ cube_read(char *format, char *buf) | |||
| 564 | } | 564 | } |
| 565 | 565 | ||
| 566 | void | 566 | void |
| 567 | cube_write(char *format, cube_t cube, char *buf) | 567 | cube_write(const char *format, cube_t cube, char *buf) |
| 568 | { | 568 | { |
| 569 | char *errormsg; | 569 | char *errormsg; |
| 570 | size_t len; | 570 | size_t len; |
| @@ -594,11 +594,11 @@ write_error: | |||
| 594 | } | 594 | } |
| 595 | 595 | ||
| 596 | int | 596 | int |
| 597 | cube_readmoves(char *buf, move_t *ret) | 597 | cube_readmoves(const char *buf, move_t *ret) |
| 598 | { | 598 | { |
| 599 | int n; | 599 | int n; |
| 600 | move_t r, m; | 600 | move_t r, m; |
| 601 | char *b; | 601 | const char *b; |
| 602 | 602 | ||
| 603 | for (n = 0, b = buf; *b != '\0'; b++) { | 603 | for (n = 0, b = buf; *b != '\0'; b++) { |
| 604 | while (*b == ' ' || *b == '\t' || *b == '\n') | 604 | while (*b == ' ' || *b == '\t' || *b == '\n') |
| @@ -621,7 +621,7 @@ applymoves_error: | |||
| 621 | } | 621 | } |
| 622 | 622 | ||
| 623 | trans_t | 623 | trans_t |
| 624 | cube_readtrans(char *buf) | 624 | cube_readtrans(const char *buf) |
| 625 | { | 625 | { |
| 626 | trans_t t; | 626 | trans_t t; |
| 627 | 627 | ||
| @@ -34,11 +34,11 @@ cube_t cube_transform(cube_t, trans_t); | |||
| 34 | int64_t cube_coord_co(cube_t); | 34 | int64_t cube_coord_co(cube_t); |
| 35 | int64_t cube_coord_eo(cube_t); | 35 | int64_t cube_coord_eo(cube_t); |
| 36 | 36 | ||
| 37 | cube_t cube_read(char *format, char *buf); | 37 | cube_t cube_read(const char *format, const char *buf); |
| 38 | void cube_write(char *format, cube_t cube, char *buf); | 38 | void cube_write(const char *format, cube_t cube, char *buf); |
| 39 | int cube_readmoves(char *, move_t *); | 39 | int cube_readmoves(const char *, move_t *); |
| 40 | char *cube_movestr(move_t); | 40 | char *cube_movestr(move_t); |
| 41 | trans_t cube_readtrans(char *); | 41 | trans_t cube_readtrans(const char *); |
| 42 | char *cube_transstr(trans_t); | 42 | char *cube_transstr(trans_t); |
| 43 | move_t cube_inversemove(move_t); | 43 | move_t cube_inversemove(move_t); |
| 44 | trans_t cube_inversetrans(trans_t); | 44 | trans_t cube_inversetrans(trans_t); |
diff --git a/example/example.cpp b/example/example.cpp index 60c998f..c7ec982 100644 --- a/example/example.cpp +++ b/example/example.cpp | |||
| @@ -21,12 +21,12 @@ int main() { | |||
| 21 | char cstr[500]; | 21 | char cstr[500]; |
| 22 | 22 | ||
| 23 | std::cout << "The solved cube looks like this in H48 notation:\n"; | 23 | std::cout << "The solved cube looks like this in H48 notation:\n"; |
| 24 | cube_write((char *)"H48", cube, cstr); | 24 | cube_write("H48", cube, cstr); |
| 25 | std::string solvedstr(cstr); | 25 | std::string solvedstr(cstr); |
| 26 | std::cout << solvedstr << "\n"; | 26 | std::cout << solvedstr << "\n"; |
| 27 | std::cout << "After a sexy move it looks like this:\n"; | 27 | std::cout << "After a sexy move it looks like this:\n"; |
| 28 | cube = apply_alg(cube, moves); | 28 | cube = apply_alg(cube, moves); |
| 29 | cube_write((char *)"H48", cube, cstr); | 29 | cube_write("H48", cube, cstr); |
| 30 | std::string sexystr(cstr); | 30 | std::string sexystr(cstr); |
| 31 | std::cout << sexystr << "\n"; | 31 | std::cout << sexystr << "\n"; |
| 32 | 32 | ||
