Refactor Doom modules to use native c"..." literals and remove duplicated cstr! macros#145
Merged
Merged
Conversation
Agent-Logs-Url: https://github.com/sunsided/room/sessions/fb9747f6-a968-4601-ad75-8152c8e345a4 Co-authored-by: sunsided <495335+sunsided@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor: replace cstr! macros with c"..." literals
Refactor Doom modules to use native May 22, 2026
c"..." literals and remove duplicated cstr! macros
There was a problem hiding this comment.
Pull request overview
This PR refactors multiple Doom-engine Rust port modules to stop using locally duplicated cstr! macros and instead use native Rust C-string literals (c"...") for 'static NUL-terminated strings, while also tightening argv-parameter APIs to be read-only (*const c_char).
Changes:
- Replaced
cstr!("...")call sites withc"...".as_ptr()(and.cast_mut()only where required by existing FFI signatures). - Removed duplicated per-module
macro_rules! cstrhelpers. - Updated
m_argv’s argument-matching APIs (M_CheckParmWithArgs,M_CheckParm,M_ParmExists) to accept*const c_char.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| room/src/doom/w_main.rs | Switches -file parsing strings to c"..." literals and removes local cstr!. |
| room/src/doom/statdump.rs | Removes local cstr! and uses c"-statdump".as_ptr() with updated argv API. |
| room/src/doom/r_draw.rs | Replaces cstr! uses in WAD lump name lookups with c"..." literals. |
| room/src/doom/p_spec.rs | Removes local cstr!, updates ANIMDEFS to c"..." literals, and updates -donut flag lookup. |
| room/src/doom/m_argv.rs | Changes argv-check function parameters from *mut c_char to *const c_char. |
| room/src/doom/hu_stuff.rs | Converts many exported string tables to c"..." literals and removes local cstr!. |
| room/src/doom/f_finale.rs | Converts finale text/name constants and lump-name strings to c"..." literals. |
| room/src/doom/dstrings.rs | Removes cstr! macro and uses c"..." literals for quit-message tables. |
| room/src/doom/d_mode.rs | Converts D_GameMissionString return strings to c"..." literals and removes local cstr!. |
| room/src/doom/d_iwad.rs | Converts IWAD metadata and flag strings to c"..." literals and removes local cstr!. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
cstr!was duplicated across multiple Doom modules and routinely produced mutable raw pointers for string literals that are actually read-only. This change replaces those macro calls with native Rust C-string literals and makes mutability explicit only where required by FFI signatures.Replace
cstr!usage with native C-string literalscstr!("...")toc"...".as_ptr().macro_rules! cstrdefinitions from affected modules.Make pointer mutability explicit at FFI boundaries
.cast_mut()only where data flows into APIs/types that still require*mut c_char(while preserving read-only backing storage semantics).*const c_charwhere possible.Align argv parameter APIs with read-only usage
m_argvsignatures used for argument matching (M_CheckParmWithArgs,M_CheckParm,M_ParmExists) to accept*const c_char.Mechanical cleanup from macro removal
cstr!.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
dl.google.com/usr/lib/apt/methods/https /usr/lib/apt/methods/https /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libgimli-46dc78dc6a8cb06a.rlib /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libcfg_if-0ce073fff809ec38.rlib /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/librustc_demangle-146c3f1190dee2e2.rlib /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libstd_detect-e305c7135f50bfab.rlib eUlG/symbols.o cript_build-d2cc17342796f4f3.build_script_build.7e66a80fa321764f-cgu.0.rcgu.o cript_build-d2cc17342796f4f3.build_script_build.7e66a80fa321764f-cgu.1.rcgu.o cript_build-d2cc17342796f4f3.build_script_build.7e66a80fa321764f-cgu.2.rcgu.o cript_build-d2cc17342796f4f3.5jda16q7vra9bvmy1a0oko6we.rcgu.o /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libminiz_oxide-5ad929a15a8e6727.rlib /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libadler2-1f570ee5c6635aae.rlib ib 64-REDACTED-linux-gnu/lib/libstd-d1237ef7159db0a2.rlib 64-REDACTED-linux-gnu/lib/libpanic_unwind-4be5972b22d3a6da.rlib 64-REDACTED-linux-gnu/lib/libobject-2a81194c9d07bbf6.rlib 64-REDACTED-linux-gnu/lib/libmemchr-ea71fa85f6699d6b.rlib 64-REDACTED-linux-gnu/lib/libaddr2line-a79a8816d9fd6004.rlib 64-REDACTED-linux-gnu/lib/libgimli-46dc78dc6a8cb06a.rlib 64-REDACTED-linux-gnu/lib/libcfg_if-0ce073fff809ec38.rlib(dns block)If you need me to access, download, or install something from one of these locations, you can either: