Logo: treat a "$" ending a line or the logo as a plain dollar (#2667)

Fixes #2666
This commit is contained in:
berce
2026-10-23 10:28:06 +03:00
committed by GitHub
parent bbb92543b0
commit bfe74b8437
2 changed files with 15 additions and 2 deletions
+5 -2
View File
@@ -143,10 +143,13 @@ static void logoLineCacheBuild(FFLogoLineCacheState* cache, const char* data, bo
if (doColorReplacement && *data == '$') {
++data;
if (*data == '$' || *data == '\0') {
// `$$` is an escaped dollar; a `$` ending a line or the logo is a plain one
if (*data == '$' || *data == '\0' || *data == '\n' || *data == '\r') {
ffStrbufAppendC(&line, '$');
++lineWidth;
++data;
if (*data == '$') {
++data;
}
continue;
}
+10
View File
@@ -1,5 +1,6 @@
#include "logo/logo.h"
#include "common/textModifier.h"
#include "fastfetch.h"
#include <stdio.h>
#include <stdlib.h>
@@ -55,6 +56,15 @@ int main(void) {
VERIFY(strcmp(ffLogoPositionToString(FF_LOGO_POSITION_TOP), "top") == 0);
VERIFY(strcmp(ffLogoPositionToString(FF_LOGO_POSITION_RIGHT), "right") == 0);
// A `$` ending a line or the logo is a plain dollar: it keeps the line break and the terminator.
instance.config.display.pipe = true;
ffLogoPrintChars("ab$\ncd", true);
VERIFY(instance.state.logoHeight == 1 && instance.state.logoWidth == 3);
ffLogoPrintChars("ab$", true);
VERIFY(instance.state.logoHeight == 0 && instance.state.logoWidth == 3);
ffLogoPrintChars("a$1b$$c", true);
VERIFY(instance.state.logoWidth == 4);
puts("\033[32mAll tests passed!" FASTFETCH_TEXT_MODIFIER_RESET);
return 0;
}