From 3784e70c8258f5e479c744be489168ecae445e5c Mon Sep 17 00:00:00 2001 From: apocelipes Date: Sun, 5 May 2024 03:15:27 +0800 Subject: [PATCH] fastfetch: fix #868 Fix #868. --- src/common/commandoption.c | 4 ++-- src/common/jsonconfig.c | 2 +- src/fastfetch.c | 2 +- src/util/stringUtils.h | 5 +++++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/common/commandoption.c b/src/common/commandoption.c index e05cdbf92c..d1824d0fcf 100644 --- a/src/common/commandoption.c +++ b/src/common/commandoption.c @@ -11,7 +11,7 @@ bool ffParseModuleOptions(const char* key, const char* value) { - if (!ffStrStartsWith(key, "--") || !isalpha(key[2])) return false; + if (!ffStrStartsWith(key, "--") || !ffCharIsEnglishAlphabet(key[2])) return false; for (FFModuleBaseInfo** modules = ffModuleInfos[toupper(key[2]) - 'A']; *modules; ++modules) { @@ -102,7 +102,7 @@ static void parseStructureCommand( } } - if(isalpha(line[0])) + if(ffCharIsEnglishAlphabet(line[0])) { for (FFModuleBaseInfo** modules = ffModuleInfos[toupper(line[0]) - 'A']; *modules; ++modules) { diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 3131cd7503..de34b2b10c 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -94,7 +94,7 @@ static inline void genJsonResult(FFModuleBaseInfo* baseInfo, yyjson_mut_doc* doc static bool parseModuleJsonObject(const char* type, yyjson_val* jsonVal, yyjson_mut_doc* jsonDoc) { - if(!isalpha(type[0])) return false; + if(!ffCharIsEnglishAlphabet(type[0])) return false; for (FFModuleBaseInfo** modules = ffModuleInfos[toupper(type[0]) - 'A']; *modules; ++modules) { diff --git a/src/fastfetch.c b/src/fastfetch.c index 629c4dad0b..474abd78f5 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -249,7 +249,7 @@ static void printCommandHelp(const char* command) puts(FASTFETCH_DATATEXT_HELP_COLOR); else if(ffStrEqualsIgnCase(command, "format")) puts(FASTFETCH_DATATEXT_HELP_FORMAT); - else if(isalpha(command[0]) && ffStrEndsWithIgnCase(command, "-format")) // -format + else if(ffCharIsEnglishAlphabet(command[0]) && ffStrEndsWithIgnCase(command, "-format")) // -format printCommandFormatHelp(command); else if(!printSpecificCommandHelp(command)) fprintf(stderr, "Error: No specific help for command '%s' provided\n", command); diff --git a/src/util/stringUtils.h b/src/util/stringUtils.h index dd5d7e5ba1..ad24057b56 100644 --- a/src/util/stringUtils.h +++ b/src/util/stringUtils.h @@ -69,3 +69,8 @@ static inline bool ffStrContainsC(const char* str, char compareTo) { return strchr(str, compareTo) != NULL; } + +static inline bool ffCharIsEnglishAlphabet(char c) +{ + return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'); +}