From 9425e9191c5314b28d5f93b11c0ea63d83e33a30 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Mon, 24 Apr 2006 12:09:11 -0400 Subject: [PATCH] libchess: When there is no promotion piece in the move text, promote to queen. --- libchess/move.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libchess/move.c b/libchess/move.c index 92795e8..ce281b7 100644 --- a/libchess/move.c +++ b/libchess/move.c @@ -1057,6 +1057,9 @@ capture: *bp++ = INTTOFILE(file); *bp++ = INTTORANK(rank); + if (p == PAWN && !promo && (rank == 8 || rank == 1)) + promo = pgn_piece_to_int('q'); + /* * [Pf][fr][x]fr[=P] */ @@ -1135,7 +1138,7 @@ again: while (!isdigit(*--p) && *p != 'O') { if (*p == '=') { - promo = toupper(pgn_piece_to_int(i)); + promo = pgn_piece_to_int(i); i = 0; break; } @@ -1205,6 +1208,13 @@ again: if (find_source_square(*g, b, PAWN, &sfile, &srank, file, rank) != 1) return E_PGN_INVALID; + + if (!promo && (rank == 8 || rank == 1)) { + promo = pgn_piece_to_int('q'); + *p++ = '='; + *p++ = pgn_int_to_piece(WHITE, promo); + *p = 0; + } } /* Not a pawn. */ else { -- 2.11.4.GIT