prevent buffer overflow
[xboard.git] / winboard / jaws.c
index 9d8ec9c..a9cfd7f 100644 (file)
 \r
 extern long whiteTimeRemaining, blackTimeRemaining, timeControl, timeIncrement;\r
 \r
-#if 0\r
-// from moves.h, but no longer needed, as the new routines are all moved to winboard.c\r
-\r
-extern char* PieceToName P((ChessSquare p, int i));\r
-extern char* SquareToChar P((int Xpos)); \r
-extern char* SquareToNum P((int Ypos));\r
-extern int CoordToNum P((char c));\r
-\r
-#endif\r
-\r
 // from moves.c, added WinBoard_F piece types and ranks / files\r
 \r
 char *squareToChar[] = { "ay", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l" };\r
@@ -172,7 +162,7 @@ PSAYSTRING RealSayString;
 \r
 VOID SayString(char *mess, BOOL flag)\r
 { // for debug file\r
-       char buf[MSG_SIZ], *p;\r
+       char buf[8000], *p;\r
        if(appData.debugMode) fprintf(debugFP, "SAY '%s'\n", mess);\r
        strcpy(buf, mess);\r
        if(p = StrCaseStr(buf, "Xboard adjudication:")) {\r
@@ -239,7 +229,6 @@ AdaptMenu()
 \r
        helpMenuInfo.cbSize = sizeof(helpMenuInfo);\r
        menuMain = GetMenu(hwndMain);\r
-       if(appData.debugMode) fprintf(debugFP, "hwndMain: %8x %8x\n", hwndMain, menuMain);\r
        menuJAWS = CreatePopupMenu();\r
        \r
        for(i=0; menuItemJAWS[i].name; i++) {\r
@@ -1133,9 +1122,10 @@ KeyboardMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
                                (BlackPawn <= pdown && pdown <= BlackKing &&\r
                                 BlackPawn <= pup && pup <= BlackKing))) {\r
                        /* EditPosition, empty square, or different color piece;\r
-                       click-click move is possible */\r
+                       click-click move is possible */         \r
+                       char promoChoice = NULLCHAR;\r
                \r
-                       if (IsPromotion(oldFromX, oldFromY, fromX, fromY)) {\r
+                       if (HasPromotionChoice(oldFromX, oldFromY, fromX, fromY, &promoChoice)) {\r
                                if (appData.alwaysPromoteToQueen) {\r
                                        UserMoveEvent(oldFromX, oldFromY, fromX, fromY, 'q');\r
                                }\r
@@ -1146,7 +1136,7 @@ KeyboardMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
                                }       \r
                        }\r
                        else {\r
-                               UserMoveEvent(oldFromX, oldFromY, fromX, fromY, NULLCHAR);\r
+                               UserMoveEvent(oldFromX, oldFromY, fromX, fromY, promoChoice);\r
                        }\r
                oldFromX = oldFromY = -1;\r
                break;\r