diff --git a/components/codetools/basiccodetools.pas b/components/codetools/basiccodetools.pas index 4747e99c98..98c3bfa179 100644 --- a/components/codetools/basiccodetools.pas +++ b/components/codetools/basiccodetools.pas @@ -112,7 +112,7 @@ function GetIdentifier(Identifier: PChar; const aSkipAmp: Boolean = True; function FindNextIdentifier(const Source: string; StartPos, MaxPos: integer): integer; function FindNextIdentifierSkipStrings(const Source: string; StartPos, MaxPos: integer): integer; -function IsValidDottedIdent(const Ident: string; AllowDots: Boolean = True): Boolean; // as IsValidIdentifier, but faster and supports & +function IsValidDottedIdent(const Ident: string; AllowDots: Boolean = True): Boolean; // as sysutils.IsValidIdent, but faster and supports & function IsValidIdentPair(const NamePair: string): boolean; function IsValidIdentPair(const NamePair: string; out First, Second: string): boolean; function ExtractPasIdentifier(const Ident: string; AllowDots: Boolean): string; @@ -193,7 +193,7 @@ function dbgsDiff(Expected, Actual: string): string; overload; // dotted identifiers function DottedIdentifierLength(Identifier: PChar): integer; function GetDottedIdentifier(Identifier: PChar): string; -function IsDottedIdentifier(const Identifier: string; WithAmp: boolean = True): boolean; +function IsDottedIdentifier(const Identifier: string; AllowAmp: boolean = True): boolean; function IsIdentifierDotted(const Identifier: string; Validate: Boolean = False): boolean; function CompareDottedIdentifiers(Identifier1, Identifier2: PChar): integer; function CompareDottedIdentifiersCaseSensitive(Identifier1, Identifier2: PChar): integer; @@ -5336,15 +5336,16 @@ begin Result:= Result and ((p-PChar(Identifier))=length(Identifier)); end; -function IsDottedIdentifier(const Identifier: string; WithAmp: boolean): boolean; +function IsDottedIdentifier(const Identifier: string; AllowAmp: boolean): boolean; var - p: PChar; + p, StartP: PChar; begin Result:=false; if Identifier='' then exit; p:=PChar(Identifier); + StartP:=p; repeat - if WithAmp and (p^='&') then + if AllowAmp and (p^='&') then inc(p); if not IsIdentStartChar[p^] then exit; repeat @@ -5353,7 +5354,7 @@ begin if p^<>'.' then break; inc(p); until false; - Result:=(p-PChar(Identifier))=length(Identifier); + Result:=(p-StartP)=length(Identifier); end; function CompareDottedIdentifiers(Identifier1, Identifier2: PChar): integer; diff --git a/components/codetools/customcodetool.pas b/components/codetools/customcodetool.pas index db2e0ae5be..93f47ebeb4 100644 --- a/components/codetools/customcodetool.pas +++ b/components/codetools/customcodetool.pas @@ -3265,7 +3265,7 @@ function TCustomCodeTool.ExtractIdentifierWithPointsOutEndPos( StartPos: integer //result = "dotted.ident.unit1" and comment = "{but contaminated}{comment}" var beforePos, aLen: integer; - commentAtom: string; + CommentAtom: string; begin Result:=''; Comment:=''; @@ -3285,16 +3285,16 @@ begin exit; inc(aLen); if curPos.StartPos-beforePos>1 then begin //a comment was at least like {} - setlength(commentAtom,curPos.StartPos-beforePos); - move(src[beforePos],commentAtom[1],curPos.StartPos-beforePos); - Comment+=commentAtom; + setlength({%H-}CommentAtom,curPos.StartPos-beforePos); + move(src[beforePos],CommentAtom[1],curPos.StartPos-beforePos); + Comment+=CommentAtom; end; beforePos:=curPos.EndPos; ReadNextAtom; if curPos.StartPos-beforePos>1 then begin //a comment was at least like {} - setlength(commentAtom,curPos.StartPos-beforePos); - move(src[beforePos],commentAtom[1],curPos.StartPos-beforePos); - Comment+=commentAtom; + setlength(CommentAtom,curPos.StartPos-beforePos); + move(src[beforePos],CommentAtom[1],curPos.StartPos-beforePos); + Comment+=CommentAtom; end; Result+='.'+GetAtom; EndPos:=CurPos.EndPos; diff --git a/components/codetools/pascalreadertool.pas b/components/codetools/pascalreadertool.pas index 3edd61f4be..4358cff223 100644 --- a/components/codetools/pascalreadertool.pas +++ b/components/codetools/pascalreadertool.pas @@ -108,7 +108,7 @@ type function ExtractIdentifierWithPointsOutEndPos(StartPos: integer; out EndPos: integer; StopAtLen: integer=0): string; function ExtractIdentifierWithPointsOutEndPos(StartPos: integer; - var Comment: string; out EndPos: integer; StopAtLen: integer=0): string; + out Comment: string; out EndPos: integer; StopAtLen: integer=0): string; function ExtractNextTypeRef(Add: boolean; const Attr: TProcHeadAttributes): boolean; function ExtractNextSpecializeParams(Add: boolean; const Attr: TProcHeadAttributes): boolean; @@ -1637,7 +1637,7 @@ begin end; function TPascalReaderTool.ExtractIdentifierWithPointsOutEndPos( - StartPos: integer; var Comment: string; out EndPos: integer; + StartPos: integer; out Comment: string; out EndPos: integer; StopAtLen: integer=0): string; //the function intended to extract dotted identifier //and cumulative comment from source