diff --git a/components/codetools/h2pastool.pas b/components/codetools/h2pastool.pas index 0d46c56184..9a05225b9a 100644 --- a/components/codetools/h2pastool.pas +++ b/components/codetools/h2pastool.pas @@ -1458,8 +1458,14 @@ var AtomStart: integer; p: Integer; - procedure Replace(const NewAtom: string); + procedure Replace(NewAtom: string); begin + if IsIdentChar[NewAtom[1]] + and (AtomStart>1) and (IsIdentChar[PasExpression[AtomStart-1]]) then + NewAtom:=' '+NewAtom; + if IsIdentChar[NewAtom[length(NewAtom)]] + and (p<=length(PasExpression)) and (IsIdentChar[PasExpression[p]]) then + NewAtom:=NewAtom+' '; PasExpression:=copy(PasExpression,1,AtomStart-1)+NewAtom +copy(PasExpression,p,length(PasExpression)); p:=AtomStart+length(NewAtom); @@ -1529,6 +1535,19 @@ begin if (CurAtom='(') or (CurAtom=')') or (CurAtom='+') or (CurAtom='-') then begin // same in pascal + end else if (CurAtom='*') then begin + // can be multiplication or dereference or pointer type + if (AtomStart>1) and (IsNumberChar[PasExpression[AtomStart-1]]) then + begin + // is multiplication + end else begin + // don't know + exit; + end; + end else if (CurAtom='|') then begin + Replace('or'); + end else if (CurAtom='&') then begin + Replace('and'); end else begin DebugLn(['TH2PasTool.MacroValueIsConstant NO ',CurAtom]); // unknown diff --git a/components/codetools/nonpascalcodetools.pas b/components/codetools/nonpascalcodetools.pas index 701f69bea8..73bb97358a 100644 --- a/components/codetools/nonpascalcodetools.pas +++ b/components/codetools/nonpascalcodetools.pas @@ -375,7 +375,7 @@ begin if (Position<1) or (Position>l) or (not IsNumberChar[Source[Position]]) then exit; // check octal and hex number - if (Source[Position]='0') and (Source[Position] in ['x','0'..'9']) + if (Source[Position]='0') and (Source[Position+1] in ['x','0'..'9']) then exit; // check float inc(Position);