Skip to content

rust: Port util/dstr-libc.c to obs-util #1855

Closed

Description

@zackees

Unit

libobs/util/dstr-libc.c.h (272 lines) into rust/obs-util. It holds the libc-backed dstr helpers that stayed C when dstr.c was ported (#43):

  • wstrcmpi, wstrcmp_n, wstrcmpi_n, wstrstri, wcsdepad
  • dstr_from_mbs, dstr_to_mbs, dstr_to_wcs, dstr_from_wcs
  • dstr_to_upper, dstr_to_lower
  • dstr_printf, dstr_catf, dstr_vprintf, dstr_vcatf (C variadic)

Phase and position

Unit 2 of #1846. The rest of dstr is already in obs-util::dstr; this removes the last C part of it from the production build.

Dependencies and existing tests

  • Stable Rust cannot define C-variadic functions or name a va_list. As with base-variadic.c.h, pipe-variadic.c.h and profiler-variadic.c.h, the four printf functions are copied verbatim into libobs/util/dstr-variadic.c.h, compiled only in the hybrid (libobs.rust-variadic group). The C reference keeps compiling all of dstr-libc.c.h.
  • The conversions call os_mbs_to_utf8_ptr / os_utf8_to_wcs_ptr from util/platform-conversions.c.h (unit 1 of meta: 10 libobs units to move from C to Rust next #1846, not part of this unit). The Rust shim calls those symbols through extern "C"; wchar_to_utf8, dstr_free, dstr_resize and bfree are the Rust ports.
  • towupper / towlower are the C library's (locale-dependent), called from obs-util::platform::crt, so case mapping matches C in any locale.
  • test_dstr covers only dstr_to_upper/dstr_to_lower (ASCII) and the printf functions. A characterization test test/cmocka/test_dstr_libc.c lands first for the wide helpers and the conversions.

Characterized, not endorsed: dstr_to_mbs converts with os_mbs_to_utf8_ptr (the multibyte-to-UTF-8 direction), as the C does; dstr_from_mbs leaves capacity 0 with a non-NULL array.

Plan

One PR:

  1. Characterization: test/cmocka/test_dstr_libc.c, registered in test/cmocka/build/test-graph.json.
  2. RED: obs-util::dstr_libc safe core and ffi::dstr_libc shim with todo!(); Tier 1 tests in tests/strings/dstr_libc.rs; dstr-libc.c.h moves to libobs.ported-util, printf copies to dstr-variadic.c.h in libobs.rust-variadic; export fragment rust-exports.d/obs-util-dstr_libc.txt.
  3. GREEN: the port; Tier 3 proptest parity against the oracle's oracle_* dstr-libc (arbitrary wide strings, non-ASCII included); Tier 2 runs test_dstr and test_dstr_libc against hybrid and C reference.
  4. Tier 4 does not apply.

Activity

  1. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Claiming: util/dstr-libc.c port (unit 2 of #1846), one PR.

    1. Characterization test test_dstr_libc (committed on branch port/dstr-libc).
    2. RED: Rust stubs + Tier 1, group move, dstr-variadic.c.h; draft PR right away.
    3. GREEN: port, Tier 3 proptest parity, Tier 2 against hybrid and C reference.
    4. Lint, CI, merge queue.

    First PR: today.

  2. added
    claimed
    on Oct 23, 2026
  3. added a commit that references this issue on Oct 23, 2026
    63fca48
  4. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Coordinator note: two claims cover the same unit. #1855 (@zackees, claimed 2026-10-23 02:08 UTC) and #1858 / PR #1859 (@rdoupe, claimed 02:34 UTC) are both "unit 2 of #1846", the util/dstr-libc.c port. Under coordination.md the earlier claim (#1855) has priority. #1859 already has a full port up, though. Please agree between you which one continues, and close the other issue as a duplicate, so no CI or review time goes to two ports.

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