Disable recognition of trigraphs in C23 mode.

This commit is contained in:
Stephen Heumann 2024-08-30 13:43:59 -05:00
parent b27fc52dc4
commit 0fe9424373
4 changed files with 21 additions and 4 deletions

View File

@ -146,6 +146,7 @@ type
gsosOutStringPtr = ^gsosOutString; gsosOutStringPtr = ^gsosOutString;
{ C language standards } { C language standards }
{ Note: this enumeration also appears in Scanner.asm. }
cStandardEnum = (c89,c95,c99,c11,c17,c23); cStandardEnum = (c89,c95,c99,c11,c17,c23);
{ The base types include two main categories. The values starting } { The base types include two main categories. The values starting }

View File

@ -467,6 +467,8 @@ cch equ 13
enum (ch_asterisk,ch_slash,ch_percent,ch_carot,ch_pound,ch_colon) enum (ch_asterisk,ch_slash,ch_percent,ch_carot,ch_pound,ch_colon)
enum (ch_backslash,ch_other,letter,digit) enum (ch_backslash,ch_other,letter,digit)
enum (c89,c95,c99,c11,c17,c23),0
! begin {NextCh} ! begin {NextCh}
tsc create stack frame tsc create stack frame
sec sec
@ -753,7 +755,8 @@ lc2a lda cch
! and (ptr(ord4(chPtr)-1)^ <> '\') ! and (ptr(ord4(chPtr)-1)^ <> '\')
! and ((ptr(ord4(chPtr)-1)^ <> '/') ! and ((ptr(ord4(chPtr)-1)^ <> '/')
! or (ptr(ord4(chPtr)-2)^ <> '?') ! or (ptr(ord4(chPtr)-2)^ <> '?')
! or (ptr(ord4(chPtr)-3)^ <> '?')) ! or (ptr(ord4(chPtr)-3)^ <> '?')
! or (cStd >= c23))
! then ! then
! done := true ! done := true
! else ! else
@ -777,6 +780,9 @@ lc2a lda cch
lda [p1] lda [p1]
cmp #'??' cmp #'??'
jne lc5 jne lc5
lda cStd
cmp #c23
jge lc5
lc2aa inc4 chPtr lc2aa inc4 chPtr
bra lc2 bra lc2
! end {else if} ! end {else if}
@ -833,10 +839,14 @@ lc5 anop
sta ch sta ch
! end {if} ! end {if}
brl le2 brl le2
! else if (ch = '?') and (chPtr <> eofPtr) and (chr(chPtr^) = '?') then begin ! else if (ch = '?') and (cStd < c23) and (chPtr <> eofPtr)
! and (chr(chPtr^) = '?') then begin
lc6 lda ch lc6 lda ch
lc7 cmp #'?' lc7 cmp #'?'
jne le2 jne le2
lda cStd
cmp #c23
jge le2
lda chPtr lda chPtr
cmp eofPtr cmp eofPtr
bne lc8 bne lc8

View File

@ -681,3 +681,8 @@
~&SYSCNT dec &a ~&SYSCNT dec &a
~restm ~restm
mend mend
macro
&l jge &bp
&l blt *+5
brl &bp
mend

View File

@ -1667,7 +1667,8 @@ if rawSourceCode then begin
i := 1; i := 1;
1: while i <= len do begin 1: while i <= len do begin
ch := chr(cp^); ch := chr(cp^);
if ch = '?' then {handle trigraphs} {handle trigraphs}
if (ch = '?') and (cStd < c23) then
if i < len-1 then if i < len-1 then
if chr(ptr(ord4(cp)+1)^) = '?' then if chr(ptr(ord4(cp)+1)^) = '?' then
if chr(ptr(ord4(cp)+2)^) in if chr(ptr(ord4(cp)+2)^) in
@ -5069,7 +5070,7 @@ if cp = eofPtr then
PeekCh := chr(0) PeekCh := chr(0)
else begin else begin
ch := chr(cp^); ch := chr(cp^);
if ch = '?' then {handle trigraphs} if (ch = '?') and (cStd < c23) then {handle trigraphs}
if ord4(eofPtr)-ord4(cp) > 2 then if ord4(eofPtr)-ord4(cp) > 2 then
if chr(ptr(ord4(cp)+1)^) = '?' then if chr(ptr(ord4(cp)+1)^) = '?' then
if chr(ptr(ord4(cp)+2)^) in if chr(ptr(ord4(cp)+2)^) in