Use nullptr instead of NULL.

See https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf
TLDR: NULL is of type int and relies on proper implicit pointer
conversion which may lead to issues when using overloaded functions

It is also considered a 'best practise' for modern C++ and
conveys the programmers intention more precisly.
This commit is contained in:
nobounce
2023-07-26 16:19:17 +02:00
parent d53307f14c
commit e4abcefbf9
7 changed files with 85 additions and 85 deletions

View File

@@ -80,7 +80,7 @@ namespace Term {
else settings.c_lflag &= ~(ICANON);
if (tcsetattr(STDIN_FILENO, TCSANOW, &settings)) return false;
if (on) setlinebuf(stdin);
else setbuf(stdin, NULL);
else setbuf(stdin, nullptr);
return true;
}
}
@@ -121,15 +121,15 @@ namespace Term {
initialized = (bool)isatty(STDIN_FILENO);
if (initialized) {
tcgetattr(STDIN_FILENO, &initial_settings);
current_tty = (ttyname(STDIN_FILENO) != NULL ? static_cast<string>(ttyname(STDIN_FILENO)) : "unknown");
current_tty = (ttyname(STDIN_FILENO) != nullptr ? static_cast<string>(ttyname(STDIN_FILENO)) : "unknown");
//? Disable stream sync
cin.sync_with_stdio(false);
cout.sync_with_stdio(false);
//? Disable stream ties
cin.tie(NULL);
cout.tie(NULL);
cin.tie(nullptr);
cout.tie(nullptr);
echo(false);
linebuffered(false);
refresh();
@@ -531,8 +531,8 @@ namespace Tools {
string username() {
auto user = getenv("LOGNAME");
if (user == NULL or strlen(user) == 0) user = getenv("USER");
return (user != NULL ? user : "");
if (user == nullptr or strlen(user) == 0) user = getenv("USER");
return (user != nullptr ? user : "");
}
}