fix: correctly apply N from FILE_FORMAT=N:M with LZ trailing suppression#278
Merged
spe-ciellt merged 2 commits intodevelopfrom Feb 23, 2026
Merged
Conversation
When FILE_FORMAT=N:M is parsed, only M (digits after the decimal) was stored as state->decimals, while N (digits before) was discarded. The decimals field has a documented dual meaning: in FMT_USER with trailing zero suppression it is the digits *before* the decimal point (i.e. N), and in all other cases it is the digits *after* (M). Commit 023e835 fixed omit_zeros being ignored when autod=0, but exposed the data loss: with omit_zeros=TRAILING now set, read_double used wantdigits=decimals=M=5 instead of the correct N=2, placing the decimal five digits in instead of two. A coordinate like Y0297402 was parsed as 02974.02 (≈2974 in) instead of 02.97402 (≈2.97 in). Fix: store N in a new digits_before field on drill_state_t. When INCH,LZ or METRIC,LZ is processed with autod=0 and FMT_USER, set decimals=digits_before so read_double gets the correct wantdigits. Also regenerates the Altium_file_format_inch_lz golden (previously generated with the broken wantdigits=5 parsing), and adds Ruthie_V1R0-Plated as a regression test for this case.
The regression test uses the drill file, but it is always great to have the complete project so you can see it all together. The bugs sticks out like a sore thumb.
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.
Didn't read the whole part of the drill file format., but that is done now.
The tests are updated with new golden reference images.
Altium_file_format_inch_lz.drlwas unnoticeable was affected by the error.Ruthie_V1R0-Plated.drl, which is a new file that highlighted the problem.There can be a problem when running the pipeline if the versions of Cairo are different when locally generating the golden file and the one in the pipeline, hopefully that should not be any problem.
@ejouellette allowed us to use the files he used to show the problem as example and as a reference for the tests.
Closes #238