Skip to content

m_config: parse_int_parameter drops C sscanf %i octal fallback #136

@sunsided

Description

@sunsided

Context

parse_int_parameter in room/src/doom/m_config.rs parses integer values from .cfg files.

C behavior

C ParseIntParameter falls back to sscanf("%i", ...), which recognizes:

  • 0x / 0X prefix as hex,
  • leading 0 as octal,
  • otherwise decimal.

So a config value like 0755 is parsed as octal 493.

Rust behavior

After the hex branch, the Rust port uses str::parse::<i32>(), which rejects octal-style leading zeros and accepts only decimal. Values like 0755 parse as decimal 755 (or fail and return 0 in older Rust - actually leading zeros are accepted in decimal by parse::<i32>, but no octal interpretation occurs).

Impact

Any .cfg value relying on sscanf %i octal interpretation silently changes meaning. The risk is low but real for binding bytes like 077 (octal 63 in C, decimal 77 in Rust).

Location

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

Suggested fix

Detect a leading 0 (not followed by x/X) and parse as octal via i32::from_str_radix(..., 8), then fall back to decimal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-m_configArea: m_configbugSomething isn't workingkilo-duplicateAuto-generated label by Kilokilo-triagedAuto-generated label by Kilo

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions