mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-09 06:30:10 +01:00
Global: replaces NULL to nullptr
This commit is contained in:
@@ -77,7 +77,7 @@ static bool parseGhosttyConfig(FFstrbuf* path, FFstrbuf* fontName, FFstrbuf* fon
|
||||
return false;
|
||||
}
|
||||
|
||||
char* line = NULL;
|
||||
char* line = nullptr;
|
||||
size_t len = 0;
|
||||
while (ffStrbufGetline(&line, &len, &buffer)) {
|
||||
if (ffParsePropLine(line, "font-family =", &temp)) {
|
||||
@@ -124,10 +124,10 @@ static void detectGhostty(const FFstrbuf* exe, FFTerminalFontResult* terminalFon
|
||||
const char* error = ffProcessAppendStdOut(&buffer, (char* const[]){
|
||||
exe->chars,
|
||||
"+show-config",
|
||||
NULL,
|
||||
nullptr,
|
||||
});
|
||||
if (error == NULL) {
|
||||
char* line = NULL;
|
||||
if (error == nullptr) {
|
||||
char* line = nullptr;
|
||||
size_t len = 0;
|
||||
while (ffStrbufGetline(&line, &len, &buffer)) {
|
||||
if (ffStrStartsWith(line, "font-family = ")) {
|
||||
@@ -167,7 +167,7 @@ static void detectGhostty(const FFstrbuf* exe, FFTerminalFontResult* terminalFon
|
||||
ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars);
|
||||
if (fontNameFallback.length > 0) {
|
||||
FF_DEBUG("applying fallback family='%s'", fontNameFallback.chars);
|
||||
ffFontInitValues(&terminalFont->fallback, fontNameFallback.chars, NULL);
|
||||
ffFontInitValues(&terminalFont->fallback, fontNameFallback.chars, nullptr);
|
||||
}
|
||||
FF_DEBUG("result family='%s' size='%s'%s", fontName.chars, fontSize.chars, fontNameFallback.length ? " (with fallback)" : "");
|
||||
FF_DEBUG("detectGhostty: end");
|
||||
@@ -180,7 +180,7 @@ FF_A_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont) {
|
||||
|
||||
if (fontName.length == 0) {
|
||||
ffStrbufAppendS(&fontName, "VGA default kernel font ");
|
||||
ffProcessAppendStdOut(&fontName, (char* const[]){ "showconsolefont", "--info", NULL });
|
||||
ffProcessAppendStdOut(&fontName, (char* const[]){ "showconsolefont", "--info", nullptr });
|
||||
|
||||
ffStrbufTrimRight(&fontName, ' ');
|
||||
}
|
||||
@@ -203,7 +203,7 @@ FF_A_UNUSED static bool detectKitty(const FFstrbuf* exe, FFTerminalFontResult* r
|
||||
2,
|
||||
"\eP1+r%*[^=]=%511[^\e]\e\\\eP1+r%*[^=]=%511[^\e]\e\\",
|
||||
fontHex,
|
||||
sizeHex) == NULL &&
|
||||
sizeHex) == nullptr &&
|
||||
*fontHex && *sizeHex) {
|
||||
// decode hex string
|
||||
for (const char* p = fontHex; p[0] && p[1]; p += 2) {
|
||||
@@ -224,7 +224,7 @@ FF_A_UNUSED static bool detectKitty(const FFstrbuf* exe, FFTerminalFontResult* r
|
||||
exe->chars,
|
||||
"+kitten",
|
||||
"query-terminal",
|
||||
NULL,
|
||||
nullptr,
|
||||
})) {
|
||||
ffParsePropLines(buf.chars, "font_family: ", &fontName);
|
||||
ffParsePropLines(buf.chars, "font_size: ", &fontSize);
|
||||
@@ -260,7 +260,7 @@ static bool detectWezterm(const FFstrbuf* exe, FFTerminalFontResult* result) {
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate();
|
||||
|
||||
ffStrbufSetS(&result->error, ffProcessAppendStdOut(&fontName, (char* const[]){ cli.chars, "ls-fonts", "--text", "a", NULL }));
|
||||
ffStrbufSetS(&result->error, ffProcessAppendStdOut(&fontName, (char* const[]){ cli.chars, "ls-fonts", "--text", "a", nullptr }));
|
||||
if (result->error.length) {
|
||||
return false;
|
||||
}
|
||||
@@ -306,7 +306,7 @@ static bool detectTabby(FFTerminalFontResult* result) {
|
||||
|
||||
static bool detectContour(const FFstrbuf* exe, FFTerminalFontResult* result) {
|
||||
FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate();
|
||||
if (ffProcessAppendStdOut(&buf, (char* const[]){ exe->chars, "font-locator", NULL })) {
|
||||
if (ffProcessAppendStdOut(&buf, (char* const[]){ exe->chars, "font-locator", nullptr })) {
|
||||
ffStrbufAppendS(&result->error, "`contour font-locator` failed");
|
||||
return false;
|
||||
}
|
||||
@@ -365,7 +365,7 @@ static bool detectTerminalFontCommon(const FFTerminalResult* terminal, FFTermina
|
||||
} else if (ffStrbufStartsWithIgnCaseS(&terminal->processName, "contour")) {
|
||||
detectContour(&terminal->exe, terminalFont);
|
||||
} else if (ffStrbufStartsWithIgnCaseS(&terminal->processName, "ghostty")) {
|
||||
detectGhostty(&terminal->exe, terminalFont, NULL, NULL);
|
||||
detectGhostty(&terminal->exe, terminalFont, nullptr, nullptr);
|
||||
} else if (ffStrbufStartsWithIgnCaseS(&terminal->processName, "Muxy")) {
|
||||
detectGhostty(&terminal->exe, terminalFont, "Muxy/ghostty.conf", "muxy/ghostty.conf");
|
||||
} else if (ffStrbufStartsWithIgnCaseS(&terminal->processName, "rio")) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
const char* detectTermux(FFTerminalFontResult* terminalFont) {
|
||||
if (!ffPathExists(FF_TERMUX_FONT_PATH, FF_PATHTYPE_FILE)) {
|
||||
ffFontInitCopy(&terminalFont->font, "monospace");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_FREETYPE
|
||||
@@ -25,9 +25,9 @@ const char* detectTermux(FFTerminalFontResult* terminalFont) {
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(freetype, FT_Done_Face);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(freetype, FT_Done_FreeType);
|
||||
|
||||
FT_Library library = NULL;
|
||||
FT_Face face = NULL;
|
||||
const char* error = NULL;
|
||||
FT_Library library = nullptr;
|
||||
FT_Face face = nullptr;
|
||||
const char* error = nullptr;
|
||||
|
||||
if (ffFT_Init_FreeType(&library)) {
|
||||
error = "FT_Init_FreeType() failed";
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
static void detectIterm2(FFTerminalFontResult* terminalFont)
|
||||
{
|
||||
const char* profile = getenv("ITERM_PROFILE");
|
||||
if (profile == NULL)
|
||||
if (profile == nullptr)
|
||||
{
|
||||
ffStrbufAppendS(&terminalFont->error, "environment variable ITERM_PROFILE not set");
|
||||
return;
|
||||
|
||||
@@ -15,24 +15,24 @@ static const char* getSystemMonospaceFont(void) {
|
||||
const FFDisplayServerResult* wmde = ffConnectDisplayServer();
|
||||
|
||||
if (ffStrbufIgnCaseEqualS(&wmde->dePrettyName, "Cinnamon")) {
|
||||
const char* systemMonospaceFont = ffSettingsGetGnome("/org/cinnamon/desktop/interface/monospace-font-name", "org.cinnamon.desktop.interface", NULL, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
const char* systemMonospaceFont = ffSettingsGetGnome("/org/cinnamon/desktop/interface/monospace-font-name", "org.cinnamon.desktop.interface", nullptr, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
if (ffStrSet(systemMonospaceFont)) {
|
||||
return systemMonospaceFont;
|
||||
}
|
||||
} else if (ffStrbufIgnCaseEqualS(&wmde->dePrettyName, "Mate")) {
|
||||
const char* systemMonospaceFont = ffSettingsGetGnome("/org/mate/interface/monospace-font-name", "org.mate.interface", NULL, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
const char* systemMonospaceFont = ffSettingsGetGnome("/org/mate/interface/monospace-font-name", "org.mate.interface", nullptr, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
if (ffStrSet(systemMonospaceFont)) {
|
||||
return systemMonospaceFont;
|
||||
}
|
||||
}
|
||||
|
||||
return ffSettingsGetGnome("/org/gnome/desktop/interface/monospace-font-name", "org.gnome.desktop.interface", NULL, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
return ffSettingsGetGnome("/org/gnome/desktop/interface/monospace-font-name", "org.gnome.desktop.interface", nullptr, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
}
|
||||
|
||||
static void detectKgx(FFTerminalFontResult* terminalFont) {
|
||||
// kgx (gnome console) doesn't support profiles
|
||||
if (!ffSettingsGetGnome("/org/gnome/Console/use-system-font", "org.gnome.Console", NULL, "use-system-font", FF_VARIANT_TYPE_BOOL).boolValue) {
|
||||
FF_AUTO_FREE const char* fontName = ffSettingsGetGnome("/org/gnome/Console/custom-font", "org.gnome.Console", NULL, "custom-font", FF_VARIANT_TYPE_STRING).strValue;
|
||||
if (!ffSettingsGetGnome("/org/gnome/Console/use-system-font", "org.gnome.Console", nullptr, "use-system-font", FF_VARIANT_TYPE_BOOL).boolValue) {
|
||||
FF_AUTO_FREE const char* fontName = ffSettingsGetGnome("/org/gnome/Console/custom-font", "org.gnome.Console", nullptr, "custom-font", FF_VARIANT_TYPE_STRING).strValue;
|
||||
if (ffStrSet(fontName)) {
|
||||
ffFontInitPango(&terminalFont->font, fontName);
|
||||
} else {
|
||||
@@ -49,8 +49,8 @@ static void detectKgx(FFTerminalFontResult* terminalFont) {
|
||||
}
|
||||
|
||||
static void detectPtyxis(FFTerminalFontResult* terminalFont) {
|
||||
if (!ffSettingsGetGnome("/org/gnome/Ptyxis/use-system-font", "org.gnome.Ptyxis", NULL, "use-system-font", FF_VARIANT_TYPE_BOOL).boolValue) {
|
||||
FF_AUTO_FREE const char* fontName = ffSettingsGetGnome("/org/gnome/Ptyxis/font-name", "org.gnome.Ptyxis", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
if (!ffSettingsGetGnome("/org/gnome/Ptyxis/use-system-font", "org.gnome.Ptyxis", nullptr, "use-system-font", FF_VARIANT_TYPE_BOOL).boolValue) {
|
||||
FF_AUTO_FREE const char* fontName = ffSettingsGetGnome("/org/gnome/Ptyxis/font-name", "org.gnome.Ptyxis", nullptr, "font-name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
if (ffStrSet(fontName)) {
|
||||
ffFontInitPango(&terminalFont->font, fontName);
|
||||
} else {
|
||||
@@ -67,7 +67,7 @@ static void detectPtyxis(FFTerminalFontResult* terminalFont) {
|
||||
}
|
||||
|
||||
static void detectFromGSettings(const char* profilePath, const char* profileList, const char* profile, const char* defaultProfileKey, FFTerminalFontResult* terminalFont) {
|
||||
FF_AUTO_FREE const char* defaultProfile = ffSettingsGetGSettings(profileList, NULL, defaultProfileKey, FF_VARIANT_TYPE_STRING).strValue;
|
||||
FF_AUTO_FREE const char* defaultProfile = ffSettingsGetGSettings(profileList, nullptr, defaultProfileKey, FF_VARIANT_TYPE_STRING).strValue;
|
||||
if (!ffStrSet(defaultProfile)) {
|
||||
ffStrbufAppendF(&terminalFont->error, "Could not get default profile from gsettings: %s", profileList);
|
||||
return;
|
||||
@@ -172,7 +172,7 @@ static void detectDeepinTerminal(FFTerminalFontResult* terminalFont) {
|
||||
FILE* file = fopen(profile.chars, "r");
|
||||
|
||||
if (file) {
|
||||
char* line = NULL;
|
||||
char* line = nullptr;
|
||||
size_t len = 0;
|
||||
|
||||
for (int count = 0; getline(&line, &len, file) != -1 && count < 2;) {
|
||||
@@ -230,7 +230,7 @@ static void detectFootTerminal(FFTerminalFontResult* terminalFont) {
|
||||
}
|
||||
ffFontInitValues(&terminalFont->font, font.chars, &font.chars[size]);
|
||||
if (comma < font.length) {
|
||||
ffFontInitValues(&terminalFont->fallback, &font.chars[comma + 1], NULL);
|
||||
ffFontInitValues(&terminalFont->fallback, &font.chars[comma + 1], nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ static void detectWarp(FFTerminalFontResult* terminalFont) {
|
||||
ffStrbufSet(&baseDir, dirPrefix);
|
||||
ffStrbufAppendS(&baseDir, "warp-terminal/user_preferences.json");
|
||||
|
||||
yyjson_doc* doc = yyjson_read_file(baseDir.chars, YYJSON_READ_INSITU | YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_COMMENTS, NULL, NULL);
|
||||
yyjson_doc* doc = yyjson_read_file(baseDir.chars, YYJSON_READ_INSITU | YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_COMMENTS, nullptr, nullptr);
|
||||
if (!doc) {
|
||||
continue;
|
||||
}
|
||||
@@ -434,7 +434,7 @@ static void detectUrxvt(FFTerminalFontResult* terminalFont) {
|
||||
|
||||
uint32_t index = 0;
|
||||
|
||||
char* line = NULL;
|
||||
char* line = nullptr;
|
||||
size_t len = 0;
|
||||
while (ffStrbufGetdelim(&line, &len, ',', &buffer)) {
|
||||
FFfont* font = index == 0 ? &terminalFont->font : &terminalFont->fallback;
|
||||
|
||||
@@ -33,7 +33,7 @@ static const char* detectWTProfile(yyjson_val* profile, FFstrbuf* name, double*
|
||||
*size = unsafe_yyjson_get_num(psize);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static inline void wrapYyjsonFree(yyjson_doc** doc) {
|
||||
@@ -44,7 +44,7 @@ static inline void wrapYyjsonFree(yyjson_doc** doc) {
|
||||
}
|
||||
|
||||
static const char* detectFromWTImpl(FFstrbuf* content, FFstrbuf* name, double* size) {
|
||||
yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(content->chars, content->length, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS, NULL, NULL);
|
||||
yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(content->chars, content->length, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS, nullptr, nullptr);
|
||||
if (!doc) {
|
||||
return "Failed to parse WT JSON config file";
|
||||
}
|
||||
@@ -86,13 +86,13 @@ static const char* detectFromWTImpl(FFstrbuf* content, FFstrbuf* name, double* s
|
||||
if (*size < 0) {
|
||||
*size = 12;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void detectFromWindowsTerminal(const FFstrbuf* terminalExe, FFTerminalFontResult* terminalFont) {
|
||||
// https://learn.microsoft.com/en-us/windows/terminal/install#settings-json-file
|
||||
FF_STRBUF_AUTO_DESTROY json = ffStrbufCreate();
|
||||
const char* error = NULL;
|
||||
const char* error = nullptr;
|
||||
|
||||
if (terminalExe && ffIsAbsolutePath(terminalExe->chars)) {
|
||||
FF_STRBUF_AUTO_DESTROY jsonPath = ffStrbufCreateA(MAX_PATH);
|
||||
@@ -106,8 +106,8 @@ static void detectFromWindowsTerminal(const FFstrbuf* terminalExe, FFTerminalFon
|
||||
error = "Error reading Windows Terminal portable settings JSON file";
|
||||
}
|
||||
} else {
|
||||
PWSTR localAppDataW = NULL;
|
||||
if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_LocalAppData, KF_FLAG_DEFAULT, NULL, &localAppDataW))) {
|
||||
PWSTR localAppDataW = nullptr;
|
||||
if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_LocalAppData, KF_FLAG_DEFAULT, nullptr, &localAppDataW))) {
|
||||
ffStrbufSetWS(&jsonPath, localAppDataW);
|
||||
CoTaskMemFree(localAppDataW);
|
||||
|
||||
@@ -146,7 +146,7 @@ static void detectFromWindowsTerminal(const FFstrbuf* terminalExe, FFTerminalFon
|
||||
"else if exist \"%LOCALAPPDATA%\\Microsoft\\Windows Terminal\\settings.json\" "
|
||||
"( type %LOCALAPPDATA%\\Microsoft\\Windows Terminal\\settings.json ) "
|
||||
"else ( call )",
|
||||
NULL });
|
||||
nullptr });
|
||||
}
|
||||
|
||||
if (error) {
|
||||
@@ -242,7 +242,7 @@ static void detectConEmu(FFTerminalFontResult* terminalFont) {
|
||||
}
|
||||
|
||||
static void detectWarp(FFTerminalFontResult* terminalFont) {
|
||||
FF_AUTO_CLOSE_FD HANDLE key = NULL;
|
||||
FF_AUTO_CLOSE_FD HANDLE key = nullptr;
|
||||
if (!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Warp.dev\\Warp", &key, &terminalFont->error)) {
|
||||
return;
|
||||
}
|
||||
@@ -261,7 +261,7 @@ static void detectWarp(FFTerminalFontResult* terminalFont) {
|
||||
|
||||
FFstrbuf* fontWeight = FF_LIST_ADD(FFstrbuf, terminalFont->font.styles);
|
||||
ffStrbufInit(fontWeight);
|
||||
if (ffRegReadStrbuf(key, L"FontWeight", fontWeight, NULL)) {
|
||||
if (ffRegReadStrbuf(key, L"FontWeight", fontWeight, nullptr)) {
|
||||
ffStrbufTrim(fontWeight, '"');
|
||||
} else {
|
||||
ffStrbufSetStatic(fontWeight, "Normal");
|
||||
|
||||
Reference in New Issue
Block a user