[Lazarus] Error in UTF8CompareText comment

Mattias Gaertner nc-gaertnma at netcologne.de
Thu Aug 13 12:15:08 CEST 2015


On Thu, 13 Aug 2015 11:52:26 +0200
Jürgen Hestermann <juergen.hestermann at gmx.de> wrote:

> There is a comment for UTF8CompareText in LazUTF8 which is contradictorily:
> 
> // Returns: < 0 if S1 < S2, 0 if S1 = S2, > 0 if S2 > S1.
> 
> But S1 < S2 is the same as S2 > S1.

It should be >0 if S1 > S2. I changed the comment.

> In the first case the result should be < 0 and in the second one > 0.
> 
> It cannot even be retrieved from the code how it realy works (unless you are fit in assembler).
> So when will the result be positive and when negative?

Under Linux it does not use Assembler.
Internally it uses UTF8CompareStr, which uses CompareMemRange, which
returns -1 if a byte of S1 is lower than S2.
I added the comment.

Mattias




More information about the Lazarus mailing list