diff --git a/CCommon.pas b/CCommon.pas index 965502b..e15e91b 100644 --- a/CCommon.pas +++ b/CCommon.pas @@ -146,6 +146,7 @@ type gsosOutStringPtr = ^gsosOutString; { C language standards } + { Note: this enumeration also appears in Scanner.asm. } cStandardEnum = (c89,c95,c99,c11,c17,c23); { The base types include two main categories. The values starting } diff --git a/Scanner.asm b/Scanner.asm index a895df6..863f892 100644 --- a/Scanner.asm +++ b/Scanner.asm @@ -467,6 +467,8 @@ cch equ 13 enum (ch_asterisk,ch_slash,ch_percent,ch_carot,ch_pound,ch_colon) enum (ch_backslash,ch_other,letter,digit) + enum (c89,c95,c99,c11,c17,c23),0 + ! begin {NextCh} tsc create stack frame sec @@ -753,7 +755,8 @@ lc2a lda cch ! and (ptr(ord4(chPtr)-1)^ <> '\') ! and ((ptr(ord4(chPtr)-1)^ <> '/') ! or (ptr(ord4(chPtr)-2)^ <> '?') -! or (ptr(ord4(chPtr)-3)^ <> '?')) +! or (ptr(ord4(chPtr)-3)^ <> '?') +! or (cStd >= c23)) ! then ! done := true ! else @@ -777,6 +780,9 @@ lc2a lda cch lda [p1] cmp #'??' jne lc5 + lda cStd + cmp #c23 + jge lc5 lc2aa inc4 chPtr bra lc2 ! end {else if} @@ -833,10 +839,14 @@ lc5 anop sta ch ! end {if} 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 lc7 cmp #'?' jne le2 + lda cStd + cmp #c23 + jge le2 lda chPtr cmp eofPtr bne lc8 diff --git a/Scanner.macros b/Scanner.macros index f59c7d1..f5f1b17 100644 --- a/Scanner.macros +++ b/Scanner.macros @@ -681,3 +681,8 @@ ~&SYSCNT dec &a ~restm mend + macro +&l jge &bp +&l blt *+5 + brl &bp + mend diff --git a/Scanner.pas b/Scanner.pas index e0bea54..b7d57f2 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -1667,7 +1667,8 @@ if rawSourceCode then begin i := 1; 1: while i <= len do begin ch := chr(cp^); - if ch = '?' then {handle trigraphs} + {handle trigraphs} + if (ch = '?') and (cStd < c23) then if i < len-1 then if chr(ptr(ord4(cp)+1)^) = '?' then if chr(ptr(ord4(cp)+2)^) in @@ -5069,7 +5070,7 @@ if cp = eofPtr then PeekCh := chr(0) else begin ch := chr(cp^); - if ch = '?' then {handle trigraphs} + if (ch = '?') and (cStd < c23) then {handle trigraphs} if ord4(eofPtr)-ord4(cp) > 2 then if chr(ptr(ord4(cp)+1)^) = '?' then if chr(ptr(ord4(cp)+2)^) in