From e685a00a4b4c6c0b14d41f0ba712f324e5505ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 25 Jul 2023 14:53:57 +0800 Subject: [PATCH] FFstrbuf: remove ffStrbufRemoveStringsV; rename ffStrbufRemoveStringsA to ffStrbufRemoveStrings --- src/detection/cpu/cpu.c | 2 +- src/detection/gpu/gpu_linux.c | 2 +- .../terminalshell/terminalshell_linux.c | 2 +- src/detection/wmtheme/wmtheme_linux.c | 2 +- src/modules/media/media.c | 2 +- src/util/FFstrbuf.c | 16 +--------------- src/util/FFstrbuf.h | 4 +--- tests/strbuf.c | 2 +- 8 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/detection/cpu/cpu.c b/src/detection/cpu/cpu.c index 4fc6d34bc..b95a354ad 100644 --- a/src/detection/cpu/cpu.c +++ b/src/detection/cpu/cpu.c @@ -14,7 +14,7 @@ const char* ffDetectCPU(const FFCPUOptions* options, FFCPUResult* cpu) " 2-Core", " 4-Core", " 6-Core", " 8-Core", " 10-Core", " 12-Core", " 14-Core", " 16-Core", " with Radeon Graphics" }; - ffStrbufRemoveStringsA(&cpu->name, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings); + ffStrbufRemoveStrings(&cpu->name, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings); ffStrbufSubstrBeforeFirstC(&cpu->name, '@'); //Cut the speed output in the name as we append our own ffStrbufTrimRight(&cpu->name, ' '); //If we removed the @ in previous step there was most likely a space before it return NULL; diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index d59127e10..749072f46 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -80,7 +80,7 @@ static void drmDetectDeviceName(FFGPUResult* gpu, PCIData* pci, struct pci_dev* " (TM)", "(TM)", " Graphics Adapter", " Graphics", " Series", " Edition" }; - ffStrbufRemoveStringsA(&gpu->name, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings); + ffStrbufRemoveStrings(&gpu->name, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings); } static void pciDetectDeviceName(FFGPUResult* gpu, PCIData* pci, struct pci_dev* device) diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 5d578fff3..eede327c5 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -299,7 +299,7 @@ static void getShellVersionGeneric(FFstrbuf* exe, const char* exeName, FFstrbuf* NULL }); ffStrbufSubstrBeforeFirstC(version, '('); - ffStrbufRemoveStrings(version, 2, "-release", "release"); + ffStrbufRemoveStrings(version, 2, (const char*[]) { "-release", "release" }); } bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version); diff --git a/src/detection/wmtheme/wmtheme_linux.c b/src/detection/wmtheme/wmtheme_linux.c index ba1e172a1..92eac7cfb 100644 --- a/src/detection/wmtheme/wmtheme_linux.c +++ b/src/detection/wmtheme/wmtheme_linux.c @@ -164,7 +164,7 @@ static bool detectOpenbox(const FFstrbuf* dePrettyName, FFstrbuf* themeOrError) if(strstr(line, "") != 0) { ffStrbufAppendS(themeOrError, line); - ffStrbufRemoveStrings(themeOrError, 2, "", ""); + ffStrbufRemoveStrings(themeOrError, 2, (const char*[]) { "", "" }); ffStrbufTrimRight(themeOrError, '\n'); ffStrbufTrim(themeOrError, ' '); break; diff --git a/src/modules/media/media.c b/src/modules/media/media.c index e60b04698..f28852e8c 100644 --- a/src/modules/media/media.c +++ b/src/modules/media/media.c @@ -63,7 +63,7 @@ void ffPrintMedia(FFMediaOptions* options) "[Lyric Video]", "[Official Lyric Video]", "[Lyrics]", "| Lyric Video", "| Official Lyric Video", "| Lyrics", }; - ffStrbufRemoveStringsA(&songPretty, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings); + ffStrbufRemoveStrings(&songPretty, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings); ffStrbufTrimRight(&songPretty, ' '); if(songPretty.length == 0) diff --git a/src/util/FFstrbuf.c b/src/util/FFstrbuf.c index c05a7fa36..305c28dbb 100644 --- a/src/util/FFstrbuf.c +++ b/src/util/FFstrbuf.c @@ -269,26 +269,12 @@ void ffStrbufRemoveS(FFstrbuf* strbuf, const char* str) ffStrbufRemoveSubstr(strbuf, i, i + stringLength); } -void ffStrbufRemoveStringsA(FFstrbuf* strbuf, uint32_t numStrings, const char* strings[]) +void ffStrbufRemoveStrings(FFstrbuf* strbuf, uint32_t numStrings, const char* strings[]) { for(uint32_t i = 0; i < numStrings; i++) ffStrbufRemoveS(strbuf, strings[i]); } -void ffStrbufRemoveStringsV(FFstrbuf* strbuf, uint32_t numStrings, va_list arguments) -{ - for(uint32_t i = 0; i < numStrings; i++) - ffStrbufRemoveS(strbuf, va_arg(arguments, const char*)); -} - -void ffStrbufRemoveStrings(FFstrbuf* strbuf, uint32_t numStrings, ...) -{ - va_list argp; - va_start(argp, numStrings); - ffStrbufRemoveStringsV(strbuf, numStrings, argp); - va_end(argp); -} - uint32_t ffStrbufNextIndexC(const FFstrbuf* strbuf, uint32_t start, char c) { assert(start <= strbuf->length); diff --git a/src/util/FFstrbuf.h b/src/util/FFstrbuf.h index c47719679..e8d723f9d 100644 --- a/src/util/FFstrbuf.h +++ b/src/util/FFstrbuf.h @@ -59,9 +59,7 @@ void ffStrbufTrim(FFstrbuf* strbuf, char c); void ffStrbufRemoveSubstr(FFstrbuf* strbuf, uint32_t startIndex, uint32_t endIndex); void ffStrbufRemoveS(FFstrbuf* strbuf, const char* str); -void ffStrbufRemoveStringsA(FFstrbuf* strbuf, uint32_t numStrings, const char* strings[]); -void ffStrbufRemoveStringsV(FFstrbuf* strbuf, uint32_t numStrings, va_list arguments); -void ffStrbufRemoveStrings(FFstrbuf* strbuf, uint32_t numStrings, ...); +void ffStrbufRemoveStrings(FFstrbuf* strbuf, uint32_t numStrings, const char* strings[]); FF_C_NODISCARD uint32_t ffStrbufNextIndexC(const FFstrbuf* strbuf, uint32_t start, char c); FF_C_NODISCARD uint32_t ffStrbufNextIndexS(const FFstrbuf* strbuf, uint32_t start, const char* str); diff --git a/tests/strbuf.c b/tests/strbuf.c index 3df30af23..027cf2415 100644 --- a/tests/strbuf.c +++ b/tests/strbuf.c @@ -129,7 +129,7 @@ int main(void) //removeStrings - ffStrbufRemoveStrings(&strbuf, 3, "23", "45", "9"); + ffStrbufRemoveStrings(&strbuf, 3, (const char*[]) { "23", "45", "9" }); VERIFY(strbuf.length == 2); VERIFY(strcmp(strbuf.chars, "16") == 0);