mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-28 15:53:51 +01:00
Global: replaces NULL to nullptr
This commit is contained in:
@@ -12,7 +12,7 @@ bool ffDetectWmTheme(FFstrbuf* themeOrError)
|
||||
BApplication app("application/x-vnd.fastfetch-cli-fastfetch");
|
||||
|
||||
DecorInfoUtility *util = new DecorInfoUtility();
|
||||
DecorInfo* decor = NULL;
|
||||
DecorInfo* decor = nullptr;
|
||||
|
||||
if (util) {
|
||||
decor = util->CurrentDecorator();
|
||||
|
||||
@@ -15,7 +15,7 @@ static bool detectWMThemeFromConfigFile(const char* configFile, const char* them
|
||||
}
|
||||
|
||||
if (themeOrError->length == 0) {
|
||||
if (defaultValue == NULL) {
|
||||
if (defaultValue == nullptr) {
|
||||
ffStrbufAppendF(themeOrError, "Couldn't find WM theme in %s", configFile);
|
||||
return false;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ ok:
|
||||
}
|
||||
|
||||
static bool detectMutter(FFstrbuf* themeOrError) {
|
||||
const char* theme = ffSettingsGetGnome("/org/gnome/shell/extensions/user-theme/name", "org.gnome.shell.extensions.user-theme", NULL, "name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
const char* theme = ffSettingsGetGnome("/org/gnome/shell/extensions/user-theme/name", "org.gnome.shell.extensions.user-theme", nullptr, "name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
if (ffStrSet(theme)) {
|
||||
ffStrbufAppendS(themeOrError, theme);
|
||||
return true;
|
||||
@@ -87,20 +87,20 @@ static bool detectMutter(FFstrbuf* themeOrError) {
|
||||
}
|
||||
|
||||
static bool detectMuffin(FFstrbuf* themeOrError) {
|
||||
FF_AUTO_FREE const char* name = ffSettingsGetGnome("/org/cinnamon/theme/name", "org.cinnamon.theme", NULL, "name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
FF_AUTO_FREE const char* theme = ffSettingsGetGnome("/org/cinnamon/desktop/wm/preferences/theme", "org.cinnamon.desktop.wm.preferences", NULL, "theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||
FF_AUTO_FREE const char* name = ffSettingsGetGnome("/org/cinnamon/theme/name", "org.cinnamon.theme", nullptr, "name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
FF_AUTO_FREE const char* theme = ffSettingsGetGnome("/org/cinnamon/desktop/wm/preferences/theme", "org.cinnamon.desktop.wm.preferences", nullptr, "theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||
|
||||
if (name == NULL && theme == NULL) {
|
||||
if (name == nullptr && theme == nullptr) {
|
||||
ffStrbufAppendS(themeOrError, "Couldn't find muffin theme in GSettings / DConf");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (name == NULL) {
|
||||
if (name == nullptr) {
|
||||
ffStrbufAppendS(themeOrError, theme);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (theme == NULL) {
|
||||
if (theme == nullptr) {
|
||||
ffStrbufAppendS(themeOrError, name);
|
||||
return true;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ static bool detectMuffin(FFstrbuf* themeOrError) {
|
||||
static bool detectXFWM4(FFstrbuf* themeOrError) {
|
||||
const char* theme = ffSettingsGetXFConf("xfwm4", "/general/theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||
|
||||
if (theme == NULL) {
|
||||
if (theme == nullptr) {
|
||||
ffStrbufAppendS(themeOrError, "Couldn't find xfwm4::/general/theme in XFConf");
|
||||
return false;
|
||||
}
|
||||
@@ -142,22 +142,22 @@ static bool detectOpenbox(const FFstrbuf* dePrettyName, FFstrbuf* themeOrError)
|
||||
}
|
||||
|
||||
const char* themeStart = strstr(content.chars, "<theme>");
|
||||
if (themeStart == NULL) {
|
||||
if (themeStart == nullptr) {
|
||||
goto theme_not_found;
|
||||
}
|
||||
|
||||
const char* themeEnd = strstr(themeStart, "</theme>");
|
||||
if (__builtin_expect(themeEnd == NULL, false)) { // very rare case
|
||||
if (__builtin_expect(themeEnd == nullptr, false)) { // very rare case
|
||||
goto theme_not_found;
|
||||
}
|
||||
|
||||
const char* nameStart = strstr(themeStart, "<name>");
|
||||
if (nameStart == NULL) {
|
||||
if (nameStart == nullptr) {
|
||||
goto name_not_found;
|
||||
}
|
||||
|
||||
const char* nameEnd = strstr(nameStart, "</name>");
|
||||
if (nameEnd == NULL || nameEnd > themeEnd) { // (nameEnd > themeEnd) means name is not a theme's child
|
||||
if (nameEnd == nullptr || nameEnd > themeEnd) { // (nameEnd > themeEnd) means name is not a theme's child
|
||||
goto name_not_found;
|
||||
}
|
||||
|
||||
@@ -216,9 +216,9 @@ static bool detectCosmicComp(FFstrbuf* themeOrError) {
|
||||
ffStrbufAppendF(&path, "com.system76.CosmicTheme.%s/v1/accent", variant);
|
||||
if (ffReadFileBuffer(path.chars, &accent)) {
|
||||
const char* baseStart = strstr(accent.chars, "base:");
|
||||
if (baseStart != NULL) {
|
||||
if (baseStart != nullptr) {
|
||||
const char* contentStart = strchr(baseStart, '(');
|
||||
if (contentStart != NULL) {
|
||||
if (contentStart != nullptr) {
|
||||
int depth = 1;
|
||||
const char* contentEnd = contentStart + 1;
|
||||
while (*contentEnd != '\0' && depth > 0) {
|
||||
@@ -237,13 +237,13 @@ static bool detectCosmicComp(FFstrbuf* themeOrError) {
|
||||
const char* key =
|
||||
i == 0 ? "red:" : (i == 1 ? "green:" : (i == 2 ? "blue:" : "alpha:"));
|
||||
const char* componentStart = strstr(contentStart, key);
|
||||
if (componentStart == NULL || componentStart >= contentEnd) {
|
||||
if (componentStart == nullptr || componentStart >= contentEnd) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
|
||||
componentStart += strlen(key);
|
||||
char* componentEnd = NULL;
|
||||
char* componentEnd = nullptr;
|
||||
double value = strtod(componentStart, &componentEnd);
|
||||
if (componentEnd == componentStart) {
|
||||
ok = false;
|
||||
@@ -323,7 +323,7 @@ bool ffDetectWmTheme(FFstrbuf* themeOrError) {
|
||||
}
|
||||
|
||||
if (ffStrbufIgnCaseEqualS(&wm->wmPrettyName, FF_WM_PRETTY_MARCO)) {
|
||||
return detectWMThemeFromSettings("/org/mate/Marco/general/theme", "org.mate.Marco.general", NULL, "theme", themeOrError);
|
||||
return detectWMThemeFromSettings("/org/mate/Marco/general/theme", "org.mate.Marco.general", nullptr, "theme", themeOrError);
|
||||
}
|
||||
|
||||
if (ffStrbufIgnCaseEqualS(&wm->wmPrettyName, FF_WM_PRETTY_OPENBOX)) {
|
||||
|
||||
@@ -105,16 +105,16 @@ const char* colorHexToString(DWORD hex) {
|
||||
case 0xFFFFFF:
|
||||
return "White";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool ffDetectWmTheme(FFstrbuf* themeOrError) {
|
||||
{
|
||||
FF_AUTO_CLOSE_FD HANDLE hKey = NULL;
|
||||
if (ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes", &hKey, NULL)) {
|
||||
FF_AUTO_CLOSE_FD HANDLE hKey = nullptr;
|
||||
if (ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes", &hKey, nullptr)) {
|
||||
FF_STRBUF_AUTO_DESTROY theme = ffStrbufCreate();
|
||||
if (ffRegReadStrbuf(hKey, L"CurrentTheme", &theme, NULL)) {
|
||||
if (ffRegReadStrbuf(hKey, L"CurrentTheme", &theme, nullptr)) {
|
||||
ffStrbufSubstrBeforeLastC(&theme, '.');
|
||||
ffStrbufSubstrAfterLastC(&theme, '\\');
|
||||
if (isalpha(theme.chars[0])) {
|
||||
@@ -129,11 +129,11 @@ bool ffDetectWmTheme(FFstrbuf* themeOrError) {
|
||||
do {
|
||||
uint32_t rgbColor;
|
||||
uint32_t bgrColor;
|
||||
FF_AUTO_CLOSE_FD HANDLE hKey = NULL;
|
||||
if (ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\DWM", &hKey, NULL)) {
|
||||
if (ffRegReadUint(hKey, L"AccentColor", &bgrColor, NULL)) {
|
||||
FF_AUTO_CLOSE_FD HANDLE hKey = nullptr;
|
||||
if (ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\DWM", &hKey, nullptr)) {
|
||||
if (ffRegReadUint(hKey, L"AccentColor", &bgrColor, nullptr)) {
|
||||
rgbColor = ((bgrColor & 0xFF) << 16) | (bgrColor & 0xFF00) | ((bgrColor >> 16) & 0xFF);
|
||||
} else if (ffRegReadUint(hKey, L"ColorizationColor", &rgbColor, NULL)) {
|
||||
} else if (ffRegReadUint(hKey, L"ColorizationColor", &rgbColor, nullptr)) {
|
||||
rgbColor &= 0xFFFFFF;
|
||||
} else {
|
||||
break;
|
||||
@@ -154,14 +154,14 @@ bool ffDetectWmTheme(FFstrbuf* themeOrError) {
|
||||
} while (false);
|
||||
|
||||
{
|
||||
FF_AUTO_CLOSE_FD HANDLE hKey = NULL;
|
||||
if (ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", &hKey, NULL)) {
|
||||
FF_AUTO_CLOSE_FD HANDLE hKey = nullptr;
|
||||
if (ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", &hKey, nullptr)) {
|
||||
uint32_t system = 1, apps = 1;
|
||||
if (ffRegReadValues(hKey, 2, (FFRegValueArg[]) {
|
||||
FF_ARG(system, L"SystemUsesLightTheme"),
|
||||
FF_ARG(apps, L"AppsUseLightTheme"),
|
||||
},
|
||||
NULL)) {
|
||||
nullptr)) {
|
||||
bool paren = themeOrError->length > 0;
|
||||
if (paren) {
|
||||
ffStrbufAppendS(themeOrError, " (");
|
||||
|
||||
Reference in New Issue
Block a user