* Skip UTF-8 BOM in TParser (classes) and dfmreader (fcl-res)

git-svn-id: trunk@14292 -
This commit is contained in:
giulio2 2009-11-30 21:55:25 +00:00
parent f191ab39cd
commit d257b19798
3 changed files with 24 additions and 0 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;