diff --git a/components/codetools/ccodeparsertool.pas b/components/codetools/ccodeparsertool.pas index cdfb95d43c..9d4d740694 100644 --- a/components/codetools/ccodeparsertool.pas +++ b/components/codetools/ccodeparsertool.pas @@ -835,8 +835,10 @@ begin ReadDefinition(false); if CurNode.LastChild.Desc<>ccnFunction then begin ReadNextAtom; + debugln(['TCCodeParserTool.OtherToken ',GetAtom,' SrcPos=',SrcPos,' AtomStart=',AtomStart,' SrcLen=',SrcLen]); if not AtomIsChar(';') then RaiseExpectedButAtomFound(';'); + debugln(['TCCodeParserTool.OtherToken AAA1']); end; end else RaiseException('unexpected token '+GetAtom); @@ -1863,7 +1865,7 @@ end; function TCCodeParserTool.AtomIsChar(const c: char): boolean; begin if SrcPos-AtomStart<>1 then exit(false); - if SrcPos>SrcLen then exit(false); + if AtomStart>SrcLen then exit(false); if Src[AtomStart]<>c then exit(false); Result:=true; end; diff --git a/test/codetoolstests/testcth2pas.pas b/test/codetoolstests/testcth2pas.pas index bb20c52291..1da58a5710 100644 --- a/test/codetoolstests/testcth2pas.pas +++ b/test/codetoolstests/testcth2pas.pas @@ -124,7 +124,13 @@ begin try Header1:=CodeToolBoss.CreateFile('header1.h'); PasCode:=CodeToolBoss.CreateFile('header1.pas'); - + Header1.Source:='int i;'; + Tool.Convert(Header1,PasCode); + Tool.WriteH2PNodeReport; + Tool.WriteH2PDirectivesNodeReport; + writeln; + writeln('============================================='); + writeln(PasCode.Source); finally Tool.Free; end;