diff --git a/components/codetools/customcodetool.pas b/components/codetools/customcodetool.pas index 4f18ae0813..1883b0a735 100644 --- a/components/codetools/customcodetool.pas +++ b/components/codetools/customcodetool.pas @@ -833,7 +833,7 @@ begin if CurPos.StartPos>SrcLen then exit(false); p:=@Src[CurPos.StartPos]; if p^ in ['0'..'9','%','$'] then exit(true); - if (p^='&') and (p[1] in ['0'..'7']) then exit(true); + if (p^='&') and IsOctNumberChar[p[1]] then exit(true); Result:=false; end; @@ -1229,10 +1229,10 @@ begin '&': // octal number or keyword as identifier begin inc(p); - if p^ in ['0'..'7'] then begin - while p^ in ['0'..'7'] do + if IsOctNumberChar[p^] then begin + while IsOctNumberChar[p^] do inc(p); - end else if IsIdentChar[p^] then begin + end else if IsIdentStartChar[p^] then begin CurPos.Flag:=cafWord; while IsIdentChar[p^] do inc(p); diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index 748a0b4829..6bd7bc644e 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -5170,7 +5170,7 @@ begin // -> check if a space must be inserted if AddAtom and ( ((phpCommentsToSpace in Attr) and (CurPos.StartPos>LastAtomEndPos)) - or ((CurPos.StartPos<=SrcLen) and (IsIdentChar[Src[CurPos.StartPos]]) + or ((CurPos.StartPos<=SrcLen) and (IsIdentChar[Src[CurPos.StartPos]] or (Src[CurPos.StartPos] = '&')) and ExtractStreamEndIsIdentChar) ) then begin diff --git a/components/codetools/sourcechanger.pas b/components/codetools/sourcechanger.pas index b781448e20..abc7e3ce33 100644 --- a/components/codetools/sourcechanger.pas +++ b/components/codetools/sourcechanger.pas @@ -1381,6 +1381,28 @@ begin then CurAtomType:=atKeyword; end; + '&': //identifier prefixed with '&' or octal number + begin + inc(CurPos); + if CurPos<=SrcLen then + case Src[CurPos] of + 'a'..'z','A'..'Z','_'://identifier prefixed with '&' + begin + CurAtomType:=atIdentifier; + repeat + inc(CurPos); + until (CurPos>SrcLen) or (not IsIdentChar[Src[CurPos]]); + end; + '0'..'7'://octal number + begin + CurAtomType:=atNumber; + repeat + inc(CurPos); + until (CurPos>SrcLen) or (not IsOctNumberChar[Src[CurPos]]); + end; + end else + CurAtomType:=atNone; + end; #128..#255: // UTF8 begin CurAtomType:=atIdentifier;