Repository navigation
refactor(libobs): move libc-bound dstr functions out (#6) - #50
Closed
b7216309-jpg wants to merge 1 commit into
Closed
b7216309-jpg wants to merge 1 commit into
b7216309-jpg wants to merge 1 commit into
Conversation
Behavior-neutral move, as the function-extraction policy requires. These 15 functions move verbatim from util/dstr.c into the new util/dstr-libc.c: - the printf family (dstr_printf, dstr_catf, dstr_vprintf, dstr_vcatf), which takes C varargs and va_list; - the wide-character compares (wstrcmpi, wstrcmp_n, wstrcmpi_n, wstrstri, wcsdepad), which depend on towupper and wchar_t width; - the conversions (dstr_from_mbs, dstr_to_mbs, dstr_to_wcs, dstr_from_wcs, dstr_to_upper, dstr_to_lower), which go through platform.c and the locale. wstrblank moves with them, and the static is_padding helper, which both files use, is copied. No header, signature or behavior changes, and the new file is always compiled. What stays in dstr.c is pure byte-string logic that a Rust port can replace under ENABLE_RUST_LIBOBS. Stable Rust cannot define variadic functions, so the printf family has to stay in C. Refs obs-rust#6 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 9, 2026
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #43 (Phase 3 tracking; #6 closed when #33 merged)
A behavior-neutral extraction ahead of porting
dstr.c(Phase 3, step 5), following "Extracting a function before porting it". The precedents are #5 and #42. This PR contains no Rust.Fifteen functions move verbatim from
util/dstr.cinto the newutil/dstr-libc.c:dstr_printf,dstr_catf,dstr_vprintf,dstr_vcatfva_list: stable Rust cannot define variadic functions (c_variadicis unstable), and the formatting is the C library'svsnprintfwstrcmpi,wstrcmp_n,wstrcmpi_n,wstrstri,wcsdepadtowupperis locale- and libc-dependent;wchar_tis 16-bit on Windows and 32-bit elsewheredstr_from_mbs,dstr_to_mbs,dstr_to_wcs,dstr_from_wcs,dstr_to_upper,dstr_to_lowerplatform.c(os_mbs_to_utf8_ptr,os_utf8_to_wcs_ptr) andtowupper/towlowerwstrblankmoves with them. Thestatic inline is_paddinghelper, used by bothstrdepadandwcsdepad, is copied. The includes are kept identical. No header, signature or behavior changes, and the new file is always compiled.test_dstris untouched.What stays in
dstr.cis pure byte-string logic: theastr*compares,strdepad,strlist_split, and thedstrcopy/cat/insert/remove/replace/left/mid/right/depad/safe_printf family. That part maps onto a safe Rust core, and the port follows in a separate PR.Verification
git diffofdstr.chas zero added lines (deletions only).dstr-libc.cappears byte-for-byte in the originaldstr.c../lintpasses.🤖 Generated with Claude Code