Converter: Support case insensitive reserved words when inserting '&' in front of an OleVariant member. Fixes issue #23552.

git-svn-id: trunk@42161 -
This commit is contained in:
juha 2013-07-20 17:57:01 +00:00
parent d1794b7b1c
commit cb53e0699e

View File

@ -147,21 +147,25 @@ function TCodeToolLink.DummyReplacements: Boolean;
// Most Codetools functions cannot be used because the code is invalid,
// but TSourceChangeCache.ReplaceEx works.
var
p, i: Integer;
s: string;
p, AStart: Integer;
Src: string;
LastWasPoint: Boolean;
begin
// Reserved words are in WordIsKeyWord list in CodeTools.
for i:=0 to WordIsKeyWord.Count-1 do begin
s:='.'+LowerCase(WordIsKeyWord.GetItem(i).KeyWord);
p:=1;
repeat
p:=PosEx(s,fCode.Source,p); // find next '.'+ReservedWord
if p<1 then break;
if not fSrcCache.ReplaceEx(gtNone,gtNone,1,1,fCode,p+1,p+1,'&') then
p:=1;
LastWasPoint:=false;
Src:=fCode.Source;
repeat
ReadRawNextPascalAtom(Src,p,AStart,false);
if p>length(Src) then break;
// Reserved words are in WordIsKeyWord list in CodeTools.
if LastWasPoint and WordIsKeyWord.DoIdentifier(@Src[AStart]) then
begin
// '.'+ReservedWord was found
if not fSrcCache.ReplaceEx(gtNone,gtNone,1,1,fCode,AStart,AStart,'&') then
Exit(False);
inc(p,length(s));
until false;
end;
end;
LastWasPoint:=Src[AStart]='.';
until false;
// Apply the changes in buffer
if not fSrcCache.Apply then
Exit(False);