if (!ParseTimeControl(appData.timeControl, appData.timeIncrement,\r
appData.movesPerSession)) {\r
char buf[MSG_SIZ];\r
- sprintf(buf, _("bad timeControl option %s"), appData.timeControl);\r
+ snprintf(buf, sizeof(buf), _("bad timeControl option %s"), appData.timeControl);\r
DisplayFatalError(buf, 0, 2);\r
}\r
\r
searchTime = min * 60 + sec;\r
} else {\r
char buf[MSG_SIZ];\r
- sprintf(buf, _("bad searchTime option %s"), appData.searchTime);\r
+ snprintf(buf, sizeof(buf), _("bad searchTime option %s"), appData.searchTime);\r
DisplayFatalError(buf, 0, 2);\r
}\r
}\r
sprintf(buf, _("Could not open comm port %s"), \r
appData.icsCommPort);\r
} else {\r
- sprintf(buf, _("Could not connect to host %s, port %s"), \r
+ snprintf(buf, sizeof(buf), _("Could not connect to host %s, port %s"), \r
appData.icsHost, appData.icsPort);\r
}\r
DisplayFatalError(buf, err, 1);\r
} else if (*appData.gateway != NULLCHAR) {\r
if (*appData.remoteShell == NULLCHAR) {\r
/* Use the rcmd protocol to run telnet program on a gateway host */\r
- sprintf(buf, "%s %s %s",\r
+ snprintf(buf, sizeof(buf), "%s %s %s",\r
appData.telnetProgram, appData.icsHost, appData.icsPort);\r
return OpenRcmd(appData.gateway, appData.remoteUser, buf, &icsPR);\r
\r
} else {\r
/* Use the rsh program to run telnet program on a gateway host */\r
if (*appData.remoteUser == NULLCHAR) {\r
- sprintf(buf, "%s %s %s %s %s", appData.remoteShell,\r
+ snprintf(buf, sizeof(buf), "%s %s %s %s %s", appData.remoteShell,\r
appData.gateway, appData.telnetProgram,\r
appData.icsHost, appData.icsPort);\r
} else {\r
- sprintf(buf, "%s %s -l %s %s %s %s",\r
+ snprintf(buf, sizeof(buf), "%s %s -l %s %s %s %s",\r
appData.remoteShell, appData.gateway, \r
appData.remoteUser, appData.telnetProgram,\r
appData.icsHost, appData.icsPort);\r
\r
if (loggedOn && !have_set_title && ics_handle[0] != NULLCHAR) {\r
char buf[MSG_SIZ];\r
- sprintf(buf, "%s@%s", ics_handle, appData.icsHost);\r
+ snprintf(buf, sizeof(buf), "%s@%s", ics_handle, appData.icsHost);\r
DisplayIcsInteractionTitle(buf);\r
have_set_title = TRUE;\r
}\r
&ticking);\r
\r
if (n < 21) {\r
- sprintf(str, _("Failed to parse board string:\n\"%s\""), string);\r
+ snprintf(str, sizeof(str), _("Failed to parse board string:\n\"%s\""), string);\r
DisplayError(str, 0);\r
return;\r
}\r
if (!strncmp(message, "tellopponent ", 13)) {\r
if (appData.icsActive) {\r
if (loggedOn) {\r
- sprintf(buf1, "%ssay %s\n", ics_prefix, message + 13);\r
+ snprintf(buf1, sizeof(buf1), "%ssay %s\n", ics_prefix, message + 13);\r
SendToICS(buf1);\r
}\r
} else {\r
if (!strncmp(message, "tellothers ", 11)) {\r
if (appData.icsActive) {\r
if (loggedOn) {\r
- sprintf(buf1, "%swhisper %s\n", ics_prefix, message + 11);\r
+ snprintf(buf1, sizeof(buf1), "%swhisper %s\n", ics_prefix, message + 11);\r
SendToICS(buf1);\r
}\r
}\r
if (!strncmp(message, "tellall ", 8)) {\r
if (appData.icsActive) {\r
if (loggedOn) {\r
- sprintf(buf1, "%skibitz %s\n", ics_prefix, message + 8);\r
+ snprintf(buf1, sizeof(buf1), "%skibitz %s\n", ics_prefix, message + 8);\r
SendToICS(buf1);\r
}\r
} else {\r
|| (StrStr(message, "Permission denied") != NULL)) {\r
\r
cps->maybeThinking = FALSE;\r
- sprintf(buf1, _("Failed to start %s chess program %s on %s: %s\n"),\r
+ snprintf(buf1, sizeof(buf1), _("Failed to start %s chess program %s on %s: %s\n"),\r
cps->which, cps->program, cps->host, message);\r
RemoveInputSource(cps->isr);\r
DisplayFatalError(buf1, 0, 1);\r
(void) CoordsToAlgebraic(boards[forwardMostMove],\r
PosFlags(forwardMostMove), EP_UNKNOWN,\r
fromY, fromX, toY, toX, promoChar, buf1);\r
- sprintf(buf2, _("Hint: %s"), buf1);\r
+ snprintf(buf2, sizeof(buf2), _("Hint: %s"), buf1);\r
DisplayInformation(buf2);\r
} else {\r
/* Hint move could not be parsed!? */\r
- sprintf(buf2,\r
+ snprintf(buf2, sizeof(buf2),\r
_("Illegal hint move \"%s\"\nfrom %s chess program"),\r
buf1, cps->which);\r
DisplayError(buf2, 0);\r
}\r
\r
if (cps->sendICS) {\r
- sprintf(buf, "ics %s\n", appData.icsActive ? appData.icsHost : "-");\r
+ snprintf(buf, sizeof(buf), "ics %s\n", appData.icsActive ? appData.icsHost : "-");\r
SendToProgram(buf, cps);\r
}\r
cps->maybeThinking = FALSE;\r
err = OpenRcmd(cps->host, appData.remoteUser, cps->program, &cps->pr);\r
} else {\r
if (*appData.remoteUser == NULLCHAR) {\r
- sprintf(buf, "%s %s %s", appData.remoteShell, cps->host,\r
+ snprintf(buf, sizeof(buf), "%s %s %s", appData.remoteShell, cps->host,\r
cps->program);\r
} else {\r
- sprintf(buf, "%s %s -l %s %s", appData.remoteShell,\r
+ snprintf(buf, sizeof(buf), "%s %s -l %s %s", appData.remoteShell,\r
cps->host, appData.remoteUser, cps->program);\r
}\r
err = StartChildProcess(buf, "", &cps->pr);\r
} else {\r
f = fopen(filename, "rb");\r
if (f == NULL) {\r
- sprintf(buf, _("Can't open \"%s\""), filename);\r
+ snprintf(buf, sizeof(buf), _("Can't open \"%s\""), filename);\r
DisplayError(buf, errno);\r
return FALSE;\r
}\r
yynewfile(f);\r
\r
if (lg && lg->gameInfo.white && lg->gameInfo.black) {\r
- sprintf(buf, "%s vs. %s", lg->gameInfo.white,\r
+ snprintf(buf, sizeof(buf), "%s vs. %s", lg->gameInfo.white,\r
lg->gameInfo.black);\r
DisplayTitle(buf);\r
} else if (*title != NULLCHAR) {\r
} else {\r
f = fopen(filename, "rb");\r
if (f == NULL) {\r
- sprintf(buf, _("Can't open \"%s\""), filename);\r
+ snprintf(buf, sizeof(buf), _("Can't open \"%s\""), filename);\r
DisplayError(buf, errno);\r
return FALSE;\r
} else {\r
} else {\r
f = fopen(filename, append ? "a" : "w");\r
if (f == NULL) {\r
- sprintf(buf, _("Can't open \"%s\""), filename);\r
+ snprintf(buf, sizeof(buf), _("Can't open \"%s\""), filename);\r
DisplayError(buf, errno);\r
return FALSE;\r
} else {\r
} else {\r
f = fopen(filename, "a");\r
if (f == NULL) {\r
- sprintf(buf, _("Can't open \"%s\""), filename);\r
+ snprintf(buf, sizeof(buf), _("Can't open \"%s\""), filename);\r
DisplayError(buf, errno);\r
return FALSE;\r
} else {\r
{
char buf[MSG_SIZ];
XSetWMProtocols(xDisplay, XtWindow(w), &wm_delete_window, 1);
- sprintf(buf, "<Message>WM_PROTOCOLS: %s() \n", procname);
+ snprintf(buf, sizeof(buf), "<Message>WM_PROTOCOLS: %s() \n", procname);
XtAugmentTranslations(w, XtParseTranslationTable(buf));
}
i = strlen(p) + strlen("/.xboardXXXXXx.pgn") + 1;
gameCopyFilename = (char*) malloc(i);
gamePasteFilename = (char*) malloc(i);
- sprintf(gameCopyFilename, "%s/.xboard%05uc.pgn", p, getpid());
- sprintf(gamePasteFilename, "%s/.xboard%05up.pgn", p, getpid());
+ snprintf(gameCopyFilename,i, "%s/.xboard%05uc.pgn", p, getpid());
+ snprintf(gamePasteFilename,i, "%s/.xboard%05up.pgn", p, getpid());
XtGetApplicationResources(shellWidget, (XtPointer) &appData,
clientResources, XtNumber(clientResources),
fprintf(stderr, "%d", piece+1);
for (kind=0; kind<4; kind++) {
fprintf(stderr, ".");
- sprintf(buf, "%s/%c%s%u.xim",
+ snprintf(buf, sizeof(buf), "%s/%c%s%u.xim",
ExpandPathName(appData.pixmapDirectory),
ToLower(PieceToChar((ChessSquare)piece)),
ximkind[kind], ss);
/* Load light and dark squares */
/* If the LSQ and DSQ pieces don't exist, we will
draw them with solid squares. */
- sprintf(buf, "%s/lsq%u.xim", ExpandPathName(appData.pixmapDirectory), ss);
+ snprintf(buf,sizeof(buf), "%s/lsq%u.xim", ExpandPathName(appData.pixmapDirectory), ss);
if (access(buf, 0) != 0) {
useImageSqs = 0;
} else {
loadXIM(ximLightSquare, NULL, buf, &xpmLightSquare, NULL);
fprintf(stderr, _("dark square "));
- sprintf(buf, "%s/dsq%u.xim",
+ snprintf(buf,sizeof(buf), "%s/dsq%u.xim",
ExpandPathName(appData.pixmapDirectory), ss);
if (appData.debugMode)
fprintf(stderr, _("(File:%s:) "), buf);
for (piece = (int) WhitePawn; piece <= (int) WhiteKing; piece++) {
fprintf(stderr, "%d ", piece+1);
for (kind=0; kind<4; kind++) {
- sprintf(buf, "%s/%c%s%u.xpm",
+ snprintf(buf, sizeof(buf), "%s/%c%s%u.xpm",
ExpandPathName(appData.pixmapDirectory),
ToLower(PieceToChar((ChessSquare)piece)),
xpmkind[kind], ss);
/* If the LSQ and DSQ pieces don't exist, we will
draw them with solid squares. */
fprintf(stderr, _("light square "));
- sprintf(buf, "%s/lsq%u.xpm", ExpandPathName(appData.pixmapDirectory), ss);
+ snprintf(buf, sizeof(buf), "%s/lsq%u.xpm", ExpandPathName(appData.pixmapDirectory), ss);
if (access(buf, 0) != 0) {
useImageSqs = 0;
} else {
exit(1);
}
fprintf(stderr, _("dark square "));
- sprintf(buf, "%s/dsq%u.xpm",
+ snprintf(buf, sizeof(buf), "%s/dsq%u.xpm",
ExpandPathName(appData.pixmapDirectory), ss);
if (appData.debugMode) {
fprintf(stderr, _("(File:%s:) "), buf);
if (errcode != BitmapSuccess) {
switch (errcode) {
case BitmapOpenFailed:
- sprintf(msg, _("Can't open bitmap file %s"), fullname);
+ snprintf(msg, sizeof(msg), _("Can't open bitmap file %s"), fullname);
break;
case BitmapFileInvalid:
- sprintf(msg, _("Invalid bitmap in file %s"), fullname);
+ snprintf(msg, sizeof(msg), _("Invalid bitmap in file %s"), fullname);
break;
case BitmapNoMemory:
- sprintf(msg, _("Ran out of memory reading bitmap file %s"),
+ snprintf(msg, sizeof(msg), _("Ran out of memory reading bitmap file %s"),
fullname);
break;
default:
- sprintf(msg, _("Unknown XReadBitmapFile error %d on file %s"),
+ snprintf(msg, sizeof(msg), _("Unknown XReadBitmapFile error %d on file %s"),
errcode, fullname);
break;
}
&& !appData.icsActive));
count = 0;
while (p && *p++ == dmEnables[i].piece) count++;
- sprintf(label, "%s %d", dmEnables[i].widget, count);
+ snprintf(label, sizeof(label), "%s %d", dmEnables[i].widget, count);
j = 0;
XtSetArg(args[j], XtNlabel, label); j++;
XtSetValues(entry, args, j);
char buf[MSG_SIZ];
if (!first.analysisSupport) {
- sprintf(buf, _("%s does not support analysis"), first.tidy);
+ snprintf(buf, sizeof(buf), _("%s does not support analysis"), first.tidy);
DisplayError(buf, 0);
return;
}
{
if (!first.analysisSupport) {
char buf[MSG_SIZ];
- sprintf(buf, _("%s does not support analysis"), first.tidy);
+ snprintf(buf, sizeof(buf), _("%s does not support analysis"), first.tidy);
DisplayError(buf, 0);
return;
}
Cardinal *nprms;
{
char buf[MSG_SIZ];
- sprintf(buf, "xterm -e info --directory %s --directory . -f %s &",
+ snprintf(buf, sizeof(buf), "xterm -e info --directory %s --directory . -f %s &",
INFODIR, INFOFILE);
system(buf);
}
name = prms[0];
else
name = "xboard";
- sprintf(buf, "xterm -e man %s &", name);
+ snprintf(buf, sizeof(buf), "xterm -e man %s &", name);
system(buf);
}
#else
char *zippy = "";
#endif
- sprintf(buf, "%s%s\n\n%s\n%s\n%s\n\n%s%s\n%s",
+ snprintf(buf, sizeof(buf), "%s%s\n\n%s\n%s\n%s\n\n%s%s\n%s",
programVersion, zippy,
"Copyright 1991 Digital Equipment Corporation",
"Enhancements Copyright 1992-2009 Free Software Foundation",
if (extMessage) {
if (*message) {
- sprintf(buf, "%s %s", message, extMessage);
+ snprintf(buf, sizeof(buf), "%s %s", message, extMessage);
message = buf;
} else {
message = extMessage;
strcpy(icon, text);
strcpy(title, text);
} else if (appData.icsActive) {
- sprintf(icon, "%s", appData.icsHost);
- sprintf(title, "%s: %s", programName, appData.icsHost);
+ snprintf(icon, sizeof(icon), "%s", appData.icsHost);
+ snprintf(title, sizeof(title),"%s: %s", programName, appData.icsHost);
} else if (appData.cmailGameName[0] != NULLCHAR) {
- sprintf(icon, "%s", "CMail");
- sprintf(title, "%s: %s", programName, "CMail");
+ snprintf(icon, sizeof(icon), "%s", "CMail");
+ snprintf(title,sizeof(title), "%s: %s", programName, "CMail");
#ifdef GOTHIC
// [HGM] license: This stuff should really be done in back-end, but WinBoard already had a pop-up for it
} else if (gameInfo.variant == VariantGothic) {
strcpy(title, programName);
} else {
strcpy(icon, first.tidy);
- sprintf(title, "%s: %s", programName, first.tidy);
+ snprintf(title,sizeof(title), "%s: %s", programName, first.tidy);
}
i = 0;
XtSetArg(args[i], XtNiconName, (XtArgVal) icon); i++;
fprintf(stderr, "%s: %s: %s\n",
programName, message, strerror(error));
}
- sprintf(buf, "%s: %s", message, strerror(error));
+ snprintf(buf,sizeof(buf), "%s: %s", message, strerror(error));
message = buf;
}
ErrorPopUp(_("Error"), message, FALSE);
} else {
fprintf(stderr, "%s: %s: %s\n",
programName, message, strerror(error));
- sprintf(buf, "%s: %s", message, strerror(error));
+ snprintf(buf, sizeof(buf), "%s: %s", message, strerror(error));
message = buf;
}
if (appData.popupExitMessage && boardWidget && XtIsRealized(boardWidget)) {
putc(BELLCHAR, stderr);
} else {
char buf[2048];
- sprintf(buf, "%s '%s' &", appData.soundProgram, name);
+ snprintf(buf, sizeof(buf), "%s '%s' &", appData.soundProgram, name);
system(buf);
}
}
char cmdLine[MSG_SIZ];
if (port[0] == NULLCHAR) {
- sprintf(cmdLine, "%s %s", appData.telnetProgram, host);
+ snprintf(cmdLine, sizeof(cmdLine), "%s %s", appData.telnetProgram, host);
} else {
- sprintf(cmdLine, "%s %s %s", appData.telnetProgram, host, port);
+ snprintf(cmdLine,sizeof(cmdLine), "%s %s %s", appData.telnetProgram, host, port);
}
return StartChildProcess(cmdLine, "", pr);
}