mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-02 19:29:21 +00:00
Restrict octal escape sequences in character constants and strings to at most three octal digits.
This is what is required by the C standards. This partially reverts a change in ORCA/C 2.1.0, which should only have been applied to hexadecimal escape sequences.
This commit is contained in:
parent
75bb522025
commit
a69fc2be59
10
Scanner.pas
10
Scanner.pas
@ -3236,6 +3236,7 @@ var
|
|||||||
label 1;
|
label 1;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
cnt: 0..3; {for counting octal escape sequences}
|
||||||
dig: 0..15; {value of a hex digit}
|
dig: 0..15; {value of a hex digit}
|
||||||
skipChar: boolean; {get next char when done?}
|
skipChar: boolean; {get next char when done?}
|
||||||
val: 0..4095; {hex escape code value (scaled to 0..255)}
|
val: 0..4095; {hex escape code value (scaled to 0..255)}
|
||||||
@ -3248,8 +3249,10 @@ var
|
|||||||
case lch of
|
case lch of
|
||||||
'0','1','2','3','4','5','6','7': begin
|
'0','1','2','3','4','5','6','7': begin
|
||||||
val := 0;
|
val := 0;
|
||||||
while lch in ['0'..'7'] do begin
|
cnt := 0;
|
||||||
|
while (cnt < 3) and (lch in ['0'..'7']) do begin
|
||||||
val := (val << 3) | (ord(lch) & 7);
|
val := (val << 3) | (ord(lch) & 7);
|
||||||
|
cnt := cnt+1;
|
||||||
NextCh;
|
NextCh;
|
||||||
end; {while}
|
end; {while}
|
||||||
EscapeCh := val & $FF;
|
EscapeCh := val & $FF;
|
||||||
@ -3637,6 +3640,7 @@ var
|
|||||||
label 1;
|
label 1;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
cnt: 0..3; {for counting octal escape sequences}
|
||||||
dig: 0..15; {value of a hex digit}
|
dig: 0..15; {value of a hex digit}
|
||||||
skipChar: boolean; {get next char when done?}
|
skipChar: boolean; {get next char when done?}
|
||||||
val: 0..4095; {hex escape code value (scaled to 0..255)}
|
val: 0..4095; {hex escape code value (scaled to 0..255)}
|
||||||
@ -3649,8 +3653,10 @@ var
|
|||||||
case ch of
|
case ch of
|
||||||
'0','1','2','3','4','5','6','7': begin
|
'0','1','2','3','4','5','6','7': begin
|
||||||
val := 0;
|
val := 0;
|
||||||
while ch in ['0'..'7'] do begin
|
cnt := 0;
|
||||||
|
while (cnt < 3) and (ch in ['0'..'7']) do begin
|
||||||
val := (val << 3) | (ord(ch) & 7);
|
val := (val << 3) | (ord(ch) & 7);
|
||||||
|
cnt := cnt+1;
|
||||||
NextCh;
|
NextCh;
|
||||||
end; {while}
|
end; {while}
|
||||||
EscapeCh := val & $FF;
|
EscapeCh := val & $FF;
|
||||||
|
Loading…
Reference in New Issue
Block a user