Merged
Conversation
sprintf-constant-args counted a format specifier by looking for its literal hex byte sequence (e.g. "2566" for "%f") inside the untouched hex dump of the format string. A specifier carrying a flag, width or precision (e.g. "%08.2f") inserts extra bytes between "%" and the conversion letter, so its hex sequence never matched and the lint silently missed the defect. Decode the hex bytes back into the actual characters first (the same approach sprintf-without-formatters already uses), then count specifiers with a regex that understands flags, width and precision. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TFrxLNmS5phrWQhwndWUCU
yegor256
marked this pull request as ready for review
September 8, 2026 06:48
Member
Author
|
Merged, thanks! Reusing the Generated by Claude Code |
|
@yegor256 Thanks for the contribution! You've earned +8 points for this: +16 as a basis; -8 for the lack of code review. Please, keep them coming. Your running score is +2338; don't forget to check your Zerocracy account too). |
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.
Problem
Closes #1366.
sprintf-constant-argsselects the.printfdispatch correctly, but its formatter count is computed by searching the hex dump of the format string for the literal hex byte sequence of a bare specifier (2573for%s,2564for%d,2566for%f,2578for%x,2562for%b). A specifier that carries a flag, width, or precision — e.g.%08.2f— inserts extra bytes between%and the conversion letter, so its hex sequence never matches and the lint silently misses the defect (0 formatters counted instead of 1).Fix
Decode the hex-encoded bytes back into the actual characters (the same
eo:hex-to-placeholderapproach already used by the sibling lintsprintf-without-formatters.xsl), then count specifiers with a regex that understands%[N$][flags][width][.precision]conversion, consistent with howsprintf-without-formattersalready detects formatters.Testing
Added a pack,
catches-printf-with-flagged-format-and-constant-args.yaml, using a real"%08.2f".printf (* "3.14")call with a constant string argument. It fails onmaster(0 defects reported instead of 1) and passes with this change. Ran the fullLtByXslTestsuite (517 tests) — all green, including the pre-existingsprintf-constant-argsandsprintf-without-formatterspacks.🤖 Generated with Claude Code
https://claude.ai/code/session_01TFrxLNmS5phrWQhwndWUCU
Generated by Claude Code