Fastfetch: unescape strings only when parsing .conf files

So that `NO_CONFIG=1 ./fastfetch --os-key \\\\ -s os -l none` prints `\\: *`
This commit is contained in:
李通洲
2023-08-15 16:39:20 +08:00
parent 2b2ebe0823
commit 8835f66b8c
5 changed files with 47 additions and 37 deletions
+2 -34
View File
@@ -36,7 +36,7 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFstrb
ffParseFormatString(&key, customKeyFormat, 1, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex}
});
ffPrintUserString(key.chars);
ffStrbufWriteTo(&key, stdout);
}
if(!instance.config.pipe)
@@ -56,8 +56,7 @@ void ffPrintFormatString(const char* moduleName, uint8_t moduleIndex, const FFst
if(buffer.length > 0)
{
ffPrintLogoAndKey(moduleName, moduleIndex, customKeyFormat, customKeyColor);
ffPrintUserString(buffer.chars);
putchar('\n');
ffStrbufPutTo(&buffer, stdout);
}
}
@@ -125,34 +124,3 @@ void ffPrintCharTimes(char c, uint32_t times)
if(remaining > 0)
fwrite(str, 1, remaining, stdout);
}
void ffPrintUserString(const char* value)
{
while(*value != '\0')
{
if(*value != '\\')
{
putchar(*value);
++value;
continue;
}
++value;
if(*value == 'n')
putchar('\n');
else if(*value == 't')
putchar('\t');
else if(*value == 'e')
putchar('\e');
else if(*value == '\\')
putchar('\\');
else
{
putchar('\\');
putchar(*value);
}
++value;
}
}
-1
View File
@@ -13,6 +13,5 @@ FF_C_PRINTF(5, 6) void ffPrintErrorString(const char* moduleName, uint8_t module
FF_C_PRINTF(4, 5) void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...);
void ffPrintColor(const FFstrbuf* colorValue);
void ffPrintCharTimes(char c, uint32_t times);
void ffPrintUserString(const char* str);
#endif