Skip to content

m_config: parse_int_parameter accepts upper-case 0X prefix unlike C ParseIntParameter #135

Description

@sunsided

Context

parse_int_parameter in room/src/doom/m_config.rs parses integer values from .cfg files (used for DEFAULT_INT* and DEFAULT_KEY entries).

C behavior

C ParseIntParameter only checks the lowercase 0x hex prefix. An upper-case 0X is not recognized as hex and falls through to sscanf("%i", ...), which then does recognize it - but the path taken differs.

Rust behavior

The Rust port accepts both 0x and 0X in the dedicated hex branch:

if bytes.len() >= 2 && bytes[0] == b'0' && (bytes[1] == b'x' || bytes[1] == b'X') {

Impact

Likely benign in practice (no known .cfg file uses 0X), but a Rust-port extension that diverges from documented C behavior.

Location

room/src/doom/m_config.rs:635 (flagged with // FIXME:).

Suggested fix

Drop the 0X branch to match C, or document the extension explicitly and add a regression test.

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions