diff --git a/.clang-format b/.clang-format index 4a4552b..fbb6706 100644 --- a/.clang-format +++ b/.clang-format @@ -8,6 +8,7 @@ AlignConsecutiveAssignments: AcrossEmptyLines: false AcrossComments: false AlignCompound: false + AlignFunctionDeclarations: false AlignFunctionPointers: false PadOperators: true AlignConsecutiveBitFields: @@ -15,6 +16,7 @@ AlignConsecutiveBitFields: AcrossEmptyLines: false AcrossComments: false AlignCompound: false + AlignFunctionDeclarations: false AlignFunctionPointers: false PadOperators: true AlignConsecutiveDeclarations: @@ -22,6 +24,7 @@ AlignConsecutiveDeclarations: AcrossEmptyLines: false AcrossComments: false AlignCompound: false + AlignFunctionDeclarations: true AlignFunctionPointers: false PadOperators: true AlignConsecutiveMacros: @@ -29,13 +32,39 @@ AlignConsecutiveMacros: AcrossEmptyLines: false AcrossComments: false AlignCompound: false + AlignFunctionDeclarations: false AlignFunctionPointers: false PadOperators: true AlignConsecutiveShortCaseStatements: Enabled: false 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: Right AlignOperands: Align AlignTrailingComments: @@ -45,6 +74,7 @@ AllowAllArgumentsOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true AllowBreakBeforeNoexceptSpecifier: Never AllowShortBlocksOnASingleLine: Never +AllowShortCaseExpressionOnASingleLine: true AllowShortCaseLabelsOnASingleLine: false AllowShortCompoundRequirementOnASingleLine: true AllowShortEnumsOnASingleLine: true @@ -52,15 +82,16 @@ AllowShortFunctionsOnASingleLine: All AllowShortIfStatementsOnASingleLine: Never AllowShortLambdasOnASingleLine: All AllowShortLoopsOnASingleLine: false +AllowShortNamespacesOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: MultiLine AttributeMacros: - __capability BinPackArguments: true -BinPackParameters: true +BinPackLongBracedList: true +BinPackParameters: BinPack BitFieldColonSpacing: Both +BracedInitializerIndentWidth: -1 BraceWrapping: AfterCaseLabel: false AfterClass: false @@ -83,15 +114,20 @@ BraceWrapping: 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: MultiLine ColumnLimit: 80 CommentPragmas: '^ IWYU pragma:' CompactNamespaces: false @@ -102,6 +138,7 @@ DerivePointerAlignment: false DisableFormat: false EmptyLineAfterAccessModifier: Never EmptyLineBeforeAccessModifier: LogicalBlock +EnumTrailingComma: Leave ExperimentalAutoDetectBinPacking: false FixNamespaceComments: true ForEachMacros: @@ -129,6 +166,7 @@ IncludeIsMainSourceRegex: '' IndentAccessModifiers: false IndentCaseBlocks: false IndentCaseLabels: false +IndentExportBlock: true IndentExternBlock: AfterExternBlock IndentGotoLabels: true IndentPPDirectives: AfterHash @@ -147,12 +185,16 @@ IntegerLiteralSeparator: HexMinDigits: 0 JavaScriptQuotes: Leave JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: false -KeepEmptyLinesAtEOF: false +KeepEmptyLines: + AtEndOfFile: false + AtStartOfBlock: false + AtStartOfFile: true +KeepFormFeed: false LambdaBodyIndentation: Signature LineEnding: DeriveLF MacroBlockBegin: '' MacroBlockEnd: '' +MainIncludeChar: Quote MaxEmptyLinesToKeep: 1 NamespaceIndentation: None ObjCBinPackProtocolList: Auto @@ -160,9 +202,11 @@ ObjCBlockIndentWidth: 2 ObjCBreakBeforeNestedBlockParam: true ObjCSpaceAfterProperty: false ObjCSpaceBeforeProtocolList: true +OneLineFormatOffRegex: '' PackConstructorInitializers: NextLine PenaltyBreakAssignment: 2 PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakBeforeMemberAccess: 150 PenaltyBreakComment: 300 PenaltyBreakFirstLessLess: 120 PenaltyBreakOpenParenthesis: 0 @@ -176,8 +220,9 @@ PointerAlignment: Right PPIndentWidth: -1 QualifierAlignment: Leave ReferenceAlignment: Pointer -ReflowComments: true +ReflowComments: Always RemoveBracesLLVM: false +RemoveEmptyLinesInUnwrappedLines: false RemoveParentheses: Leave RemoveSemicolon: false RequiresClausePosition: OwnLine @@ -185,11 +230,14 @@ RequiresExpressionIndentation: OuterScope SeparateDefinitionBlocks: Leave ShortNamespaceLines: 1 SkipMacroDefinitionBody: false -SortIncludes: Never +SortIncludes: + Enabled: false + IgnoreCase: false SortJavaStaticImport: Before SortUsingDeclarations: LexicographicNumeric SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false +SpaceAfterOperatorKeyword: false SpaceAfterTemplateKeyword: true SpaceAroundPointerQualifiers: Default SpaceBeforeAssignmentOperators: true @@ -205,6 +253,7 @@ SpaceBeforeParensOptions: AfterFunctionDefinitionName: false AfterFunctionDeclarationName: false AfterIfMacros: true + AfterNot: false AfterOverloadedOperator: false AfterPlacementOperator: true AfterRequiresInClause: false @@ -221,6 +270,7 @@ SpacesInLineCommentPrefix: Maximum: -1 SpacesInParens: Never SpacesInParensOptions: + ExceptDoubleParentheses: false InCStyleCasts: false InConditionalStatements: false InEmptyParentheses: false @@ -233,6 +283,7 @@ StatementMacros: - Q_UNUSED - QT_REQUIRE_VERSION - munit_void_test_decl +TableGenBreakInsideDAGArg: DontBreak TabWidth: 8 UseTab: Never VerilogBreakBetweenInstancePorts: true @@ -242,5 +293,6 @@ WhitespaceSensitiveMacros: - BOOST_PP_STRINGIZE - NS_SWIFT_NAME - CF_SWIFT_NAME +WrapNamespaceBodyWithEmptyLines: Leave ... diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1bf10c5..2d3e14b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ jobs: build: strategy: matrix: - os: [ubuntu-24.04, ubuntu-24.04-arm, macos-26, macos-15] + os: [ubuntu-26.04, ubuntu-26.04-arm, macos-26, macos-15] compiler: [gcc, clang] runs-on: ${{ matrix.os }} @@ -23,7 +23,7 @@ jobs: sudo apt-get update sudo apt-get install \ g++-14 \ - clang-19 \ + clang-21 \ autoconf \ automake \ autotools-dev \ @@ -42,8 +42,8 @@ jobs: - name: Setup clang (Linux) if: runner.os == 'Linux' && matrix.compiler == 'clang' run: | - echo 'CC=clang-19' >> $GITHUB_ENV - echo 'CXX=clang++-19' >> $GITHUB_ENV + echo 'CC=clang-21' >> $GITHUB_ENV + echo 'CXX=clang++-21' >> $GITHUB_ENV - name: Setup clang (MacOS) if: runner.os == 'macOS' && matrix.compiler == 'clang' run: | @@ -83,7 +83,7 @@ jobs: matrix: host: [x86_64-w64-mingw32, i686-w64-mingw32] - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 env: HOST: ${{ matrix.host }} diff --git a/http_parser_compat_test.c b/http_parser_compat_test.c index f39cf76..ff8eba9 100644 --- a/http_parser_compat_test.c +++ b/http_parser_compat_test.c @@ -623,66 +623,38 @@ static const struct url_test url_tests[] = }, }; -static void dump_url(const char *url, const urlparse_url *u) { - size_t i; - - fprintf(stderr, "\tfield_set: 0x%x, port: %u\n", u->field_set, u->port); - for (i = 0; i < URLPARSE_MAX; i++) { - if ((u->field_set & (1 << i)) == 0) { - fprintf(stderr, "\tfield_data[%zu]: unset\n", i); - continue; - } - - fprintf(stderr, "\tfield_data[%zu]: off: %u len: %u part: \"%.*s\"\n", i, - u->field_data[i].off, u->field_data[i].len, u->field_data[i].len, - url + u->field_data[i].off); - } -} - void test_http_parser_compat(void) { urlparse_url u; const struct url_test *test; - size_t i; + size_t i, j; int rv; for (i = 0; i < (sizeof(url_tests) / sizeof(url_tests[0])); ++i) { test = &url_tests[i]; memset(&u, 0, sizeof(u)); + munit_log(MUNIT_LOG_INFO, test->name); + rv = urlparse_parse_url(test->url, test->url ? strlen(test->url) : 0, test->is_connect, &u); - if (test->rv == 0) { - if (rv != 0) { - fprintf(stderr, - "\n*** http_parser_parse_url(\"%s\") \"%s\" test failed, " - "unexpected rv %d ***\n\n", - test->url, test->name, rv); - - assert_int(0, ==, rv); - } + assert_int(test->rv, ==, rv); - if (memcmp(&u, &test->u, sizeof(u)) != 0) { - fprintf(stderr, - "\n*** http_parser_parse_url(\"%s\") \"%s\" failed ***\n", - test->url, test->name); + if (test->rv != 0) { + continue; + } - fprintf(stderr, "target http_parser_url:\n"); - dump_url(test->url, &test->u); - fprintf(stderr, "result http_parser_url:\n"); - dump_url(test->url, &u); + assert_uint16(test->u.field_set, ==, u.field_set); + assert_uint16(test->u.port, ==, u.port); - assert_memory_equal(sizeof(u), &test->u, &u); - } - } else { - /* test->rv != 0 */ - if (rv == 0) { - fprintf(stderr, - "\n*** http_parser_parse_url(\"%s\") \"%s\" test failed, " - "unexpected rv %d ***\n\n", - test->url, test->name, rv); + for (j = 0; j < URLPARSE_MAX; ++j) { + assert_uint16(test->u.field_data[j].off, ==, u.field_data[j].off); + assert_uint16(test->u.field_data[j].len, ==, u.field_data[j].len); - assert_int(test->rv, ==, rv); + if (test->u.field_set & (1 << j)) { + assert_memory_equal(test->u.field_data[j].len, + &test->url[test->u.field_data[j].off], + &test->url[u.field_data[j].off]); } } } diff --git a/urlparse_test.c b/urlparse_test.c index 7339a25..0f5c5cf 100644 --- a/urlparse_test.c +++ b/urlparse_test.c @@ -58,32 +58,23 @@ const MunitSuite urlparse_suite = { #define assert_field_unset(URL, FIELD) \ assert_false((URL).field_set & (1 << (FIELD))) -/* Copied from https://github.com/nodejs/http-parser */ -static void dump_url(const char *url, const urlparse_url *u) { - size_t i; - - fprintf(stderr, "\tfield_set: 0x%x, port: %u\n", u->field_set, u->port); - for (i = 0; i < URLPARSE_MAX; i++) { - if ((u->field_set & (1 << i)) == 0) { - fprintf(stderr, "\tfield_data[%zu]: unset\n", i); - continue; - } - - fprintf(stderr, "\tfield_data[%zu]: off: %u len: %u part: \"%.*s\"\n", i, - u->field_data[i].off, u->field_data[i].len, u->field_data[i].len, - url + u->field_data[i].off); - } -} - -#define assert_url(BUF, U1, U2) \ +#define assert_url(BUF, HU, U) \ do { \ - if (memcmp((U1), (U2), sizeof(urlparse_url)) == 0) { \ - break; \ - } \ + size_t i; \ \ - dump_url((BUF), (urlparse_url *)(U1)); \ - dump_url((BUF), (U2)); \ - assert_memory_equal(sizeof(urlparse_url), (U1), (U2)); \ + assert_uint16((HU)->field_set, ==, (U)->field_set); \ + assert_uint16((HU)->port, ==, (U)->port); \ + \ + for (i = 0; i < URLPARSE_MAX; ++i) { \ + assert_uint16((HU)->field_data[i].off, ==, (U)->field_data[i].off); \ + assert_uint16((HU)->field_data[i].len, ==, (U)->field_data[i].len); \ + \ + if ((HU)->field_set & (1 << i)) { \ + assert_memory_equal((HU)->field_data[i].len, \ + &(BUF)[(HU)->field_data[i].off], \ + &(BUF)[(U)->field_data[i].off]); \ + } \ + } \ } while (0) void test_urlparse_parse_url(void) {