mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-26 04:09:35 +03:00
ccmake: Display an error and interrupt execution if ncurses failed
This commit is contained in:
committed by
Brad King
parent
21218f5c12
commit
19689d34e6
@@ -2,11 +2,15 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
|
||||
#include <csignal>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "cmsys/Encoding.hxx"
|
||||
|
||||
#include "cmCursesColor.h"
|
||||
@@ -54,7 +58,12 @@ void onsig(int /*unused*/)
|
||||
{
|
||||
if (cmCursesForm::CurrentForm) {
|
||||
endwin();
|
||||
initscr(); /* Initialization */
|
||||
if (initscr() == nullptr) {
|
||||
static const char errmsg[] = "Error: ncurses initialization failed\n";
|
||||
auto r = write(STDERR_FILENO, errmsg, sizeof(errmsg) - 1);
|
||||
static_cast<void>(r);
|
||||
exit(1);
|
||||
}
|
||||
noecho(); /* Echo off */
|
||||
cbreak(); /* nl- or cr not needed */
|
||||
keypad(stdscr, true); /* Use key symbols as KEY_DOWN */
|
||||
@@ -124,7 +133,10 @@ int main(int argc, char const* const* argv)
|
||||
cmCursesForm::DebugStart();
|
||||
}
|
||||
|
||||
initscr(); /* Initialization */
|
||||
if (initscr() == nullptr) {
|
||||
fprintf(stderr, "Error: ncurses initialization failed\n");
|
||||
exit(1);
|
||||
}
|
||||
noecho(); /* Echo off */
|
||||
cbreak(); /* nl- or cr not needed */
|
||||
keypad(stdscr, true); /* Use key symbols as KEY_DOWN */
|
||||
|
||||
Reference in New Issue
Block a user