Repository navigation
util: Move os_generate_formatted_filename into platform-filename.c - #1510
Merged
Merged
Conversation
Behavior-neutral extraction before the Rust port: os_generate_formatted_filename and its statics valid_string, replace_text and erase_ch move verbatim from libobs/util/platform.c.h into libobs/util/platform-filename.c.h, in the same libobs.platform unity group and precompiled header. The oracle compiles both files. test_formatted_filename now compiles platform-filename.c instead of platform.c and utf8.c, which the moved code does not need. No host conditionals move. test_formatted_filename becomes a full characterization. A fixed clock (the test's time() replaces libc's for the compiled-in file), a fixed TZ (UTC+05:30) and the C locale make every case exact, and the obs_get_video_info fixture becomes configurable and counts its calls. New cases: every date and time specifier, %s, %FPS (integer and fractional rates), %CRES, %ORES, %VF, table order and longest match, %% and unknown specifiers, space replacement, the extension, an empty or NULL format, and the 255-byte limit after expansion and on the extension. Characterized, not endorsed: %FPS keeps two decimals for a whole rate when fps_den > 1 (50/2 is "25.00"), and the result of obs_get_video_info is not checked, so with no video the fields are used as the call left them. Refs obs-rust#262
zackees
enabled auto-merge
October 20, 2026 08:12
zackees
reviewed
Oct 20, 2026
zackees
left a comment
Member
There was a problem hiding this comment.
Coordinator review: behaviour-neutral move. test_formatted_filename.c is edited, but all five existing cases stay registered with their assertions unchanged; the edits are the fixture (now compiling platform-filename.c) and new characterization cases. Auto-merge on.
This was referenced Oct 20, 2026
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 #262 (slice 5, filenames).
What and why
Behavior-neutral extraction before the Rust port, as the testing policy asks for a partial-file port:
os_generate_formatted_filenameand its staticsvalid_string,replace_textanderase_chmove verbatim fromlibobs/util/platform.c.hintolibobs/util/platform-filename.c.h. No Rust, no signature, header or behavior change.libobs.platformunity group andlibobs-platform.pch.h.rust/obs-c-oracle/oracle/platform.cincludes it too (os_generate_formatted_filenamewas already renamedoracle_os_generate_formatted_filenamethere), so the oracle still runs the real C. Theobs_get_video_infostub's comment inplatform_host.cpoints at the new file.test_formatted_filenamecompiles the C into the test so its fixtures replace libobs's. It now compilesplatform-filename.cinstead ofplatform.candutf8.c, which the moved code does not need (CMake and the Cargo C-test manifest).__GNUC__/__clang__pragma guard.test_formatted_filenamegoes from 5 cases to 17 and becomes a full characterization. Nothing depends on the clock, time zone or locale: the test'stime()replaces libc's for the compiled-in file and returns a fixed instant, the group setup setsTZ=OBS-5:30(UTC+05:30, so local and UTC dates and hours differ) and the C locale, and theobs_get_video_infofixture is now set per case and counts its calls. The 5 existing cases are unchanged. New cases:%CCYY %YY %MM %DD %hh %mm %ssand the strftime ones%a %A %b %B %d %H %I %m %M %p %S %y %Y %z %Z, all in local time;%s(Unix time), which is not in the specifier table;%FPS,%CRES,%ORES,%VF;%FPSwith integer, NTSC and odd rates,fps_den0, andUINT32_MAX;%VFnames;%YYYis25Y,%sssis03s,%FPSSis30S), case sensitivity, and an expansion is never scanned again (%%CCYYis%CCYY);%%, a trailing%, and unknown specifiers, strftime ones outside the table included (%q,%e,%c,%T,%F,%CRE, a%before a multibyte character): the%is dropped and the rest kept;.mkvwith an extension);Two cases are characterized, not endorsed:
%FPSkeeps two decimals for a whole rate whenfps_den > 1(50/2 is25.00);obs_get_video_infois not checked, so with no video the fields are used as the call left them. The realobs_get_video_infodoes not write them then, so the name is built from uninitialized stack memory (filed as bug: util: os_generate_formatted_filename uses video info that obs_get_video_info did not fill #1509). The port keeps it, and the fix goes in its own PR.localtime()is not thread-safe (noted on #262). This PR only pins behavior; the port can uselocaltime_ras a recorded intentional difference.RED → GREEN
platform.c.hbefore =platform.c.hafter +platform-filename.c.hminus its license and include). The test also passes against the v0.1.0-beta.20261018 release'slibobs.so.30, both the C one and theobs-studio-rust/one.ENABLE_RUST_LIBOBS=OFFandON). Each runs the cmocka tests againstlibobsand againstlibobs-with-rust:ENABLE_RUST_LIBOBS=OFF)ENABLE_RUST_LIBOBS=ON)7 frontend tests (
test_config_migration_*,test_virtual_cam_shutdown) were not built in these trees: I built only thecmocka-tests,libobsandlibobs-with-rusttargets. Nothing was skipped.test_formatted_filename: 17/17 in all four, 20 repeated runs in each mode, and withTZ/LC_ALLset to other zones and locales in the environment.test_formatted_filenamecompiles the C into the test, so it characterizes the C source only, as the testing policy says for this test; it cannot exercise the Rust swap../lint(ci/local_gate.py --lane lint): passed (42 s)Windows/macOS: PR CI scopes this Linux-only.
test_formatted_filenameis not built under MSVC. macOS builds it, but this PR's paths don't select the macOS lane; the port PR touchesrust/obs-util/src/platform/, so its CI runs the macOS Tier 2 lane with this test there.Checklist
masterdocs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): not applicable