Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/AnalyseAllPlaysBin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int main()
{
match = ComparePlay(&solved.solved[handno], handno);

sprintf(line, "AnalyseAllPlaysBin, hand %d: %s\n",
snprintf(line, sizeof(line), "AnalyseAllPlaysBin, hand %d: %s\n",
handno + 1, (match ? "OK" : "ERROR"));

PrintHand(line, bo.deals[handno].remainCards);
Expand Down
2 changes: 1 addition & 1 deletion examples/AnalyseAllPlaysPBN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int main()
{
match = ComparePlay(&solved.solved[handno], handno);

sprintf(line, "AnalyseAllPlaysBin, hand %d: %s\n",
snprintf(line, sizeof(line), "AnalyseAllPlaysBin, hand %d: %s\n",
handno + 1, (match ? "OK" : "ERROR"));

PrintPBNHand(line, bo.deals[handno].remainCards);
Expand Down
2 changes: 1 addition & 1 deletion examples/AnalysePlayBin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int main()

match = ComparePlay(&solved, handno);

sprintf(line, "AnalysePlayBin, hand %d: %s\n",
snprintf(line, sizeof(line), "AnalysePlayBin, hand %d: %s\n",
handno + 1, (match ? "OK" : "ERROR"));

PrintHand(line, dl.remainCards);
Expand Down
2 changes: 1 addition & 1 deletion examples/AnalysePlayPBN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int main()

match = ComparePlay(&solved, handno);

sprintf(line, "AnalysePlayPBNBin, hand %d: %s\n",
snprintf(line, sizeof(line), "AnalysePlayPBNBin, hand %d: %s\n",
handno + 1, (match ? "OK" : "ERROR"));

PrintPBNHand(line, dlPBN.remainCards);
Expand Down
2 changes: 1 addition & 1 deletion examples/CalcAllTables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int main()
{
match = CompareTable(&tableRes.results[handno], handno);

sprintf(line,
snprintf(line, sizeof(line),
"CalcDDtable, hand %d: %s\n",
handno + 1, (match ? "OK" : "ERROR"));

Expand Down
2 changes: 1 addition & 1 deletion examples/CalcAllTablesPBN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int main()
{
match = CompareTable(&tableRes.results[handno], handno);

sprintf(line,
snprintf(line, sizeof(line),
"CalcDDtable, hand %d: %s\n",
handno + 1, (match ? "OK" : "ERROR"));

Expand Down
2 changes: 1 addition & 1 deletion examples/CalcDDtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int main()

match = CompareTable(&table, handno);

sprintf(line,
snprintf(line, sizeof(line),
"CalcDDtable, hand %d: %s\n",
handno + 1, (match ? "OK" : "ERROR"));

Expand Down
2 changes: 1 addition & 1 deletion examples/CalcDDtablePBN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int main()

match = CompareTable(&table, handno);

sprintf(line,
snprintf(line, sizeof(line),
"CalcDDtable, hand %d: %s\n",
handno + 1, (match ? "OK" : "ERROR"));

Expand Down
2 changes: 1 addition & 1 deletion examples/SolveAllBoards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int main()
{
match = CompareFut(&solved.solvedBoard[handno], handno, 3);

sprintf(line,
snprintf(line, sizeof(line),
"SolveAllBoards, hand %d: solutions 3 %s\n",
handno + 1, (match ? "OK" : "ERROR"));

Expand Down
6 changes: 3 additions & 3 deletions examples/SolveBoard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ int main()

match2 = CompareFut(&fut2, handno, solutions);

sprintf(line,
snprintf(line, sizeof(line),
"SolveBoard, hand %d: solutions 3 %s, solutions 2 %s\n",
handno + 1,
(match3 ? "OK" : "ERROR"),
(match2 ? "OK" : "ERROR"));

PrintHand(line, dl.remainCards);

sprintf(line, "solutions == 3\n");
snprintf(line, sizeof(line), "solutions == 3\n");
PrintFut(line, &fut3);
sprintf(line, "solutions == 2\n");
snprintf(line, sizeof(line), "solutions == 2\n");
PrintFut(line, &fut2);
}
}
6 changes: 3 additions & 3 deletions examples/SolveBoardPBN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@ int main()

match2 = CompareFut(&fut2, handno, solutions);

sprintf(line,
snprintf(line, sizeof(line),
"SolveBoardPBN, hand %d: solutions 3 %s, solutions 2 %s\n",
handno + 1,
(match3 ? "OK" : "ERROR"),
(match2 ? "OK" : "ERROR"));

PrintPBNHand(line, dlPBN.remainCards);

sprintf(line, "solutions == 3\n");
snprintf(line, sizeof(line), "solutions == 3\n");
PrintFut(line, &fut3);
sprintf(line, "solutions == 2\n");
snprintf(line, sizeof(line), "solutions == 2\n");
PrintFut(line, &fut2);
}
}
32 changes: 16 additions & 16 deletions src/Par.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ int STDCALL Par(
presp->parScore[1][2] = ' ';
presp->parScore[1][3] = '\0';

sprintf(temp, "%d", sidesRes[0].score);
snprintf(temp, sizeof(temp), "%d", sidesRes[0].score);
strcat(presp->parScore[0], temp);
sprintf(temp, "%d", sidesRes[1].score);
snprintf(temp, sizeof(temp), "%d", sidesRes[1].score);
strcat(presp->parScore[1], temp);

presp->parContractsString[0][0] = 'N';
Expand Down Expand Up @@ -163,7 +163,7 @@ int STDCALL Par(

strcat(presp->parContractsString[i],
seats[sidesRes[i].contracts[k].seats]);
sprintf(temp, "%d", sidesRes[i].contracts[k].level);
snprintf(temp, sizeof(temp), "%d", sidesRes[i].contracts[k].level);
buff[0] = static_cast<char>(
cardSuit[denom_conv[sidesRes[i].contracts[k].denom]]);
buff[1] = 'x';
Expand All @@ -189,7 +189,7 @@ int STDCALL Par(
+ sidesRes[i].contracts[k].level + 6);


sprintf(temp, "%d", n);
snprintf(temp, sizeof(temp), "%d", n);
buff[0] = static_cast<char>(
cardSuit[denom_conv[sidesRes[i].contracts[k].denom]]);
buff[1] = '\0';
Expand Down Expand Up @@ -1290,7 +1290,7 @@ int STDCALL SidesPar(

for (k = 0; k < sidesRes[i].number; k++)
{
sprintf(sidesRes[i].contracts[k], "%d", parm[i].contracts[k].level);
snprintf(sidesRes[i].contracts[k], sizeof(sidesRes[i].contracts[k]), "%d", parm[i].contracts[k].level);
switch (parm[i].contracts[k].denom)
{
case 0:
Expand Down Expand Up @@ -1342,13 +1342,13 @@ int STDCALL SidesPar(
if (parm[i].contracts[k].underTricks > 0)
{
/* Sacrifice */
sprintf(buff, "-%d", parm[i].contracts[k].underTricks);
snprintf(buff, sizeof(buff), "-%d", parm[i].contracts[k].underTricks);
strcat(sidesRes[i].contracts[k], buff);
}
else if (parm[i].contracts[k].overTricks > 0)
{
/* Make */
sprintf(buff, "+%d", parm[i].contracts[k].overTricks);
snprintf(buff, sizeof(buff), "+%d", parm[i].contracts[k].overTricks);
strcat(sidesRes[i].contracts[k], buff);
}
}
Expand All @@ -1366,7 +1366,7 @@ int STDCALL ConvertToDealerTextFormat(
int k, i;
char buff[20];

sprintf(resp, "Par %d: ", pres->score);
snprintf(resp, sizeof(resp), "Par %d: ", pres->score);

for (k = 0; k < pres->number; k++)
{
Expand Down Expand Up @@ -1401,7 +1401,7 @@ int STDCALL ConvertToDealerTextFormat(

for (i = 0; i < 10; i++)
buff[i] = '\0';
sprintf(buff, "%d", pres->contracts[k].level);
snprintf(buff, sizeof(buff), "%d", pres->contracts[k].level);
strcat(resp, buff);

switch (pres->contracts[k].denom)
Expand Down Expand Up @@ -1431,15 +1431,15 @@ int STDCALL ConvertToDealerTextFormat(
strcat(resp, "x-");
for (i = 0; i < 10; i++)
buff[i] = '\0';
sprintf(buff, "%d", pres->contracts[k].underTricks);
snprintf(buff, sizeof(buff), "%d", pres->contracts[k].underTricks);
strcat(resp, buff);
}
else if (pres->contracts[k].overTricks > 0)
{
strcat(resp, "+");
for (i = 0; i < 10; i++)
buff[i] = '\0';
sprintf(buff, "%d", pres->contracts[k].overTricks);
snprintf(buff, sizeof(buff), "%d", pres->contracts[k].overTricks);
strcat(resp, buff);
}
}
Expand All @@ -1460,14 +1460,14 @@ int STDCALL ConvertToSidesTextFormat(

if (pres->score == 0)
{
sprintf(resp->parText[0], "Par 0");
snprintf(resp->parText[0], sizeof(resp->parText[0]), "Par 0");
return RETURN_NO_FAULT;
}

for (i = 0; i < 2; i++)
{

sprintf(resp->parText[i], "Par %d: ", (pres + i)->score);
snprintf(resp->parText[i], sizeof(resp->parText[i]), "Par %d: ", (pres + i)->score);

for (k = 0; k < (pres + i)->number; k++)
{
Expand Down Expand Up @@ -1502,7 +1502,7 @@ int STDCALL ConvertToSidesTextFormat(

for (j = 0; j < 10; j++)
buff[j] = '\0';
sprintf(buff, "%d", (pres + i)->contracts[k].level);
snprintf(buff, sizeof(buff), "%d", (pres + i)->contracts[k].level);
strcat(resp->parText[i], buff);

switch ((pres + i)->contracts[k].denom)
Expand Down Expand Up @@ -1532,15 +1532,15 @@ int STDCALL ConvertToSidesTextFormat(
strcat(resp->parText[i], "x-");
for (j = 0; j < 10; j++)
buff[j] = '\0';
sprintf(buff, "%d", (pres + i)->contracts[k].underTricks);
snprintf(buff, sizeof(buff), "%d", (pres + i)->contracts[k].underTricks);
strcat(resp->parText[i], buff);
}
else if ((pres + i)->contracts[k].overTricks > 0)
{
strcat(resp->parText[i], "+");
for (j = 0; j < 10; j++)
buff[j] = '\0';
sprintf(buff, "%d", (pres + i)->contracts[k].overTricks);
snprintf(buff, sizeof(buff), "%d", (pres + i)->contracts[k].overTricks);
strcat(resp->parText[i], buff);
}
}
Expand Down