Chore: run clang-format

```bash
find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) ! -path "src/3rdparty/*" -print0 | xargs -0 clang-format -i
```
This commit is contained in:
李通洲
2026-03-29 09:28:49 +08:00
parent cdd4cee968
commit e0eba8ce21
690 changed files with 28093 additions and 30062 deletions
+1 -2
View File
@@ -2,8 +2,7 @@
#include "common/option.h"
typedef struct FFOSOptions
{
typedef struct FFOSOptions {
FFModuleArgs moduleArgs;
} FFOSOptions;
+74 -94
View File
@@ -7,140 +7,123 @@
#include <ctype.h>
static void buildOutputDefault(const FFOSResult* os, FFstrbuf* result)
{
//Create the basic output
if(os->name.length > 0)
static void buildOutputDefault(const FFOSResult* os, FFstrbuf* result) {
// Create the basic output
if (os->name.length > 0) {
ffStrbufAppend(result, &os->name);
else if(os->prettyName.length > 0)
} else if (os->prettyName.length > 0) {
ffStrbufAppend(result, &os->prettyName);
else if(os->id.length > 0)
} else if (os->id.length > 0) {
ffStrbufAppend(result, &os->id);
else
} else {
ffStrbufAppend(result, &instance.state.platform.sysinfo.name);
}
//Append code name if it is missing
if(os->codename.length > 0 && !ffStrbufContainIgnCase(result, &os->codename))
{
// Append code name if it is missing
if (os->codename.length > 0 && !ffStrbufContainIgnCase(result, &os->codename)) {
ffStrbufAppendC(result, ' ');
ffStrbufAppend(result, &os->codename);
}
//Append version if it is missing
if(os->versionID.length > 0 && !ffStrbufContainIgnCase(result, &os->versionID))
{
// Append version if it is missing
if (os->versionID.length > 0 && !ffStrbufContainIgnCase(result, &os->versionID)) {
ffStrbufAppendC(result, ' ');
ffStrbufAppend(result, &os->versionID);
}
else if(os->versionID.length == 0 && os->version.length > 0 && !ffStrbufContainIgnCase(result, &os->version))
{
} else if (os->versionID.length == 0 && os->version.length > 0 && !ffStrbufContainIgnCase(result, &os->version)) {
ffStrbufAppendC(result, ' ');
ffStrbufAppend(result, &os->version);
}
//Append variant if it is missing
if(os->variant.length > 0 && !ffStrbufContainIgnCase(result, &os->variant))
{
// Append variant if it is missing
if (os->variant.length > 0 && !ffStrbufContainIgnCase(result, &os->variant)) {
ffStrbufAppendS(result, " (");
ffStrbufAppend(result, &os->variant);
ffStrbufAppendC(result, ')');
}
else if(os->variant.length == 0 && os->variantID.length > 0 && !ffStrbufContainIgnCase(result, &os->variantID))
{
} else if (os->variant.length == 0 && os->variantID.length > 0 && !ffStrbufContainIgnCase(result, &os->variantID)) {
ffStrbufAppendS(result, " (");
ffStrbufAppend(result, &os->variantID);
ffStrbufAppendC(result, ')');
}
}
bool ffPrintOS(FFOSOptions* options)
{
bool ffPrintOS(FFOSOptions* options) {
const FFOSResult* os = ffDetectOS();
if(os->name.length == 0 && os->prettyName.length == 0 && os->id.length == 0)
{
if (os->name.length == 0 && os->prettyName.length == 0 && os->id.length == 0) {
ffPrintError(FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Could not detect OS");
return false;
}
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
if(options->moduleArgs.key.length == 0)
if (options->moduleArgs.key.length == 0) {
ffStrbufSetStatic(&key, FF_OS_MODULE_NAME);
else
{
} else {
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
FF_ARG(instance.state.platform.sysinfo.name, "sysname"),
FF_ARG(os->name, "name"),
FF_ARG(options->moduleArgs.keyIcon, "icon"),
}));
FF_ARG(instance.state.platform.sysinfo.name, "sysname"),
FF_ARG(os->name, "name"),
FF_ARG(options->moduleArgs.keyIcon, "icon"),
}));
}
if(options->moduleArgs.outputFormat.length == 0)
{
if (options->moduleArgs.outputFormat.length == 0) {
FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate();
if(os->prettyName.length > 0)
if (os->prettyName.length > 0) {
ffStrbufAppend(&result, &os->prettyName);
else
} else {
buildOutputDefault(os, &result);
}
//Append architecture if it is missing
if(!ffStrbufContainIgnCase(&result, &instance.state.platform.sysinfo.architecture))
{
// Append architecture if it is missing
if (!ffStrbufContainIgnCase(&result, &instance.state.platform.sysinfo.architecture)) {
ffStrbufAppendC(&result, ' ');
ffStrbufAppend(&result, &instance.state.platform.sysinfo.architecture);
}
ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY);
ffStrbufPutTo(&result, stdout);
}
else
{
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]){
FF_ARG(instance.state.platform.sysinfo.name, "sysname"),
FF_ARG(os->name, "name"),
FF_ARG(os->prettyName, "pretty-name"),
FF_ARG(os->id, "id"),
FF_ARG(os->idLike, "id-like"),
FF_ARG(os->variant, "variant"),
FF_ARG(os->variantID, "variant-id"),
FF_ARG(os->version, "version"),
FF_ARG(os->versionID, "version-id"),
FF_ARG(os->codename, "codename"),
FF_ARG(os->buildID, "build-id"),
FF_ARG(instance.state.platform.sysinfo.architecture, "arch"),
FF_ARG(instance.state.platform.sysinfo.release, "kernel-release"),
}));
} else {
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
FF_ARG(instance.state.platform.sysinfo.name, "sysname"),
FF_ARG(os->name, "name"),
FF_ARG(os->prettyName, "pretty-name"),
FF_ARG(os->id, "id"),
FF_ARG(os->idLike, "id-like"),
FF_ARG(os->variant, "variant"),
FF_ARG(os->variantID, "variant-id"),
FF_ARG(os->version, "version"),
FF_ARG(os->versionID, "version-id"),
FF_ARG(os->codename, "codename"),
FF_ARG(os->buildID, "build-id"),
FF_ARG(instance.state.platform.sysinfo.architecture, "arch"),
FF_ARG(instance.state.platform.sysinfo.release, "kernel-release"),
}));
}
return true;
}
void ffParseOSJsonObject(FFOSOptions* options, yyjson_val* module)
{
void ffParseOSJsonObject(FFOSOptions* options, yyjson_val* module) {
yyjson_val *key, *val;
size_t idx, max;
yyjson_obj_foreach(module, idx, max, key, val)
{
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
yyjson_obj_foreach (module, idx, max, key, val) {
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) {
continue;
}
ffPrintError(FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", unsafe_yyjson_get_str(key));
}
}
void ffGenerateOSJsonConfig(FFOSOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
void ffGenerateOSJsonConfig(FFOSOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
}
bool ffGenerateOSJsonResult(FF_MAYBE_UNUSED FFOSOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
bool ffGenerateOSJsonResult(FF_MAYBE_UNUSED FFOSOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
const FFOSResult* os = ffDetectOS();
if(os->name.length == 0 && os->prettyName.length == 0 && os->id.length == 0)
{
if (os->name.length == 0 && os->prettyName.length == 0 && os->id.length == 0) {
yyjson_mut_obj_add_str(doc, module, "error", "Could not detect OS");
return false;
}
@@ -160,33 +143,31 @@ bool ffGenerateOSJsonResult(FF_MAYBE_UNUSED FFOSOptions* options, yyjson_mut_doc
return true;
}
void ffInitOSOptions(FFOSOptions* options)
{
void ffInitOSOptions(FFOSOptions* options) {
ffOptionInitModuleArg(&options->moduleArgs,
#ifdef _WIN32
""
#elif __APPLE__
""
#elif __FreeBSD__
"󰣠"
#elif __ANDROID__
""
#elif __linux__
""
#elif __sun
""
#elif __OpenBSD__
""
#elif __Haiku__
""
#else
"󰢻"
#endif
#ifdef _WIN32
""
#elif __APPLE__
""
#elif __FreeBSD__
"󰣠"
#elif __ANDROID__
""
#elif __linux__
""
#elif __sun
""
#elif __OpenBSD__
""
#elif __Haiku__
""
#else
"󰢻"
#endif
);
}
void ffDestroyOSOptions(FFOSOptions* options)
{
void ffDestroyOSOptions(FFOSOptions* options) {
ffOptionDestroyModuleArg(&options->moduleArgs);
}
@@ -212,5 +193,4 @@ FFModuleBaseInfo ffOSModuleInfo = {
{"Version codename of the OS", "codename"},
{"Build ID of the OS", "build-id"},
{"Architecture of the OS", "arch"},
}))
};
}))};