Fix bug in parsing illegal Pawn captures
authorH.G. Muller <h.g.muller@hccnet.nl>
Sat, 6 Nov 2010 18:55:31 +0000 (19:55 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Tue, 9 Nov 2010 14:01:32 +0000 (15:01 +0100)
When a pawn move of type exf5 was illegal, the parser made an attempt to
interpret it as e.p. capture of f5. This, however, messed up the move,
so that it was now permanently mistaken for e5xf6. Even in cases with
legality testing off, where you would want the original move to be
accepted despite the fact that it was illegal.

parser.l

index 96a9e8b..ac66581 100644 (file)
--- a/parser.l
+++ b/parser.l
@@ -584,8 +584,12 @@ extern void CopyBoard P((Board to, Board from));
 
     if (result == WhiteCapturesEnPassant || result == BlackCapturesEnPassant)
       return (int) result;
-    else
+    else { // [HGM] all very nice, but this messed up the input move that we might want to accept with legality testing off...
+      if (WhiteOnMove(yyboardindex)) // undo the damage
+            currentMoveString[1]--,  currentMoveString[3]--;
+       else currentMoveString[1]++,  currentMoveString[3]++;
       return (int) IllegalMove;
+    }
 }
 
 "+"?[A-Z][xX:-]?[a-l][0-9]((=?\(?[A-Z]\)?)|[=+])?  {