Skip to content

fix: keep explicit empty value in -D definitions - #64

Merged
henryiii merged 1 commit into
masterfrom
fix-define-empty-value
Aug 7, 2026
Merged

fix: keep explicit empty value in -D definitions#64
henryiii merged 1 commit into
masterfrom
fix-define-empty-value

Conversation

@henryiii

@henryiii henryiii commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

This seems oddly intentional; the new version does seem better, but was there a reason for the old one?

🤖 AI text below 🤖

Addresses finding 7 and the __init__.py simplifications from the review in #59.

  • -DFOO= (explicit empty value) kept an empty value, as clang does. Before, it became FOO=1. A bare -DFOO still becomes FOO=1.
  • _append_definition: removed the two unreachable except blocks (str.partition does not raise ValueError) and simplified the function.
  • _append_include_dir: prints the warning for a missing directory that the docstring promises, instead of doing nothing.
  • main: plain tuple unpacking for parse_known_args, extend(parsed_args.header), and no more redundant int(width) (argparse uses type=int).

A parametrized regression test for _append_definition is included.

`-DFOO=` now defines FOO to nothing, as clang does, instead of 1. Only a
bare `-DFOO` becomes `FOO=1`.

Also simplifies `__init__.py`: removes the unreachable `except` blocks in
`_append_definition`, prints the promised warning for a missing include
directory, and drops some redundant code in `main`.

Assisted-by: ClaudeCode:claude-fable-5
@henryiii
henryiii marked this pull request as draft August 6, 2026 18:18
@henryiii
henryiii requested a review from leakec August 7, 2026 13:00
@henryiii
henryiii marked this pull request as ready for review August 7, 2026 13:00

@leakec leakec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, this looks good to me. No changes to suggest.

@henryiii
henryiii merged commit ae1f864 into master Aug 7, 2026
15 of 16 checks passed
@henryiii
henryiii deleted the fix-define-empty-value branch August 7, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants