mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 21:49:18 +02:00
* Patch from Pascal Riekenberg to allow using BOM markers in source files (bug ID 34344)
git-svn-id: trunk@39832 -
This commit is contained in:
parent
8495967fc2
commit
4bb4eb5cca
@ -4259,6 +4259,13 @@ begin
|
|||||||
FCurLine := CurSourceFile.ReadLine;
|
FCurLine := CurSourceFile.ReadLine;
|
||||||
FTokenStr := PChar(CurLine);
|
FTokenStr := PChar(CurLine);
|
||||||
Result := true;
|
Result := true;
|
||||||
|
if (FCurRow = 0)
|
||||||
|
and (Length(CurLine) >= 3)
|
||||||
|
and (FTokenStr[0] = #$EF)
|
||||||
|
and (FTokenStr[1] = #$BB)
|
||||||
|
and (FTokenStr[2] = #$BF) then
|
||||||
|
// ignore UTF-8 Byte Order Mark
|
||||||
|
inc(FTokenStr, 3);
|
||||||
Inc(FCurRow);
|
Inc(FCurRow);
|
||||||
inc(FModuleRow);
|
inc(FModuleRow);
|
||||||
FCurColumnOffset:=1;
|
FCurColumnOffset:=1;
|
||||||
|
@ -244,6 +244,7 @@ type
|
|||||||
procedure TestIfError;
|
procedure TestIfError;
|
||||||
Procedure TestModeSwitch;
|
Procedure TestModeSwitch;
|
||||||
Procedure TestOperatorIdentifier;
|
Procedure TestOperatorIdentifier;
|
||||||
|
Procedure TestUTF8BOM;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -1744,6 +1745,12 @@ begin
|
|||||||
TestToken(tkidentifier,'operator',True);
|
TestToken(tkidentifier,'operator',True);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestScanner.TestUTF8BOM;
|
||||||
|
|
||||||
|
begin
|
||||||
|
DoTestToken(tkLineEnding,#$EF+#$BB+#$BF);
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterTests([TTestTokenFinder,TTestStreamLineReader,TTestScanner]);
|
RegisterTests([TTestTokenFinder,TTestStreamLineReader,TTestScanner]);
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user