Skip to content

Guard INCH/METRIC unit assignment with autod in drill header parsing (#241)#313

Merged
spe-ciellt merged 1 commit intogerbv:developfrom
SourceParts:fix/drill-unit-autod-guard
Mar 5, 2026
Merged

Guard INCH/METRIC unit assignment with autod in drill header parsing (#241)#313
spe-ciellt merged 1 commit intogerbv:developfrom
SourceParts:fix/drill-unit-autod-guard

Conversation

@rampageservices
Copy link
Copy Markdown
Contributor

Summary

  • Guard state->unit assignments in drill_parse_header_is_inch() and drill_parse_header_is_metric() with if (state->autod)
  • Prevents header INCH/METRIC commands from overwriting user-supplied unit settings when autodetect is disabled

Root cause

The M-code handlers (DRILL_M_IMPERIAL, DRILL_M_METRIC) already guard their unit assignments with if (state->autod), but the header parsing functions drill_parse_header_is_inch() and drill_parse_header_is_metric() set state->unit unconditionally. When a user disables autodetect and manually sets the unit (e.g. METRIC), parsing an INCH header command overwrites that setting.

Test plan

  • Clean build with zero warnings
  • 93/104 regression tests pass (11 pre-existing mismatches, no regression)

Fixes #241

drill_parse_header_is_inch() and drill_parse_header_is_metric() set
state->unit unconditionally, overwriting user-supplied unit settings
even when autodetect is disabled (state->autod == 0).

The M-code handlers (DRILL_M_IMPERIAL, DRILL_M_METRIC) already guard
their unit assignments with if(state->autod). Apply the same guard to
the header parsing functions for consistency.

Fixes gerbv#241
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Solution for a potential problem or omission.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot manually override numeric format (INCH/METRIC) or number of digits (drill file)

2 participants