From 25849dc4bbde57e0becb18eccc20e5d3f4b911f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 28 Oct 2023 23:39:15 +0800 Subject: [PATCH] Migration (Logo): fix `--logo-color-num` (v2) --- src/common/jsonconfig.h | 4 ++++ src/options/logo.c | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/common/jsonconfig.h b/src/common/jsonconfig.h index 917beadf2..12182855a 100644 --- a/src/common/jsonconfig.h +++ b/src/common/jsonconfig.h @@ -7,6 +7,10 @@ const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair p void ffPrintJsonConfig(bool prepare, yyjson_mut_doc* jsonDoc); void ffJsonConfigGenerateModuleArgsConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFModuleArgs* defaultModuleArgs, FFModuleArgs* moduleArgs); +yyjson_api_inline yyjson_mut_val* yyjson_mut_strbuf(yyjson_mut_doc *doc, const FFstrbuf* buf) { + return yyjson_mut_strncpy(doc, buf->chars, buf->length); +} + yyjson_api_inline bool yyjson_mut_obj_add_strbuf(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key, diff --git a/src/options/logo.c b/src/options/logo.c index 2b0daebe6..1d305e3b9 100644 --- a/src/options/logo.c +++ b/src/options/logo.c @@ -473,7 +473,10 @@ void ffOptionsGenerateLogoJsonConfig(FFOptionsLogo* options, yyjson_mut_doc* doc for (int i = 0; i < FASTFETCH_LOGO_MAX_COLORS; i++) { if (!ffStrbufEqual(&options->colors[i], &defaultOptions.colors[i])) - yyjson_mut_obj_add_strbuf(doc, color, (const char [2]) { (char)('1' + i) }, &options->colors[i]); + { + char c = (char)('1' + i); + yyjson_mut_obj_add(color, yyjson_mut_strncpy(doc, &c, 1), yyjson_mut_strbuf(doc, &options->colors[i])); + } } if (yyjson_mut_obj_size(color) > 0) yyjson_mut_obj_add_val(doc, obj, "color", color);