MichaƂ Kamburelis mkambi at poczta.onet.pl
Fri Feb 14 02:21:27 CET 2003

Hello !

You found a bug : CompareStr( 'hello', 'hello-bye' ) = 0.
It's already fixed in FPC 1.1 and 1.0.7, so I guess you're using FPC 1.0.6
or older. You can switch to FPC 1.0.7 or you can fix this by editing RTL
sources :

At least for FPC 1.0.6, it's in file rtl/objpas/sysstr.inc, lines 109 - 110
You should replace these two lines
   if Count1 > Count2 then result := ord(s1[Count1 + 1])
   else result := -ord(s2[Count2 + 1]);
   if Count1 > Count2 then result := ord(s1[Count + 1])
   else result := -ord(s2[Count + 1]);
(that is, the "Count1" and "Count2" in array indexes should be replaced
with  "Count").

That's all for THAT bug.
But while reading the code of CompareStr function we can see there's
another bug and it still exists in FPC 1.1 : CompareStr('hello',
'hello'#0'bye') will return 0 ! We can change the code in many ways to
remove this disadvantage or we can state somewhere clearly that CompareStr
doesn't work for strings that include #0 character inside (I myself would
prefer the first option). This problem goes to the developers of FPC RTL.

Sorry for my poor english grammar.
Regards, Michalis Kamburelis
mkambi at poczta.onet.pl


Tanie bilety lotnicze!

More information about the fpc-pascal mailing list