[Pharo-project] how to deal with string position in relation to cr/crlf

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Thu Apr 28 19:22:25 CEST 2011


I would say you'll have problems if an only if you mix pointers
- on transformed streams
- and on OS-native line-end transparent streams...
You'll have to arrange to either:
- always used a transformed stream
- or always use a native line-end transparent stream.

New utilities in Pharo and Squeak #linesDo: etc... works on any CR,
LF, CRLF conventions, even mixed conventions in a single file at an
acceptable runtime cost.
That may help...

Nicolas

2011/4/28 Alexandre Bergel <alexandre.bergel at me.com>:
> I experienced a similar problem when I worked on CAnalyzer. What I did is simply to remove all lf characters before doing anything.
>
> Alexandre
>
>
>
> Le 28 avr. 2011 à 04:47, Tudor Girba <tudor.girba at gmail.com> a écrit :
>
>> Hi,
>>
>> I have a small problem related to file line endings and storing the token information of PetitParser.
>>
>> Sometimes, we parse the sources on Windows and then manipulate the model on Linux or Mac. In this context, if I store the token positions in a string, I encounter problems because CR and LF are considered characters, but the line endings can vary.
>>
>> ('abc', Character cr asString , 'd') findString: 'd'.
>> ==> 5
>>
>> ('abc', Character cr asString , Character lf asString, 'd') findString: 'd'.
>> ==> 6
>>
>>
>> How would you approach this problem?
>>
>> Cheers,
>> Doru
>>
>>
>> --
>> www.tudorgirba.com
>>
>> "Every thing has its own flow."
>>
>>
>>
>>
>>
>
>



More information about the Pharo-project mailing list