diff options
author | Brad King <brad.king@kitware.com> | 2021-10-27 13:23:02 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-10-27 13:23:17 (GMT) |
commit | 9bb7982a15e51b0336e58d4cafc20529ec50550d (patch) | |
tree | 5cc5b6744ac6f8da254487002a5a9a7cd832ba80 /Source/CursesDialog | |
parent | ede11598ba16841c7652160ba8dd755c259bc122 (diff) | |
parent | b7e9cd05cd07605d01a50522f65347aa23d2647e (diff) | |
download | CMake-9bb7982a15e51b0336e58d4cafc20529ec50550d.zip CMake-9bb7982a15e51b0336e58d4cafc20529ec50550d.tar.gz CMake-9bb7982a15e51b0336e58d4cafc20529ec50550d.tar.bz2 |
Merge topic 'purge-sprintf'
b7e9cd05cd Replace the only non-standard _snprintf with snprintf
5ba6e8ac59 Source: Replace most calls to sprintf with snprintf
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6649
Diffstat (limited to 'Source/CursesDialog')
-rw-r--r-- | Source/CursesDialog/cmCursesLongMessageForm.cxx | 8 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesMainForm.cxx | 26 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesStringWidget.cxx | 3 |
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(); |