Skip to content

Commit a87a047

Browse files
committed
Fastfetch: fix #517
1. Fix specifying `--set-keyless` with the same key second time won't override the value set before 2. Fix specifying `--color` second time won't clear the value set before
1 parent 97b779a commit a87a047

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Bugfixes:
4747
* Fix option `--title-fqdn` doesn't work (Title)
4848
* Fix used spaces calculation (Disk, Linux / BSD / macOS, #508)
4949
* Fix `--brightness-format` (Brightness)
50+
* Fix specifying `--set-keyless` with the same key second time won't override the value set before (#517)
51+
* Fix specifying `--color` second time won't clear the value set before (#517)
5052

5153
Logo:
5254
* Change the special handling of `kitty` protocol with `.png` image file to a new image protocol `kitty-direct`. This is the fastest image protocol because fastfetch doesn't need to pre-encode the image to base64 or something and the image content doesn't need to be transmitted via tty. Note:

src/common/option.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ bool ffOptionParseBoolean(const char* str)
132132

133133
void ffOptionParseColor(const char* value, FFstrbuf* buffer)
134134
{
135+
ffStrbufClear(buffer);
135136
ffStrbufEnsureFree(buffer, 63);
136137

137138
while(*value != '\0')

src/fastfetch.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,10 +861,24 @@ static void parseOption(FFdata* data, const char* key, const char* value)
861861
fprintf(stderr, "Error: usage: %s <key>=<str>\n", key);
862862
exit(477);
863863
}
864-
FFCustomValue* customValue = (FFCustomValue*) ffListAdd(&data->customValues);
865-
ffStrbufInitS(&customValue->value, &customValueStr.chars[index + 1]);
866-
ffStrbufSubstrBefore(&customValueStr, index);
867-
ffStrbufInitMove(&customValue->key, &customValueStr);
864+
865+
FF_STRBUF_AUTO_DESTROY customKey = ffStrbufCreateNS(index, customValueStr.chars);
866+
867+
FFCustomValue* customValue = NULL;
868+
FF_LIST_FOR_EACH(FFCustomValue, x, data->customValues)
869+
{
870+
if(ffStrbufEqual(&x->key, &customKey))
871+
{
872+
ffStrbufDestroy(&x->key);
873+
ffStrbufDestroy(&x->value);
874+
customValue = x;
875+
break;
876+
}
877+
}
878+
if(!customValue) customValue = (FFCustomValue*) ffListAdd(&data->customValues);
879+
ffStrbufInitMove(&customValue->key, &customKey);
880+
ffStrbufSubstrAfter(&customValueStr, index);
881+
ffStrbufInitMove(&customValue->value, &customValueStr);
868882
customValue->printKey = *subkey == '\0';
869883
}
870884

0 commit comments

Comments
 (0)