exchanged some sprintf with snprintf
[xboard.git] / parser.l
index bdf11d0..29a2fa9 100755 (executable)
--- a/parser.l
+++ b/parser.l
@@ -9,8 +9,10 @@
  * parser.l -- lex parser of algebraic chess moves for XBoard\r
  * $Id: parser.l,v 2.1 2003/10/27 19:21:00 mann Exp $\r
  *\r
- * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.\r
- * Enhancements Copyright 1992-95 Free Software Foundation, Inc.\r
+ * Copyright 1991 by Digital Equipment Corporation, Maynard,\r
+ * Massachusetts.  Enhancements Copyright\r
+ * 1992-2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software\r
+ * Foundation, Inc.\r
  *\r
  * The following terms apply to Digital Equipment Corporation's copyright\r
  * interest in XBoard:\r
  * SOFTWARE.\r
  * ------------------------------------------------------------------------\r
  *\r
- * The following terms apply to the enhanced version of XBoard distributed\r
- * by the Free Software Foundation:\r
+ * The following terms apply to the enhanced version of XBoard\r
+ * distributed by the Free Software Foundation:\r
  * ------------------------------------------------------------------------\r
- * This program is free software; you can redistribute it and/or modify\r
+ *\r
+ * GNU XBoard is free software: you can redistribute it and/or modify\r
  * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
+ * the Free Software Foundation, either version 3 of the License, or (at\r
+ * your option) any later version.\r
  *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
+ * GNU XBoard is distributed in the hope that it will be useful, but\r
+ * WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * General Public License for more details.\r
  *\r
  * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
- * ------------------------------------------------------------------------\r
- */\r
+ * along with this program. If not, see http://www.gnu.org/licenses/.  \r
+ *\r
+ *------------------------------------------------------------------------\r
+ ** See the file ChangeLog for a revision history.  */\r
 \r
 /* This parser handles all forms of promotion.\r
  * The parser resolves ambiguous moves by searching and check-testing.\r
@@ -240,7 +243,8 @@ extern void CopyBoard P((Board to, Board from));
       return (int) IllegalMove;\r
 \r
     result = LegalityTest(boards[yyboardindex],\r
-                         PosFlags(yyboardindex), EP_UNKNOWN,\r
+                         PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: might think we can e.p.!\r
+                         EP_UNKNOWN,\r
                           initialRights, /* [HGM] assume all castlings allowed */\r
                           currentMoveString[1] - ONE,\r
                           currentMoveString[0] - AAA,\r
@@ -301,7 +305,8 @@ extern void CopyBoard P((Board to, Board from));
       return 0;\r
 \r
     result = LegalityTest(boards[yyboardindex],\r
-                         PosFlags(yyboardindex), EP_UNKNOWN,\r
+                         PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: might think we can e.p.!\r
+                         EP_UNKNOWN,\r
                           initialRights, /* [HGM] assume all castlings allowed */\r
                           currentMoveString[1] - ONE,\r
                           currentMoveString[0] - AAA,\r
@@ -482,7 +487,8 @@ extern void CopyBoard P((Board to, Board from));
     }\r
 \r
     result = LegalityTest(boards[yyboardindex],\r
-                         PosFlags(yyboardindex), EP_UNKNOWN,\r
+                         PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: might think we can e.p.!\r
+                         EP_UNKNOWN,\r
                           initialRights, /* [HGM] assume all castlings allowed */\r
                           currentMoveString[1] - ONE,\r
                           currentMoveString[0] - AAA,\r
@@ -522,7 +528,8 @@ extern void CopyBoard P((Board to, Board from));
     }\r
 \r
     result = LegalityTest(boards[yyboardindex],\r
-                         PosFlags(yyboardindex), EP_UNKNOWN,\r
+                         PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: might think we can e.p.!\r
+                         EP_UNKNOWN,\r
                           initialRights, /* [HGM] assume all castlings allowed */\r
                           currentMoveString[1] - ONE,\r
                           currentMoveString[0] - AAA,\r
@@ -703,7 +710,8 @@ extern void CopyBoard P((Board to, Board from));
         fprintf(debugFP, "long castling %d %d\n", ff, ft);\r
     }\r
     return (int) LegalityTest(boards[yyboardindex],\r
-                             PosFlags(yyboardindex), EP_UNKNOWN,\r
+                             PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: e.p.!\r
+                             EP_UNKNOWN,\r
                               castlingRights[yyboardindex], /* [HGM] use true castling rights */\r
                              rf, ff, rt, ft, NULLCHAR);\r
 }\r
@@ -759,7 +767,8 @@ extern void CopyBoard P((Board to, Board from));
     }\r
 \r
     return (int) LegalityTest(boards[yyboardindex],\r
-                              PosFlags(yyboardindex), EP_UNKNOWN,\r
+                             PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: e.p.!\r
+                             EP_UNKNOWN,\r
                               castlingRights[yyboardindex], /* [HGM] use true castling rights */\r
                              rf, ff, rt, ft, NULLCHAR);\r
 }\r