From 89aeedac1ec47570922fe219664c3374e93aeb8a Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 1 Dec 2021 22:48:19 +0100 Subject: [PATCH] * fixes excluding of cpu capabilities --- compiler/cutils.pas | 17 +++++++++++++++++ compiler/options.pas | 25 +++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/compiler/cutils.pas b/compiler/cutils.pas index 376073bc8c..1b92d8f51d 100644 --- a/compiler/cutils.pas +++ b/compiler/cutils.pas @@ -95,6 +95,8 @@ interface function trimspace(const s:string):string; function trimspace(const s:AnsiString):AnsiString; function space (b : longint): string; + { returns the position of the first char of the set cs in s, if there is none, then it returns 0 } + function PosCharset(const cs : TCharSet;const s : ansistring) : integer; function PadSpace(const s:string;len:longint):string; function PadSpace(const s:AnsiString;len:longint):AnsiString; function GetToken(var s:string;endchar:char):string; @@ -1181,6 +1183,21 @@ implementation result^:=s; end; + + function PosCharset(const cs : TCharSet;const s : ansistring) : integer; + var + i : integer; + begin + result:=0; + for i:=1 to length(s) do + if s[i] in cs then + begin + result:=i; + exit; + end; + end; + + function CompareStr(const S1, S2: string): Integer; var count, count1, count2: integer; diff --git a/compiler/options.pas b/compiler/options.pas index 5dd3c14779..9718b14606 100644 --- a/compiler/options.pas +++ b/compiler/options.pas @@ -1708,12 +1708,13 @@ begin begin s:=upper(copy(more,j+1,length(more)-j)); {$ifdef cpucapabilities} - if (pos('+',s)<>0) or (pos('-',s)<>0) then + { find first occurrence of + or - } + deletepos:=PosCharset(['+','-'],s); + if deletepos<>0 then begin - deletepos:=min(pos('+',s),pos('-',s)); - extrasettings:=Copy(s,Pos('+',s),Length(s)); - Delete(s,Pos('+',s),Length(s)); - end + extrasettings:=Copy(s,deletepos,Length(s)); + Delete(s,deletepos,Length(s)); + end else extrasettings:=''; {$endif cpucapabilities} @@ -1724,16 +1725,12 @@ begin begin Delete(extrasettings,1,1); includecapability:=true; - if Pos('+',extrasettings)<>0 then + deletepos:=PosCharset(['+','-'],extrasettings); + if deletepos<>0 then begin - s:=Copy(extrasettings,1,Pos('+',extrasettings)-1); - Delete(extrasettings,1,Pos('+',extrasettings)-1); - end - else if Pos('-',extrasettings)<>0 then - begin - s:=Copy(extrasettings,1,Pos('+',extrasettings)-1); - Delete(extrasettings,1,Pos('+',extrasettings)-1); - includecapability:=false; + includecapability:=extrasettings[deletepos]='+'; + s:=Copy(extrasettings,1,deletepos-1); + Delete(extrasettings,1,deletepos-1); end else begin