mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-27 16:50:33 +02:00
* Skip UTF-8 BOM in TParser (classes) and dfmreader (fcl-res)
git-svn-id: trunk@14292 -
This commit is contained in:
parent
f191ab39cd
commit
d257b19798
@ -131,6 +131,9 @@ begin
|
||||
fLine:='';
|
||||
while fLine='' do
|
||||
ReadLine(aStream);
|
||||
//skip UTF-8 BOM, if needed
|
||||
if (copy(fLine,1,3)=(#$EF+#$BB+#$BF)) then
|
||||
inc(fLinePos,3);
|
||||
tmp:=lowercase(GetIdent);
|
||||
if (tmp <> 'object') and (tmp<>'inherited') then exit;
|
||||
if GetIdent='' then exit;
|
||||
|
@ -1414,6 +1414,7 @@ type
|
||||
function GetHexValue(c : char) : byte; {$ifdef CLASSESINLINE} inline; {$endif CLASSESINLINE}
|
||||
function GetAlphaNum : string;
|
||||
procedure HandleNewLine;
|
||||
procedure SkipBOM;
|
||||
procedure SkipSpaces;
|
||||
procedure SkipWhitespace;
|
||||
procedure HandleEof;
|
||||
|
@ -119,6 +119,25 @@ begin
|
||||
fDeltaPos:=-(fPos-1);
|
||||
end;
|
||||
|
||||
procedure TParser.SkipBOM;
|
||||
var
|
||||
i : integer;
|
||||
bom : string[3];
|
||||
backup : integer;
|
||||
begin
|
||||
i:=1;
|
||||
bom:=' ';
|
||||
backup:=fPos;
|
||||
while (fBuf[fPos] in [#$BB,#$BF,#$EF]) and (i<=3) do
|
||||
begin
|
||||
bom[i]:=fBuf[fPos];
|
||||
inc(fPos);
|
||||
inc(i);
|
||||
end;
|
||||
if (bom<>(#$EF+#$BB+#$BF)) then
|
||||
fPos:=backup;
|
||||
end;
|
||||
|
||||
procedure TParser.SkipSpaces;
|
||||
begin
|
||||
while fBuf[fPos] in [' ',#9] do
|
||||
@ -304,6 +323,7 @@ begin
|
||||
fFloatType:=#0;
|
||||
fToken:=#0;
|
||||
LoadBuffer;
|
||||
SkipBom;
|
||||
NextToken;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user