summaryrefslogtreecommitdiffstats
path: root/Source/CursesDialog
diff options
context:
space:
mode:
authorSean McBride <sean@rogue-research.com>2021-10-21 16:35:57 (GMT)
committerSean McBride <sean@rogue-research.com>2021-10-25 22:23:13 (GMT)
commit5ba6e8ac59333aa574d5963332e3ef0f4c4d3514 (patch)
treed796f695e10d5ec20508cb04f4c8b3c2a6c0d742 /Source/CursesDialog
parent0ce50dd78f68b697e1ab29d52d733b87c5bfb67d (diff)
downloadCMake-5ba6e8ac59333aa574d5963332e3ef0f4c4d3514.zip
CMake-5ba6e8ac59333aa574d5963332e3ef0f4c4d3514.tar.gz
CMake-5ba6e8ac59333aa574d5963332e3ef0f4c4d3514.tar.bz2
Source: Replace most calls to sprintf with snprintf
Diffstat (limited to 'Source/CursesDialog')
-rw-r--r--Source/CursesDialog/cmCursesLongMessageForm.cxx8
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx26
-rw-r--r--Source/CursesDialog/cmCursesStringWidget.cxx3
3 files changed, 21 insertions, 16 deletions
diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx
index 591c546..7f1815f 100644
--- a/Source/CursesDialog/cmCursesLongMessageForm.cxx
+++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx
@@ -78,7 +78,8 @@ void cmCursesLongMessageForm::UpdateStatusBar()
char version[cmCursesMainForm::MAX_WIDTH];
char vertmp[128];
- sprintf(vertmp, "CMake Version %s", cmVersion::GetCMakeVersion());
+ snprintf(vertmp, sizeof(vertmp), "CMake Version %s",
+ cmVersion::GetCMakeVersion());
size_t sideSpace = (width - strlen(vertmp));
for (size_t i = 0; i < sideSpace; i++) {
version[i] = ' ';
@@ -105,7 +106,7 @@ void cmCursesLongMessageForm::PrintKeys()
return;
}
char firstLine[512];
- sprintf(firstLine, "Press [e] to exit screen");
+ snprintf(firstLine, sizeof(firstLine), "Press [e] to exit screen");
char fmt_s[] = "%s";
curses_move(y - 2, 0);
@@ -176,7 +177,8 @@ void cmCursesLongMessageForm::HandleInput()
this->PrintKeys();
int key = getch();
- sprintf(debugMessage, "Message widget handling input, key: %d", key);
+ snprintf(debugMessage, sizeof(debugMessage),
+ "Message widget handling input, key: %d", key);
cmCursesForm::LogMessage(debugMessage);
// quit
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index b28c5b7..0012a25 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -322,22 +322,22 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */)
memset(thirdLine, ' ', 68);
} else {
if (this->OkToGenerate) {
- sprintf(firstLine,
- " [l] Show log output [c] Configure"
- " [g] Generate ");
+ snprintf(firstLine, sizeof(firstLine),
+ " [l] Show log output [c] Configure"
+ " [g] Generate ");
} else {
- sprintf(firstLine,
- " [l] Show log output [c] Configure"
- " ");
+ snprintf(firstLine, sizeof(firstLine),
+ " [l] Show log output [c] Configure"
+ " ");
}
{
const char* toggleKeyInstruction =
" [t] Toggle advanced mode (currently %s)";
- sprintf(thirdLine, toggleKeyInstruction,
- this->AdvancedMode ? "on" : "off");
+ snprintf(thirdLine, sizeof(thirdLine), toggleKeyInstruction,
+ this->AdvancedMode ? "on" : "off");
}
- sprintf(secondLine,
- " [h] Help [q] Quit without generating");
+ snprintf(secondLine, sizeof(secondLine),
+ " [h] Help [q] Quit without generating");
}
curses_move(y - 4, 0);
@@ -356,7 +356,8 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */)
if (cw) {
char pageLine[512] = "";
- sprintf(pageLine, "Page %d of %d", cw->GetPage(), this->NumberOfPages);
+ snprintf(pageLine, sizeof(pageLine), "Page %d of %d", cw->GetPage(),
+ this->NumberOfPages);
curses_move(0, 65 - static_cast<unsigned int>(strlen(pageLine)) - 1);
printw(fmt_s, pageLine);
}
@@ -739,7 +740,8 @@ void cmCursesMainForm::HandleInput()
if ((!currentWidget || !widgetHandled) && !this->SearchMode) {
// If the current widget does not want to handle input,
// we handle it.
- sprintf(debugMessage, "Main form handling input, key: %d", key);
+ snprintf(debugMessage, sizeof(debugMessage),
+ "Main form handling input, key: %d", key);
cmCursesForm::LogMessage(debugMessage);
// quit
if (key == 'q') {
diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx
index 4830d63..c0d06ce 100644
--- a/Source/CursesDialog/cmCursesStringWidget.cxx
+++ b/Source/CursesDialog/cmCursesStringWidget.cxx
@@ -85,7 +85,8 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
// <Enter> is used to change edit mode (like <Esc> in vi).
while (!this->Done) {
- sprintf(debugMessage, "String widget handling input, key: %d", key);
+ snprintf(debugMessage, sizeof(debugMessage),
+ "String widget handling input, key: %d", key);
cmCursesForm::LogMessage(debugMessage);
fm->PrintKeys();