Global: replaces NULL to nullptr

This commit is contained in:
李通洲
2026-07-10 18:08:04 +08:00
parent 873454191f
commit ba18705d2e
387 changed files with 2411 additions and 2411 deletions
+38 -38
View File
@@ -25,7 +25,7 @@
static bool getFileVersion(const FFstrbuf* exePath, const wchar_t* stringName, FFstrbuf* version) {
wchar_t exePathW[PATH_MAX + 1];
if (!NT_SUCCESS(RtlUTF8ToUnicodeN(exePathW, (ULONG) sizeof(exePathW), NULL, exePath->chars, (ULONG) exePath->length + 1))) {
if (!NT_SUCCESS(RtlUTF8ToUnicodeN(exePathW, (ULONG) sizeof(exePathW), nullptr, exePath->chars, (ULONG) exePath->length + 1))) {
return false;
}
return ffGetFileVersion(exePathW, stringName, version);
@@ -38,7 +38,7 @@ static bool getFileVersion(const FFstrbuf* exePath, const wchar_t* stringName, F
#endif
static bool getExeVersionRaw(FFstrbuf* exe, FFstrbuf* version) {
return ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", NULL }) == NULL;
return ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", nullptr }) == nullptr;
}
static bool getExeVersionGeneral(FFstrbuf* exe, FFstrbuf* version) {
@@ -105,7 +105,7 @@ static bool getShellVersionPwsh(FFstrbuf* exe, FFstrbuf* version) {
}
#ifdef _WIN32
if (getFileVersion(exe, NULL, version)) {
if (getFileVersion(exe, nullptr, version)) {
ffStrbufSubstrBeforeLastC(version, '.');
return true;
}
@@ -120,14 +120,14 @@ static bool getShellVersionPwsh(FFstrbuf* exe, FFstrbuf* version) {
}
static bool getShellVersionKsh(FFstrbuf* exe, FFstrbuf* version) {
if (ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "--version", NULL }) == NULL && ffStrbufSubstrAfterFirstS(version, " (AT&T Research) ")) {
if (ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "--version", nullptr }) == nullptr && ffStrbufSubstrAfterFirstS(version, " (AT&T Research) ")) {
// version sh (AT&T Research) 93u+ 2012-08-01
ffStrbufSubstrBeforeFirstC(version, ' ');
return true;
}
ffStrbufClear(version);
if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-c", "echo $KSH_VERSION", NULL }) == NULL && ffStrbufSubstrAfterFirstS(version, " KSH ")) {
if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-c", "echo $KSH_VERSION", nullptr }) == nullptr && ffStrbufSubstrAfterFirstS(version, " KSH ")) {
// OKSH: @(#)PD KSH v5.2.14 99/07/13.2
// MKSH: @(#)MIRBSD KSH R59 2025/04/26 +Debian
// $OKSH_VERSION doesn't exist on OpenBSD
@@ -141,7 +141,7 @@ static bool getShellVersionKsh(FFstrbuf* exe, FFstrbuf* version) {
static bool getShellVersionOksh(FFstrbuf* exe, FFstrbuf* version) {
// Homebrew version
if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-c", "echo $OKSH_VERSION", NULL }) != NULL) {
if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-c", "echo $OKSH_VERSION", nullptr }) != nullptr) {
return false;
}
@@ -151,7 +151,7 @@ static bool getShellVersionOksh(FFstrbuf* exe, FFstrbuf* version) {
}
static bool getShellVersionOils(FFstrbuf* exe, FFstrbuf* version) {
if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", NULL }) != NULL) {
if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", nullptr }) != nullptr) {
return false;
}
@@ -189,9 +189,9 @@ static bool getShellVersionAsh(FFstrbuf* exe, FFstrbuf* version) {
ffBinaryExtractStrings(exe->chars, extractBusyboxVersion, version, (uint32_t) strlen("BusyBox v0.0.0"));
const char* error = ffStrbufEndsWithS(exe, "busybox")
? ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "ash", "--help", NULL })
: ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "--help", NULL });
if (error != NULL) {
? ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "ash", "--help", nullptr })
: ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "--help", nullptr });
if (error != nullptr) {
return false;
}
@@ -209,7 +209,7 @@ static bool getShellVersionXonsh(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) {
}
// exe is python here
if (ffProcessAppendStdErr(version, (char* const[]) { "xonsh", "--version", NULL }) != NULL) {
if (ffProcessAppendStdErr(version, (char* const[]) { "xonsh", "--version", nullptr }) != nullptr) {
return false;
}
@@ -249,13 +249,13 @@ static bool getShellVersionWinPowerShell(FFstrbuf* exe, FFstrbuf* version) {
return true;
}
FF_AUTO_CLOSE_FD HANDLE hKey = NULL;
if (ffRegOpenSubkeyForRead(ffRegGetRootKeyHandle(HKEY_LOCAL_MACHINE), L"SOFTWARE\\Microsoft\\PowerShell\\3\\PowerShellEngine", &hKey, NULL) && ffRegReadStrbuf(hKey, L"PowerShellVersion", version, NULL)) {
FF_AUTO_CLOSE_FD HANDLE hKey = nullptr;
if (ffRegOpenSubkeyForRead(ffRegGetRootKeyHandle(HKEY_LOCAL_MACHINE), L"SOFTWARE\\Microsoft\\PowerShell\\3\\PowerShellEngine", &hKey, nullptr) && ffRegReadStrbuf(hKey, L"PowerShellVersion", version, nullptr)) {
return true;
}
// Extremely slow
return ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-NoLogo", "-NoProfile", "-Command", "$PSVersionTable.PSVersion.ToString()", NULL }) == NULL;
return ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-NoLogo", "-NoProfile", "-Command", "$PSVersionTable.PSVersion.ToString()", nullptr }) == nullptr;
}
#endif
@@ -309,7 +309,7 @@ bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version)
return getShellVersionWinPowerShell(exe, version);
}
return getFileVersion(exe, NULL, version);
return getFileVersion(exe, nullptr, version);
#endif
return false;
@@ -341,7 +341,7 @@ FF_A_UNUSED static bool getTerminalVersionGnome(FFstrbuf* exe, FFstrbuf* version
}
}
if (ffProcessAppendStdOut(version, (char* const[]) { "gnome-terminal", "--version", NULL })) {
if (ffProcessAppendStdOut(version, (char* const[]) { "gnome-terminal", "--version", nullptr })) {
return false;
}
@@ -363,7 +363,7 @@ FF_A_UNUSED static bool getTerminalVersionXfce4Terminal(FFstrbuf* exe, FFstrbuf*
}
FF_A_UNUSED static bool getTerminalVersionKgx(FFstrbuf* version) {
if (ffProcessAppendStdOut(version, (char* const[]) { "kgx", "--version", NULL })) {
if (ffProcessAppendStdOut(version, (char* const[]) { "kgx", "--version", nullptr })) {
return false;
}
@@ -377,7 +377,7 @@ FF_A_UNUSED static bool getTerminalVersionKonsole(FFstrbuf* exe, FFstrbuf* versi
const char* konsoleVersion = getenv("KONSOLE_VERSION");
if (konsoleVersion) {
// 221201
long major = strtol(konsoleVersion, NULL, 10);
long major = strtol(konsoleVersion, nullptr, 10);
if (major >= 0) {
long patch = major % 100;
major /= 100;
@@ -397,7 +397,7 @@ FF_A_UNUSED static bool getTerminalVersionKonsole(FFstrbuf* exe, FFstrbuf* versi
FF_A_UNUSED static bool getTerminalVersionFoot(FFstrbuf* exe, FFstrbuf* version) {
uint32_t major = 0, minor = 0, patch = 0;
if (ffGetTerminalResponse("\e[>c", 3, "\e[>1;%2u%2u%2u;0c", &major, &minor, &patch) == NULL) {
if (ffGetTerminalResponse("\e[>c", 3, "\e[>1;%2u%2u%2u;0c", &major, &minor, &patch) == nullptr) {
ffStrbufSetF(version, "%u.%u.%u", major, minor, patch);
return true;
}
@@ -441,7 +441,7 @@ FF_A_UNUSED static bool getTerminalVersionCockpit(FFstrbuf* exe, FFstrbuf* versi
FF_A_UNUSED static bool getTerminalVersionXterm(FFstrbuf* exe, FFstrbuf* version) {
ffStrbufSetS(version, getenv("XTERM_VERSION"));
if (!version->length) {
if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-v", NULL })) {
if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-v", nullptr })) {
return false;
}
}
@@ -453,7 +453,7 @@ FF_A_UNUSED static bool getTerminalVersionXterm(FFstrbuf* exe, FFstrbuf* version
}
FF_A_UNUSED static bool getTerminalVersionBlackbox(FFstrbuf* exe, FFstrbuf* version) {
if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", NULL })) {
if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", nullptr })) {
return false;
}
@@ -466,7 +466,7 @@ FF_A_UNUSED static bool getTerminalVersionBlackbox(FFstrbuf* exe, FFstrbuf* vers
FF_A_UNUSED static bool getTerminalVersionUrxvt(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) {
if (ffProcessAppendStdErr(version, (char* const[]) { "urxvt", // Don't use exe because of urxvtd
"-invalid",
NULL })) {
nullptr })) {
return false;
}
@@ -479,7 +479,7 @@ FF_A_UNUSED static bool getTerminalVersionUrxvt(FF_A_UNUSED FFstrbuf* exe, FFstr
}
FF_A_UNUSED static bool getTerminalVersionSt(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) {
if (ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "-v", NULL })) {
if (ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "-v", nullptr })) {
return false;
}
@@ -500,7 +500,7 @@ FF_A_UNUSED static bool getTerminalVersionLxterminal(FFstrbuf* exe, FFstrbuf* ve
FF_A_UNUSED static bool getTerminalVersionWeston(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) {
// weston-terminal doesn't report a version, use weston version instead
if (ffProcessAppendStdOut(version, (char* const[]) { "weston", "--version", NULL })) {
if (ffProcessAppendStdOut(version, (char* const[]) { "weston", "--version", nullptr })) {
return false;
}
@@ -565,7 +565,7 @@ static bool getTerminalVersionScreen(FFstrbuf* exe, FFstrbuf* version) {
}
static bool getTerminalVersionTmux(FFstrbuf* exe, FFstrbuf* version) {
if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-V", NULL }) != NULL) {
if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-V", nullptr }) != nullptr) {
return false;
}
@@ -593,7 +593,7 @@ static bool getTerminalVersionZed(FFstrbuf* exe, FFstrbuf* version) {
#endif
);
if (ffProcessAppendStdOut(version, (char* const[]) { cli.chars, "--version", NULL }) != NULL) {
if (ffProcessAppendStdOut(version, (char* const[]) { cli.chars, "--version", nullptr }) != nullptr) {
return false;
}
@@ -621,7 +621,7 @@ static bool getTerminalVersionSshd(FFstrbuf* exe, FFstrbuf* version) {
FF_STRBUF_AUTO_DESTROY exePath = ffStrbufCreate();
if (ffIsAbsolutePath(exe->chars)) {
ffStrbufSet(&exePath, exe);
} else if (ffFindExecutableInPath("sshd", &exePath) != NULL) {
} else if (ffFindExecutableInPath("sshd", &exePath) != nullptr) {
return false;
}
@@ -630,7 +630,7 @@ static bool getTerminalVersionSshd(FFstrbuf* exe, FFstrbuf* version) {
return true;
}
if (ffProcessAppendStdOut(version, (char* const[]) { exePath.chars, "-V", NULL }) != NULL) {
if (ffProcessAppendStdOut(version, (char* const[]) { exePath.chars, "-V", nullptr }) != nullptr) {
return false;
}
@@ -669,7 +669,7 @@ static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) {
}
}
#elif __APPLE__
if (ffGetAppNameAndVersion(exe->chars, NULL, version)) {
if (ffGetAppNameAndVersion(exe->chars, nullptr, version)) {
return true;
}
#endif
@@ -680,7 +680,7 @@ static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) {
"\eP+q6b697474792d71756572792d76657273696f6e\e\\", // kitty-query-version
1,
"\eP1+r%*[^=]=%63[^\e]\e\\\\",
versionHex) == NULL) {
versionHex) == nullptr) {
// decode hex string
for (const char* p = versionHex; p[0] && p[1]; p += 2) {
unsigned value;
@@ -696,7 +696,7 @@ static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) {
}
FF_A_UNUSED static bool getTerminalVersionPtyxis(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) {
if (ffProcessAppendStdOut(version, (char* const[]) { "ptyxis", "--version", NULL }) != NULL) {
if (ffProcessAppendStdOut(version, (char* const[]) { "ptyxis", "--version", nullptr }) != nullptr) {
return false;
}
@@ -713,7 +713,7 @@ FF_A_UNUSED static bool getTerminalVersionTilix(FFstrbuf* exe, FFstrbuf* version
}
}
if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", NULL }) != NULL) {
if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", nullptr }) != nullptr) {
return false;
}
@@ -731,7 +731,7 @@ FF_A_UNUSED static bool getTerminalVersionTilix(FFstrbuf* exe, FFstrbuf* version
}
FF_A_UNUSED static bool getTerminalVersionSakura(FFstrbuf* exe, FFstrbuf* version) {
if (ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "--version", NULL }) != NULL) { // sakura version is 3.8.8
if (ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "--version", nullptr }) != nullptr) { // sakura version is 3.8.8
return false;
}
@@ -740,7 +740,7 @@ FF_A_UNUSED static bool getTerminalVersionSakura(FFstrbuf* exe, FFstrbuf* versio
}
FF_A_UNUSED static bool getTerminalVersionTermite(FFstrbuf* exe, FFstrbuf* version) {
if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", NULL }) != NULL) { // termite v16.9\nvte 0.78.1 +BIDI +GNUTLS +ICU +SYSTEMD
if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", nullptr }) != nullptr) { // termite v16.9\nvte 0.78.1 +BIDI +GNUTLS +ICU +SYSTEMD
return false;
}
@@ -762,7 +762,7 @@ static bool getTerminalVersionWindowsTerminal(FFstrbuf* exe, FFstrbuf* version)
return true;
}
return getFileVersion(exe, NULL, version);
return getFileVersion(exe, nullptr, version);
}
static bool getTerminalVersionConEmu(FFstrbuf* exe, FFstrbuf* version) {
@@ -772,7 +772,7 @@ static bool getTerminalVersionConEmu(FFstrbuf* exe, FFstrbuf* version) {
return true;
}
return getFileVersion(exe, NULL, version);
return getFileVersion(exe, nullptr, version);
}
#endif
@@ -980,11 +980,11 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_A_UNUSED FFstrbuf* exe, FF
#ifdef _WIN32
return getFileVersion(exe, NULL, version);
return getFileVersion(exe, nullptr, version);
#elif __APPLE__
return ffGetAppNameAndVersion(exe->chars, NULL, version);
return ffGetAppNameAndVersion(exe->chars, nullptr, version);
#else