Skip to content

fix: binary pattern rejects values with a leading plus sign - #2946

Open
b84330808 wants to merge 1 commit into
WerWolv:masterfrom
b84330808:fix-binary-pattern-plus-sign
Open

b84330808 wants to merge 1 commit into
WerWolv:masterfrom
b84330808:fix-binary-pattern-plus-sign

Conversation

@b84330808

Copy link
Copy Markdown

Problem description

In the Find view's binary pattern syntax, a value with a leading + is rejected. u8(+5) and u16be(+258) are invalid, but s16(-2) works. parseValueExpression() handles + with continue before it consumes the character. On the next iteration i is 1, the same + is not a digit, and the whole pattern is rejected.

Implementation description

Handle + like -: consume it and set negative from it. New BinaryPatternValueWithSign test in tests/helpers/source/binary_pattern.cpp.

Screenshots

None. There is no UI change.

Additional things

I couldn't do a full ImHex build here (Windows without MSYS2). I compiled the unchanged binary_pattern.cpp with zig c++ (clang, C++23) and linked it into a small harness that runs the same checks as the new test. 3 checks fail on master and all pass with the fix. The new test file compiles against the real tests.hpp, but CI is the first run of it inside helpers_test.

I used Claude Code to write this change.

parseValueExpression() skipped "+" with `continue` before consuming it,
so the next iteration saw "+" again at i == 1 and rejected the whole
pattern. "u8(+5)" and "u16be(+258)" were invalid while "s16(-2)" worked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant