dep

Package manager for embedded C libraries
git clone git://git.finwo.net/app/dep
Log | Files | Refs | README | LICENSE

commit 27154a9aa1c0ced35baa991c14b25e240f1f9b1a
parent 70453235b61e0189aececa36a211cce7817c5410
Author: finwo <finwo@pm.me>
Date:   Fri, 13 Mar 2026 11:55:49 +0100

Auto-formatting

Diffstat:
A.clang-format | 334+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MMakefile | 3+++
Msrc/command/command.h | 6+++---
Msrc/command/license/license.h | 2+-
Msrc/command/license/main.c | 23+++++++++++------------
Msrc/main.c | 115+++++++++++++++++++++++++++++++++++++------------------------------------------
6 files changed, 406 insertions(+), 77 deletions(-)

diff --git a/.clang-format b/.clang-format @@ -0,0 +1,334 @@ +--- +Language: Cpp +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: true + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveMacros: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCaseArrows: false + AlignCaseColons: false +AlignConsecutiveTableGenBreakingDAGArgColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenCondOperatorColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenDefinitionColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: + Kind: Always + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowBreakBeforeNoexceptSpecifier: Never +AllowShortBlocksOnASingleLine: Never +AllowShortCaseExpressionOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: true +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: true +AllowShortNamespacesOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AttributeMacros: + - __capability + - absl_nonnull + - absl_nullable + - absl_nullability_unknown +BinPackArguments: true +BinPackLongBracedList: true +BinPackParameters: BinPack +BitFieldColonSpacing: Both +BracedInitializerIndentWidth: -1 +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterExternBlock: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAdjacentStringLiterals: true +BreakAfterAttributes: Leave +BreakAfterJavaFieldAnnotations: false +BreakAfterReturnType: None +BreakArrays: true +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Attach +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTemplateCloser: false +BreakBeforeTernaryOperators: true +BreakBinaryOperations: Never +BreakConstructorInitializers: BeforeColon +BreakFunctionDefinitionParameters: false +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +BreakTemplateDeclarations: Yes +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +EnumTrailingComma: Leave +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^<ext/.*\.h>' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^<.*\.h>' + Priority: 1 + SortPriority: 0 + CaseSensitive: false + - Regex: '^<.*' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 3 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '([-_](test|unittest))?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseBlocks: true +IndentCaseLabels: true +IndentExportBlock: true +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true +IndentPPDirectives: None +IndentRequiresClause: true +IndentWidth: 2 +IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: true +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigits: 0 + Decimal: 0 + DecimalMinDigits: 0 + Hex: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLines: + AtEndOfFile: false + AtStartOfBlock: false + AtStartOfFile: false +KeepFormFeed: false +LambdaBodyIndentation: Signature +LineEnding: DeriveLF +MacroBlockBegin: '' +MacroBlockEnd: '' +MainIncludeChar: Quote +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Never +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +OneLineFormatOffRegex: '' +PackConstructorInitializers: NextLine +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakBeforeMemberAccess: 150 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakScopeResolution: 500 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Right +PPIndentWidth: -1 +QualifierAlignment: Leave +RawStringFormats: + - Language: Cpp + Delimiters: + - cc + - CC + - cpp + - Cpp + - CPP + - 'c++' + - 'C++' + CanonicalDelimiter: '' + BasedOnStyle: google + - Language: TextProto + Delimiters: + - pb + - PB + - proto + - PROTO + EnclosingFunctions: + - EqualsProto + - EquivToProto + - PARSE_PARTIAL_TEXT_PROTO + - PARSE_TEST_PROTO + - PARSE_TEXT_PROTO + - ParseTextOrDie + - ParseTextProtoOrDie + - ParseTestProto + - ParsePartialTestProto + CanonicalDelimiter: pb + BasedOnStyle: google +ReferenceAlignment: Pointer +ReflowComments: Always +RemoveBracesLLVM: false +RemoveEmptyLinesInUnwrappedLines: false +RemoveParentheses: Leave +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SkipMacroDefinitionBody: false +SortIncludes: + Enabled: true + IgnoreCase: false +SortJavaStaticImport: Before +SortUsingDeclarations: LexicographicNumeric +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterOperatorKeyword: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterNot: false + AfterOverloadedOperator: false + AfterPlacementOperator: true + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: Never +SpacesInContainerLiterals: true +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParens: Never +SpacesInParensOptions: + ExceptDoubleParentheses: false + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false +SpacesInSquareBrackets: false +Standard: Auto +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TableGenBreakInsideDAGArg: DontBreak +TabWidth: 8 +UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: + - BOOST_PP_STRINGIZE + - CF_SWIFT_NAME + - NS_SWIFT_NAME + - PP_STRINGIZE + - STRINGIZE +WrapNamespaceBodyWithEmptyLines: Leave +... + diff --git a/Makefile b/Makefile @@ -73,3 +73,6 @@ dep: $(LIBS) $(OBJ) clean: rm -f $(OBJ) +.PHONY: format +format: + $(FIND) src/ -type f \( -name '*.c' -o -name '*.h' \) -exec clang-format -i {} + diff --git a/src/command/command.h b/src/command/command.h @@ -1,7 +1,7 @@ struct cmd_struct { - void *next; - const char *cmd; - int (*fn) (int, const char **); + void *next; + const char *cmd; + int (*fn)(int, const char **); }; extern struct cmd_struct *commands; diff --git a/src/command/license/license.h b/src/command/license/license.h @@ -4,4 +4,4 @@ extern const unsigned char _binary_LICENSE_md_start[]; extern const unsigned char _binary_LICENSE_md_end[]; -#endif // LICENSE_H +#endif // LICENSE_H diff --git a/src/command/license/main.c b/src/command/license/main.c @@ -5,20 +5,19 @@ #include "license.h" int cmd_license(int argc, const char **argv) { - (void)argc; - (void)argv; - const unsigned char *start = _binary_LICENSE_md_start; - const unsigned char *end = _binary_LICENSE_md_end; - size_t len = end - start; - fwrite(start, 1, len, stdout); - return 0; + (void)argc; + (void)argv; + const unsigned char *start = _binary_LICENSE_md_start; + const unsigned char *end = _binary_LICENSE_md_end; + size_t len = end - start; + fwrite(start, 1, len, stdout); + return 0; } void __attribute__((constructor)) cmd_license_setup() { struct cmd_struct *cmd = calloc(1, sizeof(struct cmd_struct)); - cmd->next = commands; - cmd->fn = cmd_license; - cmd->cmd = "license"; - commands = cmd; + cmd->next = commands; + cmd->fn = cmd_license; + cmd->cmd = "license"; + commands = cmd; } - diff --git a/src/main.c b/src/main.c @@ -3,11 +3,10 @@ #include <string.h> #include "cofyc/argparse.h" +#include "command/command.h" #include "erkkah/naett.h" #include "rxi/microtar.h" -#include "command/command.h" - #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) struct cmd_struct *commands = NULL; @@ -17,68 +16,62 @@ static const char *const usages[] = { NULL, }; -int -cmd_foo(int argc, const char **argv) -{ - printf("executing subcommand foo\n"); - printf("argc: %d\n", argc); - for (int i = 0; i < argc; i++) { - printf("argv[%d]: %s\n", i, *(argv + i)); - } - int force = 0; - int test = 0; - const char *path = NULL; - struct argparse_option options[] = { - OPT_HELP(), - OPT_BOOLEAN('f', "force", &force, "force to do", NULL, 0, 0), - OPT_BOOLEAN('t', "test", &test, "test only", NULL, 0, 0), - OPT_STRING('p', "path", &path, "path to read", NULL, 0, 0), - OPT_END(), - }; - struct argparse argparse; - argparse_init(&argparse, options, usages, 0); - argc = argparse_parse(&argparse, argc, argv); - printf("after argparse_parse:\n"); - printf("argc: %d\n", argc); - for (int i = 0; i < argc; i++) { - printf("argv[%d]: %s\n", i, *(argv + i)); - } - return 0; +int cmd_foo(int argc, const char **argv) { + printf("executing subcommand foo\n"); + printf("argc: %d\n", argc); + for (int i = 0; i < argc; i++) { + printf("argv[%d]: %s\n", i, *(argv + i)); + } + int force = 0; + int test = 0; + const char *path = NULL; + struct argparse_option options[] = { + OPT_HELP(), + OPT_BOOLEAN('f', "force", &force, "force to do", NULL, 0, 0), + OPT_BOOLEAN('t', "test", &test, "test only", NULL, 0, 0), + OPT_STRING('p', "path", &path, "path to read", NULL, 0, 0), + OPT_END(), + }; + struct argparse argparse; + argparse_init(&argparse, options, usages, 0); + argc = argparse_parse(&argparse, argc, argv); + printf("after argparse_parse:\n"); + printf("argc: %d\n", argc); + for (int i = 0; i < argc; i++) { + printf("argv[%d]: %s\n", i, *(argv + i)); + } + return 0; } -int -cmd_bar(int argc, const char **argv) -{ - printf("executing subcommand bar\n"); - for (int i = 0; i < argc; i++) { - printf("argv[%d]: %s\n", i, *(argv + i)); - } - return 0; +int cmd_bar(int argc, const char **argv) { + printf("executing subcommand bar\n"); + for (int i = 0; i < argc; i++) { + printf("argv[%d]: %s\n", i, *(argv + i)); + } + return 0; } -int -main(int argc, const char **argv) -{ - struct argparse argparse; - struct argparse_option options[] = { - OPT_HELP(), - OPT_END(), - }; - argparse_init(&argparse, options, usages, ARGPARSE_STOP_AT_NON_OPTION); - argc = argparse_parse(&argparse, argc, argv); - if (argc < 1) { - argparse_usage(&argparse); - return -1; - } +int main(int argc, const char **argv) { + struct argparse argparse; + struct argparse_option options[] = { + OPT_HELP(), + OPT_END(), + }; + argparse_init(&argparse, options, usages, ARGPARSE_STOP_AT_NON_OPTION); + argc = argparse_parse(&argparse, argc, argv); + if (argc < 1) { + argparse_usage(&argparse); + return -1; + } - /* Try to run command with args provided. */ - struct cmd_struct *cmd = commands; - while(cmd) { - if (!strcmp(cmd->cmd, argv[0])) break; - cmd = cmd->next; - } - if (cmd) { - return cmd->fn(argc, argv); - } - return 0; + /* Try to run command with args provided. */ + struct cmd_struct *cmd = commands; + while (cmd) { + if (!strcmp(cmd->cmd, argv[0])) break; + cmd = cmd->next; + } + if (cmd) { + return cmd->fn(argc, argv); + } + return 0; }