From 5ce83cdf139082b730ca55fcf73ffde34f48bc61 Mon Sep 17 00:00:00 2001 From: Evelyn Chen Date: Thu, 27 Aug 2026 17:05:40 +0000 Subject: [PATCH] Keep escape parsing linear Authored-By: Codex (GPT-5) --- check.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/check.sh b/check.sh index 79a2199..9c82bd8 100755 --- a/check.sh +++ b/check.sh @@ -40,6 +40,7 @@ VISIBLE_BODY=$(printf '%s\n' "${BODY}" | awk ' visible="" pos=1 + backslash_run=0 while (pos <= length(line)) { if (in_comment) { rest=substr(line, pos) @@ -51,16 +52,11 @@ VISIBLE_BODY=$(printf '%s\n' "${BODY}" | awk ' visible=visible " " pos += comment_end + 2 in_comment=0 + backslash_run=0 continue } - escaped=0 - escape_pos=pos - 1 - while (escape_pos >= 1 && substr(line, escape_pos, 1) == "\\") { - escaped++ - escape_pos-- - } - if (substr(line, pos, 1) == "`" && escaped % 2 == 0) { + if (substr(line, pos, 1) == "`" && backslash_run % 2 == 0) { ticks=1 while (substr(line, pos + ticks, 1) == "`") ticks++ close_pos=pos + ticks @@ -77,6 +73,7 @@ VISIBLE_BODY=$(printf '%s\n' "${BODY}" | awk ' if (found_close) { visible=visible substr(line, pos, close_pos + ticks - pos) pos=close_pos + ticks + backslash_run=0 continue } } @@ -85,9 +82,13 @@ VISIBLE_BODY=$(printf '%s\n' "${BODY}" | awk ' visible=visible " " in_comment=1 pos += 4 + backslash_run=0 continue } - visible=visible substr(line, pos, 1) + char=substr(line, pos, 1) + visible=visible char + if (char == "\\") backslash_run++ + else backslash_run=0 pos++ } print visible