Fix in CharacterArray>>withTabsExpanded: - case for Unicode16/Unicode32 strings jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 21 Apr 2015 17:01:16 +0100
branchjv
changeset 18258 9f83d8bddcf0
parent 18257 877a8f1b326d
child 18259 e8ad15456505
Fix in CharacterArray>>withTabsExpanded: - case for Unicode16/Unicode32 strings For text instances (which inherit from CharacterArray) code like: self species new:newSz. creates new Text withg underlying string as an instance of String, i.e., 8bits per character even if self's string is a wide string. In that the expansion will fail as soon as wide character is copied into an output Text instance. To handle this correctly, treat Text instances specially and create their copy as Text string: (self string class new: newSz). in order to prevent wideness of underlying string.
CharacterArray.st
--- a/CharacterArray.st	Tue Apr 21 10:47:35 2015 +0100
+++ b/CharacterArray.st	Tue Apr 21 17:01:16 2015 +0100
@@ -294,6 +294,7 @@
     "Created: 3.8.1997 / 18:16:40 / cg"
 ! !
 
+
 !CharacterArray class methodsFor:'cleanup'!
 
 lowSpaceCleanup
@@ -4446,6 +4447,8 @@
 ! !
 
 
+
+
 !CharacterArray methodsFor:'matching - glob expressions'!
 
 compoundMatch:aString
@@ -5791,7 +5794,6 @@
     "Modified: 17.4.1997 / 12:50:23 / cg"
 ! !
 
-
 !CharacterArray methodsFor:'special string converting'!
 
 asUnixFilenameString
@@ -6402,7 +6404,11 @@
         ]
     ].
 
-    str := self species new:newSz.
+    self isText ifTrue:[ 
+        str := Text string: (self string class new: newSz).
+    ] ifFalse:[
+        str := self species new:newSz.
+    ].
 
     hasEmphasis := self hasChangeOfEmphasis.
 
@@ -6456,7 +6462,8 @@
              with:$2) withTabsExpanded
     "
 
-    "Modified: 12.5.1996 / 13:05:10 / cg"
+    "Modified: / 12-05-1996 / 13:05:10 / cg"
+    "Modified: / 21-04-2015 / 15:40:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 withoutAllSpaces
@@ -6782,7 +6789,6 @@
     "
 ! !
 
-
 !CharacterArray methodsFor:'substring searching'!
 
 findRangeOfString:subString
@@ -7383,6 +7389,7 @@
     ^ aVisitor visitString:self with:aParameter
 ! !
 
+
 !CharacterArray class methodsFor:'documentation'!
 
 version
@@ -7391,6 +7398,11 @@
 
 version_CVS
     ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.582 2015-04-09 11:42:14 stefan Exp $'
+!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
 ! !