commit ba4e25810e0b845fe0488bc504bf3ab5bd1f3824
parent 59ecc0ee72a180692fcccab88db310d60021f2ab
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Mon, 15 Apr 2024 16:07:52 +0200
const char *
Diffstat:
3 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/cube.c b/cube.c
@@ -31,13 +31,13 @@
_static_inline cube_t invertco(cube_t);
_static int permsign(uint8_t *, int);
-_static uint8_t readco(char *);
-_static uint8_t readcp(char *);
-_static uint8_t readeo(char *);
-_static uint8_t readep(char *);
-_static cube_t read_H48(char *);
-_static uint8_t readpiece_LST(char **);
-_static cube_t read_LST(char *);
+_static uint8_t readco(const char *);
+_static uint8_t readcp(const char *);
+_static uint8_t readeo(const char *);
+_static uint8_t readep(const char *);
+_static cube_t read_H48(const char *);
+_static uint8_t readpiece_LST(const char **);
+_static cube_t read_LST(const char *);
_static int writepiece_LST(uint8_t, char *);
_static void write_H48(cube_t, char *);
_static void write_LST(cube_t, char *);
@@ -45,7 +45,7 @@ _static uint8_t readmove(char);
_static uint8_t readmodifier(char);
_static uint8_t
-readco(char *str)
+readco(const char *str)
{
if (*str == '0')
return 0;
@@ -59,7 +59,7 @@ readco(char *str)
}
_static uint8_t
-readcp(char *str)
+readcp(const char *str)
{
uint8_t c;
@@ -73,7 +73,7 @@ readcp(char *str)
}
_static uint8_t
-readeo(char *str)
+readeo(const char *str)
{
if (*str == '0')
return 0;
@@ -85,7 +85,7 @@ readeo(char *str)
}
_static uint8_t
-readep(char *str)
+readep(const char *str)
{
uint8_t e;
@@ -98,12 +98,12 @@ readep(char *str)
}
_static cube_t
-read_H48(char *buf)
+read_H48(const char *buf)
{
int i;
uint8_t piece, orient;
cube_t ret = {0};
- char *b;
+ const char *b;
b = buf;
@@ -134,7 +134,7 @@ read_H48(char *buf)
}
_static uint8_t
-readpiece_LST(char **b)
+readpiece_LST(const char **b)
{
uint8_t ret;
bool read;
@@ -151,7 +151,7 @@ readpiece_LST(char **b)
}
_static cube_t
-read_LST(char *buf)
+read_LST(const char *buf)
{
int i;
cube_t ret = {0};
@@ -547,7 +547,7 @@ cube_coord_eo(cube_t c)
}
cube_t
-cube_read(char *format, char *buf)
+cube_read(const char *format, const char *buf)
{
cube_t cube;
@@ -564,7 +564,7 @@ cube_read(char *format, char *buf)
}
void
-cube_write(char *format, cube_t cube, char *buf)
+cube_write(const char *format, cube_t cube, char *buf)
{
char *errormsg;
size_t len;
@@ -594,11 +594,11 @@ write_error:
}
int
-cube_readmoves(char *buf, move_t *ret)
+cube_readmoves(const char *buf, move_t *ret)
{
int n;
move_t r, m;
- char *b;
+ const char *b;
for (n = 0, b = buf; *b != '\0'; b++) {
while (*b == ' ' || *b == '\t' || *b == '\n')
@@ -621,7 +621,7 @@ applymoves_error:
}
trans_t
-cube_readtrans(char *buf)
+cube_readtrans(const char *buf)
{
trans_t t;
diff --git a/cube.h b/cube.h
@@ -34,11 +34,11 @@ cube_t cube_transform(cube_t, trans_t);
int64_t cube_coord_co(cube_t);
int64_t cube_coord_eo(cube_t);
-cube_t cube_read(char *format, char *buf);
-void cube_write(char *format, cube_t cube, char *buf);
-int cube_readmoves(char *, move_t *);
+cube_t cube_read(const char *format, const char *buf);
+void cube_write(const char *format, cube_t cube, char *buf);
+int cube_readmoves(const char *, move_t *);
char *cube_movestr(move_t);
-trans_t cube_readtrans(char *);
+trans_t cube_readtrans(const char *);
char *cube_transstr(trans_t);
move_t cube_inversemove(move_t);
trans_t cube_inversetrans(trans_t);
diff --git a/example/example.cpp b/example/example.cpp
@@ -21,12 +21,12 @@ int main() {
char cstr[500];
std::cout << "The solved cube looks like this in H48 notation:\n";
- cube_write((char *)"H48", cube, cstr);
+ cube_write("H48", cube, cstr);
std::string solvedstr(cstr);
std::cout << solvedstr << "\n";
std::cout << "After a sexy move it looks like this:\n";
cube = apply_alg(cube, moves);
- cube_write((char *)"H48", cube, cstr);
+ cube_write("H48", cube, cstr);
std::string sexystr(cstr);
std::cout << sexystr << "\n";