Skip to content

Fix: Implement bracket-aware custom slicing mode for M4 (#2204) - #2205

Merged
squid-protocol merged 3 commits into
mainfrom
fix/2204-m4-bracket-mode
Aug 24, 2026
Merged

Fix: Implement bracket-aware custom slicing mode for M4 (#2204)#2205
squid-protocol merged 3 commits into
mainfrom
fix/2204-m4-bracket-mode

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Resolves #2204

Root Cause

  1. Mode A (Greedy Labels) fails because M4 macros do not implicitly terminate when the next one starts, causing empty stubs (like AC_PROG_F77) to swallow 1,532 LOC of unrelated shell code.
  2. Mode B (Lisp Braces) fails because GitGalaxy aggressively shields string literals to prevent brace-depth corruption. Because M4 heavily embeds bash fragments with scattered and unbalanced quotes, the shielding pass shreds the M4 code stream, yielding 0% extraction.

The Fix

Implemented a dedicated custom integration loop (_slice_by_m4_brackets, Mode F) tailored for M4's lexical structure:

  • Locates func_start on the unshielded source code.
  • Steps forward to track the depth of the outer ( and ).
  • Simultaneously tracks M4's bracket quotes [ and ]. Any parenthesis that appears while bracket depth > 0 is completely ignored, correctly shielding unbalanced parenthesis inside bash strings without stripping the strings.
  • Added strict structural test harness coverage for these unbalanced-quote edge cases.

This strictly binds macros to their correct AC_DEFUN invocation bounds, completely eliminating the false positive LOC bleeds.

Golden Master Audits

  • 157 precise fixes committed to the golden master.
  • M4 gross impact LOC perfectly corrected (e.g. AC_PROG_F77 drops exactly from 1532 -> 1).

@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 7efcc72 into main Aug 24, 2026
30 checks passed
@squid-protocol
squid-protocol deleted the fix/2204-m4-bracket-mode branch August 24, 2026 02:29
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.

m4: Mode A 'greedy to next func' body heuristic is structurally incorrect (produces 1500+ LOC for empty macros)

1 participant