Speaking of end of line conventions, here's issue 1472 :)

CrLfStream fails horribly currently, since the UTF8-converters latin1map never 
gets initialized.
detectLineEndConvention gets called before converter is installed, and later 
on, 
in MultiByteFileStream>>open: forWrite: , converter lineendings never gets set 
(and latin1map initialized) if lineEndConvention isn't nil.

Alternatives:

1. ensure lineEndConvention installation:

MultiByteFileStream>>open: fileName forWrite: writeMode 
        | result |
        result := super open: fileName forWrite: writeMode.
        result ifNotNil: [
                        converter ifNil: [converter := UTF8TextConverter new].
                        lineEndConvention ifNil: [ self detectLineEndConvention 
]
                                                        ifNotNil: [self 
installLineEndConventionInConverter]
        ].
        ^result

2. Use converter: instead, since that installs the lineEndConvention:
MultiByteFileStream>>open: fileName forWrite: writeMode 
        | result |
        result := super open: fileName forWrite: writeMode.
        result ifNotNil: [
                        converter ifNil: [self converter: UTF8TextConverter 
new].
                        lineEndConvention ifNil: [ self detectLineEndConvention 
]
                                                        
        ].
        ^result

Ironically, if no lineEndConvention is defined, it will default to the same 
line-ending as you would get with a CrLfStream anyways :P

I'm  submitting a slice with approach 2 to inbox.

Cheers,
Henry



_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to