Browse Source

* patch from Giulio Bernardi to fix the generic AnsiStrIComp,
AnsiStrLComp and AnsiStrLIComp (mantis #11235):
* fixed wrong equality result in case one of the strings
was shorter than the other but matched the start
* AnsiStrLComp and AnsiStrLIComp should ignore embedded #0
characters

git-svn-id: trunk@10846 -

Jonas Maebe 17 years ago
parent
commit
2067da9a62
1 changed files with 8 additions and 3 deletions
  1. 8 3
      rtl/objpas/sysutils/sysstr.inc

+ 8 - 3
rtl/objpas/sysutils/sysstr.inc

@@ -339,7 +339,12 @@ begin
     Result:=Ord(LowerCaseTable[Ord(S1[0])])-Ord(LowerCaseTable[Ord(S2[0])]); //!! Must be replaced by ansi characters !!
     Inc(S1);
     Inc(S2);
-  Until (Result<>0) or ((S1[0]=#0) or (S2[0]=#0))
+  Until (Result<>0) or ((S1[0]=#0) or (S2[0]=#0));
+  if (Result=0) and (s1[0]<>s2[0]) then //length(s1)<>length(s2)
+    if s1[0]=#0 then
+      Result:=-1 //s1 shorter than s2
+    else
+      Result:=1; //s1 longer than s2
 end;
 
 
@@ -367,7 +372,7 @@ begin
     Inc(S1);
     Inc(S2);
     Inc(I);
-  Until (Result<>0) or ((S1[0]=#0) or (S2[0]=#0)) or (I=MaxLen)
+  Until (Result<>0) or (I=MaxLen)
 end;
 
 
@@ -395,7 +400,7 @@ begin
     Inc(S1);
     Inc(S2);
     Inc(I);
-  Until (Result<>0) or ((S1[0]=#0) or (S2[0]=#0)) or (I=MaxLen)
+  Until (Result<>0) or (I=MaxLen)
 end;