fix: set omit_zeros unconditionally when LZ/TZ is declared in Excellon header#275
Merged
spe-ciellt merged 2 commits intogerbv:developfrom Feb 22, 2026
Conversation
When FILE_FORMAT=N:M sets autod=0 (commit 944a4b3, PR gerbv#156), the subsequent INCH,LZ or METRIC,LZ line is completely ignored — not just the decimals/number_format override (intended), but also the omit_zeros setting (regression). This causes coordinates with suppressed trailing zeros to be misinterpreted, rendering drill holes at wildly incorrect positions. Affects all Altium-exported drill files using FILE_FORMAT + INCH,LZ. Fix: move omit_zeros assignment outside the if(state->autod) gate in both drill_parse_header_is_inch() and drill_parse_header_is_metric(). The autod guard still correctly prevents decimals/number_format from being overridden when FILE_FORMAT has already set them. Fixes gerbv#174. Fixes gerbv#195.
Add new test case Altium_file_format_inch_lz that covers the exact scenario from issue gerbv#174: FILE_FORMAT declared before INCH,LZ. This test fails on develop (MAE=13726) and passes with the omit_zeros fix. Regenerate golden PNG for LimeSDR-QPCIe_1v2-RoundHoles since the previous golden was generated with the buggy autod gate that skipped omit_zeros when FILE_FORMAT was present.
Contributor
|
Hello and thank you for the patch. I will merge this patch since it seems to solve a real world problem and does not affect the current ones. |
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.
Summary
Fixes #174. When an Excellon drill file contains both
FILE_FORMATandINCH,LZ(orMETRIC,LZ,INCH,TZ, etc.), theFILE_FORMAThandler setsautod = 0, which causes the subsequent LZ/TZ parsing to skip settingomit_zeros. This results in incorrect coordinate interpretation — trailing zeros are not suppressed when they should be.The fix moves the
omit_zerosassignment outside theif (state->autod)gate in bothdrill_parse_header_is_metric()anddrill_parse_header_is_inch(). Theautodgate is preserved fordecimalsandnumber_format— onlyomit_zerosis decoupled.This regression was introduced in 944a4b3 (PR #156).
What changed
src/drill.c: 4 lines moved —omit_zerosassignment for cases 'L' and 'T' in bothdrill_parse_header_is_metric()anddrill_parse_header_is_inch()now executes unconditionallytest/golden/LimeSDR-QPCIe_1v2-RoundHoles.png: Regenerated — previous golden was produced with the buggyautod=0pathtest/inputs/Altium_file_format_inch_lz.drl: New test input —FILE_FORMAT=2:5beforeINCH,LZwith trailing-zero-suppressed coordinatestest/tests.list: AddedAltium_file_format_inch_lztest entryRegression analysis
INCH,TZalone (no FILE_FORMAT)FILE_FORMATthenINCH,TZFILE_FORMATthenMETRIC,LZINCH,TZthenFILE_FORMATThe new test
Altium_file_format_inch_lzfails on develop with MAE=13726 and passes with this fix.Test plan
test-drill-trailing-zero-suppressionfailure unrelated to this change)Altium_file_format_inch_lztest passesAltium_file_format_inchandAltium_inch_file_formatunchanged (still pass)