mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-28 15:53:51 +01:00
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:
@@ -2,8 +2,7 @@
|
||||
#include "common/processing.h"
|
||||
#include "common/FFstrbuf.h"
|
||||
|
||||
typedef struct FFCommandResultBundle
|
||||
{
|
||||
typedef struct FFCommandResultBundle {
|
||||
FFProcessHandle handle;
|
||||
const char* error;
|
||||
} FFCommandResultBundle;
|
||||
@@ -13,26 +12,25 @@ static FFlist commandQueue = {
|
||||
.elementSize = sizeof(FFCommandResultBundle),
|
||||
};
|
||||
|
||||
static const char* spawnProcess(FFCommandOptions* options, FFProcessHandle* handle)
|
||||
{
|
||||
if (options->text.length == 0)
|
||||
static const char* spawnProcess(FFCommandOptions* options, FFProcessHandle* handle) {
|
||||
if (options->text.length == 0) {
|
||||
return "No command text specified";
|
||||
}
|
||||
|
||||
return ffProcessSpawn(options->param.length ? (char* const[]){
|
||||
options->shell.chars,
|
||||
options->param.chars,
|
||||
options->text.chars,
|
||||
NULL
|
||||
} : (char* const[]){
|
||||
options->shell.chars,
|
||||
options->text.chars,
|
||||
NULL
|
||||
}, options->useStdErr, handle);
|
||||
return ffProcessSpawn(options->param.length ? (char* const[]) {
|
||||
options->shell.chars,
|
||||
options->param.chars,
|
||||
options->text.chars,
|
||||
NULL}
|
||||
: (char* const[]) {options->shell.chars, options->text.chars, NULL},
|
||||
options->useStdErr,
|
||||
handle);
|
||||
}
|
||||
|
||||
bool ffPrepareCommand(FFCommandOptions* options)
|
||||
{
|
||||
if (!options->parallel) return false;
|
||||
bool ffPrepareCommand(FFCommandOptions* options) {
|
||||
if (!options->parallel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FFCommandResultBundle* bundle = ffListAdd(&commandQueue);
|
||||
bundle->error = spawnProcess(options, &bundle->handle);
|
||||
@@ -40,20 +38,22 @@ bool ffPrepareCommand(FFCommandOptions* options)
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* ffDetectCommand(FFCommandOptions* options, FFstrbuf* result)
|
||||
{
|
||||
const char* ffDetectCommand(FFCommandOptions* options, FFstrbuf* result) {
|
||||
FFCommandResultBundle bundle = {};
|
||||
if (!options->parallel)
|
||||
if (!options->parallel) {
|
||||
bundle.error = spawnProcess(options, &bundle.handle);
|
||||
else if (!ffListShift(&commandQueue, &bundle))
|
||||
} else if (!ffListShift(&commandQueue, &bundle)) {
|
||||
return "[BUG] command queue is empty";
|
||||
}
|
||||
|
||||
if (bundle.error)
|
||||
if (bundle.error) {
|
||||
return bundle.error;
|
||||
}
|
||||
|
||||
bundle.error = ffProcessReadOutput(&bundle.handle, result);
|
||||
if (bundle.error)
|
||||
if (bundle.error) {
|
||||
return bundle.error;
|
||||
}
|
||||
|
||||
ffStrbufTrimRightSpace(result);
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user