Fix multiple issues#226
Closed
henrygab wants to merge 19 commits intogerbv:mainfrom
henrygab:second_pass_reduction
Closed
Fix multiple issues#226henrygab wants to merge 19 commits intogerbv:mainfrom henrygab:second_pass_reduction
henrygab wants to merge 19 commits intogerbv:mainfrom
henrygab:second_pass_reduction
Conversation
* Order of internal `drill_state_t` structure changed * `drill_state_t->autod` changed to native `bool` * `drill_state_t->autod` changed name to `autodetect_file_format` * `drill_parse_header_is_metric_comment()` -- local variable names changed for increased clarity. * Many comments added to start documenting unwritten rules
Excellon format is clear that only two values are valid for `header_number_format`, and which value is used depends on the units: * Inches ==> FMT_00_0000 * Metric ==> FMT_000_000 Therefore, do not set to FMT_USER on those occasions, but to the allowed format type. Also added many more comments to `drill_parse_header_is_metric()`, explaining the implied logic.
This ensures the error message will properly report all the junk characters, when found.
Specifically, pull out the detection for two edge cases (hacks for bad data) into separate functions. These new functions ensure that, if they return false, they leave the file descriptor pointer where it was at entry.
* !~ Enable test case for 195 ~! * Track `leading_digits` and `trailing_digits` as separate values, rather than only tracking `decimals` * Remove HID Attribute `HA_digits` ... because it doesn't store information necessary to properly setup state * Add HID Attributes `HA_leading_digits` and `HA_trailing_digits` * Update function `read_double()` similarly (parameter `decimals` --> two parameters) * Split large function `read_double()` into smaller, functionally-focused parts.
* `CHK_STATE` macro calls `check_invariants()` with function/line * `DUMP_STATE` macro dumps internal state only in debug build * `check_floating_point()` asserts that stored floating point values are never NAN / INFINITE, and logs information if ever stores a SUBNORMAL value. * `check_min_max_int_value()` asserts that stored int values are within a given range. With static_assert() and above functions setup, the following invariants are checked: * `image->aperture` is a contiguous array with APERTURE_MAX elements * `max_valid_tool` is set to the smaller of APERTURE_MAX or 99 * fp values in `state`: `curr_x`, `curr_y`, `origin_x`, `origin_y` * `state->current_tool` in range `[0..max_valid_tool]` * `state->unit` in range `[0..max_units]` * `state->curr_section` in range `[0..max_file_section]` * `state->coordinate_mode` in range `[0..max_coordinate_mode]` * `state->number_format` in range `[0..max_number_format]` * `state->header_number_format` in range `[0..max_number_format]` * `state->backup_number_format` in range `[0..max_number_format]` * `state->omit_zeros` in range `[0..max_zero_suppression]` * `state->header_number_format` is either `FMT_00_0000` or `FMT_000_000` Moreover, once parsing of the header portion is completed, the following additional invariants are asserted: * `state->unit` (inches/mm) corresponds to `state->number_format`
Two issues with the prior method:
1. `dprintf()` is already defined in `stdio.h`,
which reduces clarity (bad form!)
2. The use of an `if` statement without braces
can hide significant logic errors.
Example code that would have logic error:
```C
// Ensure number format is set to FMT_USER (and warn if not true).
if (state->number_format == FMT_USER)
dprintf("Some debugging information here.")
else
state->number_format = FMT_USER;
```
Bug in the above example:
`number_format` is never set to `FMT_USER`
* Old and new functions run in parallel to verify equivalent * Enhanced debugging via single-line output of state * Enhanced reliability via explicit invariant checks
Closed
Closed
Author
|
It's clear now that this software is essentially not taking pull requests, even after fixes are updated to meet previously-unwritten requirements. See #210, opened on Sep 4, 2023. 100% success for all self-tests, and significant improvements in code maintainability, and many tiny bugs fixed. This is now dead. |
This was referenced Mar 1, 2026
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.
Highlights are as follows:
Fixes #195.
Fixes #211.
Fixes #212.
Fixes #213.
Fixes #214.
Fixes #215.
Fixes #216.
Fixes #217.
Fixes #218.
Fixes #219.
Fixes #220.
Fixes #221.