Browse Source

* fixes excluding of cpu capabilities

florian 3 years ago
parent
commit
89aeedac1e
2 changed files with 28 additions and 14 deletions
  1. 17 0
      compiler/cutils.pas
  2. 11 14
      compiler/options.pas

+ 17 - 0
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;

+ 11 - 14
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
-                              begin
-                                s:=Copy(extrasettings,1,Pos('+',extrasettings)-1);
-                                Delete(extrasettings,1,Pos('+',extrasettings)-1);
-                              end
-                            else 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);
-                                includecapability:=false;
+                                includecapability:=extrasettings[deletepos]='+';
+                                s:=Copy(extrasettings,1,deletepos-1);
+                                Delete(extrasettings,1,deletepos-1);
                               end
                             else
                               begin