summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <alx.manpages@gmail.com>2022-01-30 20:37:27 +0100
committerAlejandro Colomar <alx.manpages@gmail.com>2022-01-30 20:37:27 +0100
commitb495fed89f9990984373cc068783f97900e035c1 (patch)
treedd2a9b9b18ee115e87b5beebc9f7ab9545dd1b28
parent3cbee51d0efbadcc6911a9388ffe8530b4a141e4 (diff)
io/chess.c: Fix minor bug
Fail instead of ignoring spurious characters between origin and target. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
-rw-r--r--src/lib/io/chess.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lib/io/chess.c b/src/lib/io/chess.c
index 7c632e5..9bd7c31 100644
--- a/src/lib/io/chess.c
+++ b/src/lib/io/chess.c
@@ -85,7 +85,9 @@ int chess_read_mv(char *s, struct chess_mv *mv)
mv->mv.piece = chess_is_piece(*s) ? *s++ : '?';
mv->mv.x0 = ('a' <= *s && *s <= 'h') ? (*s++ - 'a') : '?';
mv->mv.y0 = ('1' <= *s && *s <= '8') ? ('8' - *s++) : '?';
- mv->capture = (*s++ == 'x');
+ mv->capture = (*s == 'x');
+ if (mv->capture)
+ s++;
return strlen(s);
}