From 9c04b94093454ca1188b85c0dc88dcfa0f3eae22 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Mon, 6 Sep 2021 20:37:17 -0500 Subject: [PATCH] Allow invalid escape sequences and UCN-like sequences in skipped code. The standard wording is not always clear on these cases, but I think at least some of them should be allowed and others may be undefined behavior (which we can choose to allow). At any rate, this allows non-standard escape sequences targeted at other compilers to appear in skipped-over code. There probably ought to be similar handling for #defines that are never expanded, but that would require more code changes. --- Scanner.pas | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Scanner.pas b/Scanner.pas index 244a111..cb1c19f 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -3654,7 +3654,8 @@ while digits > 0 do begin digits := digits - 1; end {while} else begin - Error(145); + if not skipping then + Error(145); codePoint := $0000C0; digits := 0; end; {else} @@ -4263,7 +4264,8 @@ var NextCh; end; {while} if (val & $FF00) <> 0 then - Error(162); + if not skipping then + Error(162); EscapeCh := val & $FF; skipChar := false; end; @@ -4290,7 +4292,8 @@ var end; {else} val := (val << 4) | dig; if (val & $FF00) <> 0 then begin - Error(162); + if not skipping then + Error(162); val := 0; end; {if} NextCh; @@ -4306,14 +4309,16 @@ var EscapeCh := chFromUCN else begin EscapeCh := 0; - Error(146); + if not skipping then + Error(146); end; {else} end; '''','"','?','\': EscapeCh := ord(ch); otherwise: Error(57); end {case} else begin - Error(162); + if not skipping then + Error(162); EscapeCh := ord(ch); end; {else} end {if}