From 2067da9a620f0fb52b325d0671e67d08a2203f0b Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Wed, 30 Apr 2008 19:02:01 +0000 Subject: [PATCH] * 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 - --- rtl/objpas/sysutils/sysstr.inc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rtl/objpas/sysutils/sysstr.inc b/rtl/objpas/sysutils/sysstr.inc index c1879169c6..b6455422bf 100644 --- a/rtl/objpas/sysutils/sysstr.inc +++ b/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;