[fpc-devel] Questions on TStringList.Find change (Mantis 28744)

Michael Van Canneyt michael at freepascal.org
Sat Mar 26 13:50:18 CET 2016



On Sat, 26 Mar 2016, C Western wrote:

> On 26/03/16 09:19, Michael Van Canneyt wrote:
>> I have implemented a new property
>>
>>   TStringsSortStyle = (sslNone,sslUser,sslAuto);
>>
>>   Property SortStyle : TStringsSortStyle Read FSortStyle Write
>> SetSortStyle;
>> 
>> I assume the meaning is clear.
>> 
>> - Sorted is true if SortStyle is in [sslUser,sslAuto], so it reflects
>> actual state.
>> 
>> - Setting sorted to True is equivalent to setting SortStyle = sslAuto
>> 
>> - Setting sorted to false is equivalent to setting SortStyle = sslNone
>> 
>> - Find will work on one of those values, but it will raise an exception
>> if sortstyle = sslnone
>> 
>> - Add will put a new string on the 'correct' place if SortStyle=sslAuto
>> 
>> - Insert will raise an error (as it was) if SortStyle=sslAuto.
>> 
>> Michael.
>
> I think you might have missed updating a file:
>
> bootstrap/ppcx64 -Ur -gl -Ur -Xs -O2 -n -Fi../inc -Fi../x86_64 -Fi../unix 
> -Fix86_64 -FE. -FU/home/ctcmw/fpc/trunk.w/fpcsrc/rtl/units/x86_64-linux -Cg 
> -dx86_64 -dDEBUG -dRELEASE -Fi../objpas/classes ../unix/classes.pp
> stringl.inc(1447,29) Error: Identifier not found "SErrFindNeedsSortedList"

Correct. Committed the file.

>
> On a related matter - is this insensitive to changes in the system/rtl sort 
> order? I had a difficult to find problem recently where I had some code in an 
> initialization section that prepared a sorted string list (or something like 
> it). The use of this in the main program then broke when I added another 
> package to the program (in fact fpSpreadsheet) that forced inclusion of 
> cwstrings to the program, but implicitly after the initialization discussed. 
> This was easily fixed by adding cwstrings at the top of the lpr file. I am 
> not sure if this is something that can be more generally fixed, but if there 
> is anything that can reduce the possibilities for confusion that would be 
> good.

This is unrelated, and has to do with the fact that the stringlist by
default is sorted case-insensitively.

Michael.



More information about the fpc-devel mailing list