Use escape sequences in format strings printed by the format checker.

Error messages are now lined up to account for the actual printed length of any escape sequences.
This commit is contained in:
Stephen Heumann 2018-09-02 00:18:26 -05:00
parent 7493ffa76c
commit d3aff49550

View File

@ -126,7 +126,7 @@ var
} }
var var
i: integer; i: integer;
c: char; ch: char;
begin {Warning} begin {Warning}
if error_count = 0 then begin if error_count = 0 then begin
@ -136,9 +136,28 @@ var
if s <> nil then begin if s <> nil then begin
Write(' > "'); Write(' > "');
for i := 1 to s^.length do begin for i := 1 to s^.length do begin
c := s^.str[i]; ch := s^.str[i];
if (c = '"') or (ord(c) < $20) or (ord(c) > $7f) then c := '.'; if ch in [' '..'~'] then begin
Write(c); if ch in ['"','\','?'] then
write('\');
write(ch);
end {if}
else
case ord(ch) of
7: write('\a');
8: write('\b');
9: write('\t');
10: write('\n');
11: write('\v');
12: write('\f');
13: write('\r');
otherwise: begin
write('\');
write((ord(ch)>>6):1);
write(((ord(ch)>>3) & $0007):1);
write((ord(ch) & $0007):1);
end;
end; {case}
end; {for} end; {for}
WriteLn('"'); WriteLn('"');
end; {if} end; {if}
@ -146,10 +165,28 @@ var
error_count := error_count + 1; error_count := error_count + 1;
Write(' '); Write(' ');
if offset = 0 then if offset = 0 then
if s <> nil then if s <> nil then begin
offset := s^.length + 1; offset := s^.length;
write(' ');
end; {if}
if offset > 0 then begin if offset > 0 then begin
for i := 1 to offset do Write(' '); if s <> nil then begin
if offset > s^.length then
offset := s^.length;
for i := 1 to offset do begin
ch := s^.str[i];
if ch in [' '..'~'] then begin
if ch in ['"','\','?'] then
write(' ');
write(' ');
end {if}
else
case ord(ch) of
7,8,9,10,11,12,13: write(' ');
otherwise: write(' ');
end; {case}
end; {for}
end; {if}
Write('^ '); Write('^ ');
end; {if} end; {if}
WriteLn(msg^); WriteLn(msg^);