security fix: replaced sprintf with snprintf
[xboard.git] / winboard / woptions.c
index 9460aa0..2913b68 100644 (file)
@@ -54,7 +54,7 @@ extern HINSTANCE hInst;          /* current instance */
 extern HWND hwndMain;            /* root window*/\r
 extern BOOLEAN alwaysOnTop;\r
 extern RECT boardRect;\r
-extern COLORREF lightSquareColor, darkSquareColor, whitePieceColor, \r
+extern COLORREF lightSquareColor, darkSquareColor, whitePieceColor,\r
   blackPieceColor, highlightSquareColor, premoveHighlightColor;\r
 extern HPALETTE hPal;\r
 extern BoardSize boardSize;\r
@@ -100,15 +100,15 @@ LRESULT CALLBACK SaveOptions(HWND, UINT, WPARAM, LPARAM);
 LRESULT CALLBACK TimeControl(HWND, UINT, WPARAM, LPARAM);\r
 VOID ChangeBoardSize(BoardSize newSize);\r
 VOID PaintSampleSquare(\r
-    HWND     hwnd, \r
-    int      ctrlid, \r
-    COLORREF squareColor, \r
+    HWND     hwnd,\r
+    int      ctrlid,\r
+    COLORREF squareColor,\r
     COLORREF pieceColor,\r
     COLORREF squareOutlineColor,\r
     COLORREF pieceDetailColor,\r
     BOOL     isWhitePiece,\r
     BOOL     isMono,\r
-    HBITMAP  pieces[3] \r
+    HBITMAP  pieces[3]\r
     );\r
 VOID PaintColorBlock(HWND hwnd, int ctrlid, COLORREF color);\r
 VOID SetBoardOptionEnables(HWND hDlg);\r
@@ -196,9 +196,9 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
                 appData.icsActive || !appData.noChessProgram);\r
     EnableWindow(GetDlgItem(hDlg, OPT_PonderNextMove),\r
                 !appData.noChessProgram);\r
-    EnableWindow(GetDlgItem(hDlg, OPT_PeriodicUpdates), \r
+    EnableWindow(GetDlgItem(hDlg, OPT_PeriodicUpdates),\r
                 !appData.noChessProgram && !appData.icsActive);\r
-    EnableWindow(GetDlgItem(hDlg, OPT_ShowThinking), \r
+    EnableWindow(GetDlgItem(hDlg, OPT_ShowThinking),\r
                 !appData.noChessProgram);\r
     return TRUE;\r
 \r
@@ -207,7 +207,7 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     switch (LOWORD(wParam)) {\r
     case IDOK:\r
       /* Read changed options from the dialog box */\r
-      \r
+\r
 #define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x))\r
 \r
       alwaysOnTop                  = IS_CHECKED(OPT_AlwaysOnTop);\r
@@ -250,7 +250,7 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        ClearHighlights();\r
        DrawPosition(FALSE, NULL);\r
       }\r
-      /* \r
+      /*\r
        * for some reason the redraw seems smoother when we invalidate\r
        * the board rect after the call to EndDialog()\r
        */\r
@@ -261,7 +261,7 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        InitDrawingSizes(boardSize, 0);\r
       } else if (oldShowButtonBar != appData.showButtonBar) {\r
        InitDrawingSizes(boardSize, 0);\r
-      } else if ((oldShowCoords != appData.showCoords) || \r
+      } else if ((oldShowCoords != appData.showCoords) ||\r
                 (oldBlindfold != appData.blindfold)) {\r
        InvalidateRect(hwndMain, &boardRect, FALSE);\r
       }\r
@@ -278,7 +278,7 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   return FALSE;\r
 }\r
 \r
-VOID \r
+VOID\r
 GeneralOptionsPopup(HWND hwnd)\r
 {\r
   FARPROC lpProc;\r
@@ -307,15 +307,15 @@ ChangeBoardSize(BoardSize newSize)
 \r
 VOID\r
 PaintSampleSquare(\r
-    HWND     hwnd, \r
-    int      ctrlid, \r
-    COLORREF squareColor, \r
+    HWND     hwnd,\r
+    int      ctrlid,\r
+    COLORREF squareColor,\r
     COLORREF pieceColor,\r
     COLORREF squareOutlineColor,\r
     COLORREF pieceDetailColor,\r
     BOOL     isWhitePiece,\r
     BOOL     isMono,\r
-    HBITMAP  pieces[3] \r
+    HBITMAP  pieces[3]\r
     )\r
 {\r
   HBRUSH  brushSquare;\r
@@ -358,15 +358,15 @@ PaintSampleSquare(
   brushPiece          = CreateSolidBrush(pieceColor);\r
   brushPieceDetail    = CreateSolidBrush(pieceDetailColor);\r
 \r
-  /* \r
-   * first draw the rectangle \r
+  /*\r
+   * first draw the rectangle\r
    */\r
   pen      = CreatePen(PS_SOLID, BORDER, squareOutlineColor);\r
   oldPen   = (HPEN)  SelectObject(hdcMem, pen);\r
   oldBrushSquare = (HBRUSH)SelectObject(hdcMem, brushSquare);\r
   Rectangle(hdcMem, rect.left, rect.top, rect.right, rect.bottom);\r
 \r
-  /* \r
+  /*\r
    * now draw the piece\r
    */\r
   if (isMono) {\r
@@ -378,23 +378,23 @@ PaintSampleSquare(
     if (isWhitePiece) {\r
       oldBitmapTemp = SelectObject(hdcTemp, pieces[WHITE]);\r
       oldBrushPiece = SelectObject(hdcMem, brushPiece);\r
-      BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, \r
+      BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,\r
             hdcTemp, 0, 0, 0x00B8074A);\r
       /* Use black for outline of white pieces */\r
       SelectObject(hdcTemp, pieces[OUTLINE]);\r
-      BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, \r
+      BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,\r
             hdcTemp, 0, 0, SRCAND);\r
     } else {\r
       /* Use square color for details of black pieces */\r
       oldBitmapTemp = SelectObject(hdcTemp, pieces[SOLID]);\r
       oldBrushPiece = SelectObject(hdcMem, brushPiece);\r
-      BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, \r
+      BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,\r
             hdcTemp, 0, 0, 0x00B8074A);\r
     }\r
     SelectObject(hdcMem, oldBrushPiece);\r
     SelectObject(hdcTemp, oldBitmapTemp);\r
   }\r
-  /* \r
+  /*\r
    * copy the memory dc to the screen\r
    */\r
   SelectObject(hdcMem, bufferBitmap);\r
@@ -403,7 +403,7 @@ PaintSampleSquare(
         rect.bottom - rect.top,\r
         hdcMem, rect.left, rect.top, SRCCOPY);\r
   SelectObject(hdcMem, oldBitmapMem);\r
-  /* \r
+  /*\r
    * clean up\r
    */\r
   SelectObject(hdcMem, oldBrushPiece);\r
@@ -466,7 +466,7 @@ SetBoardOptionEnables(HWND hDlg)
   }\r
 }\r
 \r
-BoardSize \r
+BoardSize\r
 BoardOptionsWhichRadio(HWND hDlg)\r
 {\r
   return (IsDlgButtonChecked(hDlg, OPT_SizeTiny) ? SizeTiny :\r
@@ -572,7 +572,7 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     pieces[0] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "s");\r
     pieces[1] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "w");\r
     pieces[2] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "o");\r
-       \r
+\r
     lsc = lightSquareColor;\r
     dsc = darkSquareColor;\r
     wpc = whitePieceColor;\r
@@ -604,7 +604,7 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   case WM_COMMAND: /* message: received a command */\r
     switch (LOWORD(wParam)) {\r
     case IDOK:\r
-      /* \r
+      /*\r
        * if we call EndDialog() after the call to ChangeBoardSize(),\r
        * then ChangeBoardSize() does not take effect, although the new\r
        * boardSize is saved. Go figure...\r
@@ -657,42 +657,42 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       return TRUE;\r
 \r
     case OPT_ChooseLightSquareColor:\r
-      if (ChangeColor(hDlg, &lsc)) \r
+      if (ChangeColor(hDlg, &lsc))\r
        PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);\r
        PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,\r
            TRUE, mono, pieces);\r
       break;\r
 \r
     case OPT_ChooseDarkSquareColor:\r
-      if (ChangeColor(hDlg, &dsc)) \r
+      if (ChangeColor(hDlg, &dsc))\r
        PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc);\r
        PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,\r
            FALSE, mono, pieces);\r
       break;\r
 \r
     case OPT_ChooseWhitePieceColor:\r
-      if (ChangeColor(hDlg, &wpc)) \r
+      if (ChangeColor(hDlg, &wpc))\r
        PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc);\r
        PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,\r
            TRUE, mono, pieces);\r
       break;\r
 \r
     case OPT_ChooseBlackPieceColor:\r
-      if (ChangeColor(hDlg, &bpc)) \r
+      if (ChangeColor(hDlg, &bpc))\r
        PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc);\r
        PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,\r
            FALSE, mono, pieces);\r
       break;\r
 \r
     case OPT_ChooseHighlightSquareColor:\r
-      if (ChangeColor(hDlg, &hsc)) \r
+      if (ChangeColor(hDlg, &hsc))\r
        PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc);\r
        PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,\r
            TRUE, mono, pieces);\r
       break;\r
 \r
     case OPT_ChoosePremoveHighlightColor:\r
-      if (ChangeColor(hDlg, &phc)) \r
+      if (ChangeColor(hDlg, &phc))\r
        PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc);\r
        PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,\r
            FALSE, mono, pieces);\r
@@ -908,7 +908,7 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   case WM_COMMAND: /* message: received a command */\r
     switch (LOWORD(wParam)) {\r
     case IDOK:\r
-      /* \r
+      /*\r
        * if we call EndDialog() after the call to ChangeBoardSize(),\r
        * then ChangeBoardSize() does not take effect, although the new\r
        * boardSize is saved. Go figure...\r
@@ -916,16 +916,17 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       EndDialog(hDlg, TRUE);\r
 \r
       v = VariantWhichRadio(hDlg);\r
-      if(!appData.noChessProgram) { char *name = VariantName(v), buf[MSG_SIZ];\r
+      if(!appData.noChessProgram) {\r
+       char *name = VariantName(v), buf[MSG_SIZ];\r
        if (first.protocolVersion > 1 && StrStr(first.variants, name) == NULL) {\r
-           /* [HGM] in protocol 2 we check if variant is suported by engine */\r
-           sprintf(buf, _("Variant %s not supported by %s"), name, first.tidy);\r
-           DisplayError(buf, 0);\r
-           return TRUE; /* treat as _("Cancel") if first engine does not support it */\r
+         /* [HGM] in protocol 2 we check if variant is suported by engine */\r
+         snprintf(buf, MSG_SIZ, _("Variant %s not supported by %s"), name, first.tidy);\r
+         DisplayError(buf, 0);\r
+         return TRUE; /* treat as _("Cancel") if first engine does not support it */\r
        } else\r
        if (second.initDone && second.protocolVersion > 1 && StrStr(second.variants, name) == NULL) {\r
-           sprintf(buf, _("Warning: second engine (%s) does not support this!"), second.tidy);\r
-           DisplayError(buf, 0);   /* use of second engine is optional; only warn user */\r
+         snprintf(buf, MSG_SIZ, r_("Warning: second engine (%s) does not support this!"), second.tidy);\r
+         DisplayError(buf, 0);   /* use of second engine is optional; only warn user */\r
        }\r
       }\r
 \r
@@ -1038,12 +1039,12 @@ UpdateSampleText(HWND hDlg, int id, MyColorizeAttribs *mca)
 {\r
   CHARFORMAT cf;\r
   cf.cbSize = sizeof(CHARFORMAT);\r
-  cf.dwMask = \r
+  cf.dwMask =\r
     CFM_COLOR|CFM_CHARSET|CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_STRIKEOUT|CFM_FACE|CFM_SIZE;\r
   cf.crTextColor = mca->color;\r
   cf.dwEffects = mca->effects;\r
   safeStrCpy(cf.szFaceName, font[boardSize][CONSOLE_FONT]->mfp.faceName, sizeof(cf.szFaceName)/sizeof(cf.szFaceName[0]) );\r
-  /* \r
+  /*\r
    * The 20.0 below is in fact documented. yHeight is expressed in twips.\r
    * A twip is 1/20 of a font's point size. See documentation of CHARFORMAT.\r
    * --msw\r
@@ -1075,8 +1076,8 @@ ColorizeTextDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     CheckDlgButton(hDlg, OPT_Strikeout, (mca.effects & CFE_STRIKEOUT) != 0);\r
 \r
     /* get the current background color from the parent window */\r
-    SendMessage(GetWindow(hDlg, GW_OWNER),WM_COMMAND, \r
-               (WPARAM)WM_USER_GetConsoleBackground, \r
+    SendMessage(GetWindow(hDlg, GW_OWNER),WM_COMMAND,\r
+               (WPARAM)WM_USER_GetConsoleBackground,\r
                (LPARAM)&background);\r
 \r
     /* set the background color */\r
@@ -1099,7 +1100,7 @@ ColorizeTextDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        cf.cbSize = sizeof(CHARFORMAT);\r
        cf.dwMask = CFM_COLOR;\r
        cf.crTextColor = mca.color;\r
-       SendDlgItemMessage(hwndConsole, OPT_ConsoleInput, \r
+       SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,\r
          EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);\r
       }\r
       EndDialog(hDlg, TRUE);\r
@@ -1203,7 +1204,7 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
 #undef CHECK_BOX\r
 \r
-    sprintf(buf, "%d", appData.icsAlarmTime / 1000);\r
+    snprintf(buf, MSG_SIZ, "%d", appData.icsAlarmTime / 1000);\r
     SetDlgItemText(hDlg, OPT_IcsAlarmTime, buf);\r
     SetDlgItemText(hDlg, OPT_PremoveWhiteText, appData.premoveWhiteText);\r
     SetDlgItemText(hDlg, OPT_PremoveBlackText, appData.premoveBlackText);\r
@@ -1248,7 +1249,7 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   case WM_COMMAND: /* message: received a command */\r
     switch (LOWORD(wParam)) {\r
 \r
-    case WM_USER_GetConsoleBackground: \r
+    case WM_USER_GetConsoleBackground:\r
       /* the ColorizeTextDialog needs the current background color */\r
       colorref = (COLORREF *)lParam;\r
       *colorref = cbc;\r
@@ -1313,20 +1314,20 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        cf.dwMask = CFM_COLOR;\r
        cf.crTextColor = ParseColorName(COLOR_NORMAL);\r
 \r
-       SendDlgItemMessage(hwndConsole, OPT_ConsoleInput, \r
+       SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,\r
          EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);\r
-        SendDlgItemMessage(hwndConsole, OPT_ConsoleText, \r
+        SendDlgItemMessage(hwndConsole, OPT_ConsoleText,\r
          EM_SETBKGNDCOLOR, FALSE, background);\r
-       SendDlgItemMessage(hwndConsole, OPT_ConsoleInput, \r
+       SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,\r
          EM_SETBKGNDCOLOR, FALSE, background);\r
       }\r
 \r
       if (cbc != consoleBackgroundColor) {\r
        consoleBackgroundColor = cbc;\r
        if (appData.colorize) {\r
-         SendDlgItemMessage(hwndConsole, OPT_ConsoleText, \r
+         SendDlgItemMessage(hwndConsole, OPT_ConsoleText,\r
            EM_SETBKGNDCOLOR, FALSE, consoleBackgroundColor);\r
-         SendDlgItemMessage(hwndConsole, OPT_ConsoleInput, \r
+         SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,\r
            EM_SETBKGNDCOLOR, FALSE, consoleBackgroundColor);\r
        }\r
       }\r
@@ -1355,7 +1356,7 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
     case OPT_ChooseChannel1Color:\r
       ColorizeTextPopup(hDlg, ColorChannel1);\r
-      UpdateSampleText(hDlg, OPT_SampleChannel1, \r
+      UpdateSampleText(hDlg, OPT_SampleChannel1,\r
                       &colorizeAttribs[ColorChannel1]);\r
       break;\r
 \r
@@ -1411,7 +1412,7 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
     case OPT_DefaultColors:\r
       for (i=0; i < NColorClasses - 1; i++)\r
-       ParseAttribs(&mca[i].color, \r
+       ParseAttribs(&mca[i].color,\r
                     &mca[i].effects,\r
                     defaultTextAttribs[i]);\r
 \r
@@ -1476,21 +1477,21 @@ SetSampleFontText(HWND hwnd, int id, const MyFont *mf)
   POINT center;\r
   int len;\r
 \r
-  len = sprintf(buf, "%.0f pt. %s%s%s\n",\r
-               mf->mfp.pointSize, mf->mfp.faceName,\r
-               mf->mfp.bold ? " bold" : "",\r
-               mf->mfp.italic ? " italic" : "");\r
+  len = snprintf(buf, MSG_SIZ, "%.0f pt. %s%s%s\n",\r
+                mf->mfp.pointSize, mf->mfp.faceName,\r
+                mf->mfp.bold ? " bold" : "",\r
+                mf->mfp.italic ? " italic" : "");\r
   SetDlgItemText(hwnd, id, buf);\r
 \r
   hControl = GetDlgItem(hwnd, id);\r
   hdc = GetDC(hControl);\r
   SetMapMode(hdc, MM_TEXT);    /* 1 pixel == 1 logical unit */\r
   oldFont = SelectObject(hdc, mf->hf);\r
-  \r
+\r
   /* get number of logical units necessary to display font name */\r
   GetTextExtentPoint32(hdc, buf, len, &size);\r
 \r
-  /* calculate formatting rectangle in the rich edit control.  \r
+  /* calculate formatting rectangle in the rich edit control.\r
    * May be larger or smaller than the actual control.\r
    */\r
   GetClientRect(hControl, &rectClient);\r
@@ -1616,7 +1617,7 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
       if (commentDialog) {\r
        SendDlgItemMessage(commentDialog, OPT_CommentText,\r
-         WM_SETFONT, (WPARAM)font[boardSize][COMMENT_FONT]->hf, \r
+         WM_SETFONT, (WPARAM)font[boardSize][COMMENT_FONT]->hf,\r
          MAKELPARAM(TRUE, 0));\r
        GetClientRect(GetDlgItem(commentDialog, OPT_CommentText), &rect);\r
        InvalidateRect(commentDialog, &rect, TRUE);\r
@@ -1624,7 +1625,7 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
       if (editTagsDialog) {\r
        SendDlgItemMessage(editTagsDialog, OPT_TagsText,\r
-         WM_SETFONT, (WPARAM)font[boardSize][EDITTAGS_FONT]->hf, \r
+         WM_SETFONT, (WPARAM)font[boardSize][EDITTAGS_FONT]->hf,\r
          MAKELPARAM(TRUE, 0));\r
        GetClientRect(GetDlgItem(editTagsDialog, OPT_TagsText), &rect);\r
        InvalidateRect(editTagsDialog, &rect, TRUE);\r
@@ -1632,7 +1633,7 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
       if( moveHistoryDialog != NULL ) {\r
        SendDlgItemMessage(moveHistoryDialog, IDC_MoveHistory,\r
-         WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, \r
+         WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf,\r
          MAKELPARAM(TRUE, 0));\r
         SendMessage( moveHistoryDialog, WM_INITDIALOG, 0, 0 );\r
 //     InvalidateRect(editTagsDialog, NULL, TRUE); // [HGM] this ws improperly cloned?\r
@@ -1640,10 +1641,10 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
       if( engineOutputDialog != NULL ) {\r
        SendDlgItemMessage(engineOutputDialog, IDC_EngineMemo1,\r
-         WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, \r
+         WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf,\r
          MAKELPARAM(TRUE, 0));\r
        SendDlgItemMessage(engineOutputDialog, IDC_EngineMemo2,\r
-         WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, \r
+         WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf,\r
          MAKELPARAM(TRUE, 0));\r
       }\r
 \r
@@ -1796,7 +1797,7 @@ InitSoundCombo(HWND hwndCombo, SoundComboData *scd)
   while (scd->label) {\r
     err = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) T_(scd->label));\r
     if (err != cnt++) {\r
-      sprintf(buf, "InitSoundCombo(): err '%d', cnt '%d'\n",\r
+      snprintf(buf, MSG_SIZ,  "InitSoundCombo(): err '%d', cnt '%d'\n",\r
          (int)err, (int)cnt);\r
       MessageBox(NULL, buf, NULL, MB_OK);\r
     }\r
@@ -1857,7 +1858,7 @@ void
 DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name)\r
 {\r
   int radio;\r
-  /* \r
+  /*\r
    * I think it's best to clear the combo and edit boxes. It looks stupid\r
    * to have a value from another sound event sitting there grayed out.\r
    */\r
@@ -1883,7 +1884,7 @@ DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name)
       radio = OPT_NoSound;\r
     } else {\r
       radio = OPT_BuiltInSound;\r
-      if (SendMessage(hCombo, CB_SELECTSTRING, (WPARAM) -1, \r
+      if (SendMessage(hCombo, CB_SELECTSTRING, (WPARAM) -1,\r
                      (LPARAM) (name + 1)) == CB_ERR) {\r
        SendMessage(hCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);\r
        SendMessage(hCombo, WM_SETTEXT, (WPARAM) 0, (LPARAM) (name + 1));\r
@@ -1898,7 +1899,7 @@ DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name)
   SoundDialogSetEnables(hDlg, radio);\r
   CheckRadioButton(hDlg, OPT_NoSound, OPT_WavFile, radio);\r
 }\r
-    \r
+\r
 \r
 char *builtInSoundNames[] = BUILT_IN_SOUND_NAMES;\r
 \r
@@ -1940,16 +1941,16 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
   case WM_COMMAND: /* message: received a command */\r
 \r
-    if (((HWND)lParam == hSoundCombo) && \r
+    if (((HWND)lParam == hSoundCombo) &&\r
        (HIWORD(wParam) == CBN_SELCHANGE)) {\r
-      /* \r
+      /*\r
        * the user has selected a new sound event. We must store the name for\r
        * the previously selected event, then retrieve the name for the\r
-       * newly selected event and update the dialog. \r
+       * newly selected event and update the dialog.\r
        */\r
       radio = SoundDialogWhichRadio(hDlg);\r
       newName = strdup(SoundDialogGetName(hDlg, radio));\r
-      \r
+\r
       if (strcmp(newName, soundComboData[index].name) != 0) {\r
        free(soundComboData[index].name);\r
        soundComboData[index].name = newName;\r
@@ -1960,13 +1961,13 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       /* now get the settings for the newly selected event */\r
       index = SendMessage(hSoundCombo, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);\r
       DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name);\r
-      \r
+\r
       return TRUE;\r
     }\r
     switch (LOWORD(wParam)) {\r
     case IDOK:\r
-      /* \r
-       * save the name for the currently selected sound event \r
+      /*\r
+       * save the name for the currently selected sound event\r
        */\r
       radio = SoundDialogWhichRadio(hDlg);\r
       newName = strdup(SoundDialogGetName(hDlg, radio));\r
@@ -1990,7 +1991,7 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       }\r
       for ( cc = (ColorClass)0; cc < NColorClasses - 2; cc++) {\r
        index = (int)cc + (int)NSoundClasses;\r
-       if (strcmp(soundComboData[index].name, \r
+       if (strcmp(soundComboData[index].name,\r
                   textAttribs[cc].sound.name) != 0) {\r
          free(textAttribs[cc].sound.name);\r
          textAttribs[cc].sound.name = strdup(soundComboData[index].name);\r
@@ -2171,7 +2172,7 @@ VOID PrintCommSettings(FILE *f, char *name, DCB *dcb)
 {\r
   char *flow = "??", *parity = "??", *stopBits = "??";\r
   ComboData *cd;\r
-  \r
+\r
   cd = cdParity;\r
   while (cd->label != NULL) {\r
     if (dcb->Parity == cd->value) {\r
@@ -2261,7 +2262,7 @@ CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam,     LPARAM lParam)
 \r
     hwndCombo = GetDlgItem(hDlg, OPT_DataRate);\r
     InitCombo(hwndCombo, cdDataRate);\r
-    sprintf(buf, "%u", (int)dcb.BaudRate);\r
+    snprintf(buf, MSG_SIZ, "%u", (int)dcb.BaudRate);\r
     if (SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) buf) == CB_ERR) {\r
       SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);\r
       SendMessage(hwndCombo, WM_SETTEXT, (WPARAM) 0, (LPARAM) buf);\r
@@ -2367,7 +2368,7 @@ CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam,     LPARAM lParam)
       }\r
       if (!SetCommState(hCommPort, (LPDCB) &dcb)) {\r
        err = GetLastError();\r
-       switch(MessageBox(hDlg, \r
+       switch(MessageBox(hDlg,\r
                         "Failed to set comm port state;\r\ninvalid options?",\r
                         _("Option Error"), MB_ABORTRETRYIGNORE|MB_ICONQUESTION)) {\r
        case IDABORT:\r
@@ -2436,7 +2437,7 @@ LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     /* Initialize the dialog items */\r
     if (appData.timeDelay >= 0.0) {\r
       CheckDlgButton(hDlg, OPT_Autostep, TRUE);\r
-      sprintf(buf, "%.2g", appData.timeDelay);\r
+      snprintf(buf, MSG_SIZ, "%.2g", appData.timeDelay);\r
       SetDlgItemText(hDlg, OPT_ASTimeDelay, buf);\r
     } else {\r
       CheckDlgButton(hDlg, OPT_Autostep, FALSE);\r
@@ -2476,7 +2477,7 @@ LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 }\r
 \r
 \r
-VOID \r
+VOID\r
 LoadOptionsPopup(HWND hwnd)\r
 {\r
   FARPROC lpProc = MakeProcInstance((FARPROC)LoadOptions, hInst);\r
@@ -2584,9 +2585,9 @@ SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       return TRUE;\r
 \r
     case OPT_AVBrowse:\r
-      f = OpenFileDialog(hDlg, "a", NULL, \r
-                        appData.oldSaveStyle ? "gam" : "pgn", \r
-                        GAME_FILT, _("Browse for Auto Save File"), \r
+      f = OpenFileDialog(hDlg, "a", NULL,\r
+                        appData.oldSaveStyle ? "gam" : "pgn",\r
+                        GAME_FILT, _("Browse for Auto Save File"),\r
                         NULL, NULL, buf);\r
       if (f != NULL) {\r
        fclose(f);\r
@@ -2975,7 +2976,7 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM
 \r
     case IDC_BrowseForBook:\r
       {\r
-          char filter[] = { \r
+          char filter[] = {\r
               'A','l','l',' ','F','i','l','e','s', 0,\r
               '*','.','*', 0,\r
               'B','I','N',' ','F','i','l','e','s', 0,\r