Skip to content

rust: Port util/cf-parser.c to obs-util #1466

Closed

Description

@nathan-v

Unit

Port libobs/util/cf-parser.c.h (the former cf-parser.c) to obs-util: cf_adderror and cf_pass_pair.

Phase and position

Phase 3, lexer/parser step 3, deferred follow-up tracked by #43.

Dependencies and existing tests

Uses the lexer/token structures, error-data helpers and dstr formatting. These dependencies are already available through the existing C API and Rust utility ports. The preprocessor in cf-lexer.c.h stays C.

test/cmocka/test_cf_lexer.c already contains parser pair-skipping, error-reporting and parse-failure characterization. First audit that coverage; submit a separate C-only characterization PR only if needed before the Rust port.

Notes

Preserve public headers, exported signatures, parser/token layouts and existing C tests. The eventual port requires RED then GREEN, Tier 1 mirrors, layout checks, differential parity and unchanged Tier 2 OFF/ON checks. Header-inline parser helpers remain unchanged. No intended behavior changes.

Current authorized work is the claim and characterization audit, plus a characterization-only PR if necessary; Rust implementation follows separately.

Activity

  1. nathan-v commented on Oct 20, 2026

    @nathan-v
    ContributorAuthor

    Claiming: libobs/util/cf-parser.c.h (cf_adderror and cf_pass_pair).

    1. Audit the existing parser characterization in test/cmocka/test_cf_lexer.c against the two C functions and their registration.
    2. If coverage needs strengthening before the port, add separate C tests without changing existing tests or public headers, and submit a characterization-only PR.
    3. Record the audit outcome here. Rust RED/GREEN implementation is a separate next step.

    ETA: audit this session; first characterization PR this session if needed. No Rust implementation in this pass.

  2. added
    claimed
    on Oct 20, 2026
  3. nathan-v commented on Oct 20, 2026

    @nathan-v
    ContributorAuthor

    Characterization audit

    Audited master 9d58d5ee5e09253c41242f6e05a32df410f35033. A separate characterization PR is not necessary for this two-function unit: existing C characterization covers both exports and is registered against libobs.

    • test/cmocka/test_cf_lexer.c:418, parser_pass_pair_test: skips a balanced pair, checks the immediate token position after the closing delimiter, handles nested same-kind pairs, fails an unbalanced pair at the terminator, preserves the cursor when not on an opener, and checks allocation balance.
    • test/cmocka/test_cf_lexer.c:477, parser_adderror_test: covers plain and substituted messages, error/warning levels and counts, filename and row/column, the combined diagnostic text, and allocation balance.
    • parser_parse_failure_test also covers empty input and failed lexing through the existing header-inline parser setup.
    • All three are registered in the executable's cmocka array. test/cmocka/CMakeLists.txt:283-288 links test_cf_lexer to OBS::libobs, adds it to cmocka-tests, and registers it with CTest. The Tier 2 harness runs that CTest suite against both libobs variants.
    • libobs/build/libobs.util-cf+.h.c still includes the original parser implementation. The current test reaches the real C exports, rather than a copied test implementation.

    This is sufficient existing characterization under the policy's "Characterization tests for units without C tests" rule. It is not exhaustive coverage. The port's Tier 1 edge cases and Tier 3 parity should additionally cover calls starting at EOF, a nonmatching punctuation opener, nested EOF failure, empty pairs, and substitution values 2/3 (including sparse NULL arguments), preserving defined C behavior and cursor state. Existing C tests and public headers stay unchanged.

    Validation boundary: source and test-registration audit only; no build or test execution in this pass, and no claim of a fresh Tier 2 pass. No source changes, characterization commit, or PR were created. Rust implementation has not started; the requested claim remains in place for the next step.

  4. nathan-v commented on Oct 21, 2026

    @nathan-v
    ContributorAuthor

    Closing this. The port is on master as #1467 (797f5b135). cf_adderror and cf_pass_pair are in obs-util, and cf-parser.c.h stays only in the C reference build. cf-lexer is still #1499.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions