Bladeren bron

Change CompareChar uses inside compiler/RTL to CompareByte.

Rika Ichinose 5 maanden geleden
bovenliggende
commit
6631f83ccf

+ 1 - 1
compiler/cutils.pas

@@ -1244,7 +1244,7 @@ implementation
           Count:=Count2
         else
           Count:=Count1;
-        result := CompareChar(S1[1],S2[1], Count);
+        result := CompareByte(S1[1],S2[1], Count);
         if result=0 then
           result:=Count1-Count2;
       end;

+ 1 - 1
packages/rtl-objpas/src/inc/strutils.pp

@@ -2980,7 +2980,7 @@ begin
      c:=substr[1];
      repeat
        if (c=pc^) and
-          (CompareChar(Substr[1],pc^,llen)=0) then
+          (CompareByte(Substr[1],pc^,llen)=0) then
         begin
           rPosex:=pc-pc2+1;
           exit;

+ 1 - 1
rtl/objpas/classes/classes.inc

@@ -1791,7 +1791,7 @@ function CollectionsEqual(C1, C2: TCollection; Owner1, Owner2: TComponent): Bool
       try
         stream_collection(s1,c1,owner1);
         stream_collection(s2,c2,owner2);
-        result:=(s1.size=s2.size) and (CompareChar(s1.memory^,s2.memory^,s1.size)=0);
+        result:=(s1.size=s2.size) and (CompareByte(s1.memory^,s2.memory^,s1.size)=0);
       finally
         s2.free;
       end;

+ 6 - 6
rtl/objpas/sysutils/syshelps.inc

@@ -489,9 +489,9 @@ begin
       Result:=SameText(System.Copy(Self,NS-L+1,L),AValue)
     else
 {$IFDEF IS_SHORTSTRINGHELPER}
-      Result:=CompareChar(PTStringChar(@Self[1])[NS-L],PTStringChar(@AValue[1])^,L)=0;
+      Result:=CompareByte(PTStringChar(@Self[1])[NS-L],PTStringChar(@AValue[1])^,L*sizeof(TStringChar))=0;
 {$ELSE}
-      Result:=CompareChar(PTStringChar(Pointer(Self))[NS-L],PTStringChar(Pointer(AValue))^,L)=0;
+      Result:=CompareByte(PTStringChar(Pointer(Self))[NS-L],PTStringChar(Pointer(AValue))^,L*sizeof(TStringChar))=0;
 {$ENDIF}
 end;
 
@@ -619,10 +619,10 @@ begin
           Break;
         SP:=SP+Ofs+1;
         {$IFDEF IS_SHORTSTRINGHELPER}
-        if CompareChar(SP^,PTStringChar(@AValue[1])[1],NV-1)=0 then
+        if CompareByte(SP^,PTStringChar(@AValue[1])[1],(NV-1)*sizeof(TStringChar))=0 then
           Exit(SP-PTStringChar(@Self[1])-1);
         {$ELSE}
-        if CompareChar(SP^,PTStringChar(Pointer(AValue))[1],NV-1)=0 then
+        if CompareByte(SP^,PTStringChar(Pointer(AValue))[1],(NV-1)*sizeof(TStringChar))=0 then
           Exit(SP-PTStringChar(Pointer(Self))-1);
         {$ENDIF}
       until false;
@@ -1344,9 +1344,9 @@ begin
       Result:=SameText(System.Copy(Self,1,L),AValue)
     else
 {$IFDEF IS_SHORTSTRINGHELPER}
-      Result:=CompareChar(PTStringChar(@Self[1])^,PTStringChar(@AValue[1])^,L)=0;
+      Result:=CompareByte(PTStringChar(@Self[1])^,PTStringChar(@AValue[1])^,L*sizeof(TStringChar))=0;
 {$ELSE}
-      Result:=CompareChar(PTStringChar(Pointer(Self))^,PTStringChar(Pointer(AValue))^,L)=0;
+      Result:=CompareByte(PTStringChar(Pointer(Self))^,PTStringChar(Pointer(AValue))^,L*sizeof(TStringChar))=0;
 {$ENDIF}
 end;