--- a/UninterpretedBytes.st Fri Jul 31 21:14:12 2015 +0200
+++ b/UninterpretedBytes.st Mon Aug 03 11:58:16 2015 +0200
@@ -81,28 +81,28 @@
"
UninterpretedBytes provides the common protocol for byte-storage
containers; concrete subclasses are
- ByteArray (which store the bytes within the Smalltalk object memory)
- String (knows that the bytes represent characters)
+ ByteArray (which store the bytes within the Smalltalk object memory)
+ String (knows that the bytes represent characters)
and
- ExternalBytes (which store the bytes in the malloc-heap).
+ ExternalBytes (which store the bytes in the malloc-heap).
UninterpretedBytes itself is abstract, so no instances of it can be created.
[See also:]
- ByteArray String ExternalBytes
+ ByteArray String ExternalBytes
[author:]
- Claus Gittinger
+ Claus Gittinger
[Notice:]
- Notice the confusion due to multiple methods with the same
- functionality (i.e. 'xxxx:MSB:' vs. 'xxxx:bigEndian:').
- The reason is that at the time this class was written,
- ST80 sid not offer protocol to specify the byteOrder, and
- ST/X provided methods ending in 'MSB:' for this.
- In the meanwhile, VW added protocol ending in 'bigEndian:',
- which has been added here for compatibility.
- (certainly a point, where an ansi-standard will help)
+ Notice the confusion due to multiple methods with the same
+ functionality (i.e. 'xxxx:MSB:' vs. 'xxxx:bigEndian:').
+ The reason is that at the time this class was written,
+ ST80 sid not offer protocol to specify the byteOrder, and
+ ST/X provided methods ending in 'MSB:' for this.
+ In the meanwhile, VW added protocol ending in 'bigEndian:',
+ which has been added here for compatibility.
+ (certainly a point, where an ansi-standard will help)
"
! !
@@ -197,7 +197,7 @@
of 4 in size (since 24 is the lcm of 6 and 8).
Every 6 bit packet is encoded as a character in 32..95.
Characters below 32 are ignored (so line breaks can be inserted at any place).
- An addition final byte defines how many bytes of the last triple are valid.
+ An addition final byte defines how many bytes of the last triple are valid.
This is somewhat like the radix-encoding used in good old PDP11 times ;-)
ST-80 uses this encoding for Images ...
This is a base64 encoding, very similar (but not equal) to the algorithm used in RFC1421.
@@ -222,47 +222,47 @@
last := aString last codePoint.
last > 96 ifTrue:[
- stop := stop - 3 + (last - 96)
+ stop := stop - 3 + (last - 96)
].
bytes := self new:stop.
index := 1. dstIndex := 1.
[dstIndex <= stop] whileTrue:[
- "/ take 4 characters ...
- "/ allow a line break before each group of 4
- sixBits := (aString at:index) codePoint.
- [sixBits < 32] whileTrue:[
- index := index + 1.
- sixBits := (aString at:index) codePoint.
- ].
- sixBits := sixBits bitAnd:16r3F.
- n := sixBits.
-
- "/ self assert:(aString at:index+1) codePoint >= 32.
- sixBits := (aString at:index+1) codePoint bitAnd:16r3F.
- n := (n bitShift:6) + sixBits.
-
- "/ self assert:(aString at:index+2) codePoint >= 32.
- sixBits := (aString at:index+2) codePoint bitAnd:16r3F.
- n := (n bitShift:6) + sixBits.
-
- "/ self assert:(aString at:index+3) codePoint >= 32.
- sixBits := (aString at:index+3) codePoint bitAnd:16r3F.
- n := (n bitShift:6) + sixBits.
-
- index := index + 4.
-
- "/ now have 24 bits in n
-
- bytes at:dstIndex put:(n bitShift:-16).
-
- dstIndex < stop ifTrue:[
- bytes at:dstIndex+1 put:((n bitShift:-8) bitAnd:16rFF).
- dstIndex+2 <= stop ifTrue:[
- bytes at:dstIndex+2 put:(n bitAnd:16rFF).
- ]
- ].
- dstIndex := dstIndex + 3.
+ "/ take 4 characters ...
+ "/ allow a line break before each group of 4
+ sixBits := (aString at:index) codePoint.
+ [sixBits < 32] whileTrue:[
+ index := index + 1.
+ sixBits := (aString at:index) codePoint.
+ ].
+ sixBits := sixBits bitAnd:16r3F.
+ n := sixBits.
+
+ "/ self assert:(aString at:index+1) codePoint >= 32.
+ sixBits := (aString at:index+1) codePoint bitAnd:16r3F.
+ n := (n bitShift:6) + sixBits.
+
+ "/ self assert:(aString at:index+2) codePoint >= 32.
+ sixBits := (aString at:index+2) codePoint bitAnd:16r3F.
+ n := (n bitShift:6) + sixBits.
+
+ "/ self assert:(aString at:index+3) codePoint >= 32.
+ sixBits := (aString at:index+3) codePoint bitAnd:16r3F.
+ n := (n bitShift:6) + sixBits.
+
+ index := index + 4.
+
+ "/ now have 24 bits in n
+
+ bytes at:dstIndex put:(n bitShift:-16).
+
+ dstIndex < stop ifTrue:[
+ bytes at:dstIndex+1 put:((n bitShift:-8) bitAnd:16rFF).
+ dstIndex+2 <= stop ifTrue:[
+ bytes at:dstIndex+2 put:(n bitAnd:16rFF).
+ ]
+ ].
+ dstIndex := dstIndex + 3.
].
^ bytes
@@ -281,13 +281,13 @@
ByteArray fromPackedString:((ByteArray new:64) asPackedString)
0 to:256 do:[:l |
- |orig copy|
-
- 0 to:255 do:[:fill |
- orig := ByteArray new:l withAll:fill.
- copy := ByteArray fromPackedString:(orig asPackedString).
- self assert:(orig = copy).
- ]
+ |orig copy|
+
+ 0 to:255 do:[:fill |
+ orig := ByteArray new:l withAll:fill.
+ copy := ByteArray fromPackedString:(orig asPackedString).
+ self assert:(orig = copy).
+ ]
]
"
@@ -1646,13 +1646,13 @@
* aligned
*/
if (((INT)cp & (sizeof(int)-1)) == 0) {
- int __v;
+ INT __v;
if (__isSmallInteger(value)) {
((int *)cp)[0] = __intVal(value);
RETURN (value);
}
- if (__v = __signedLongIntVal(value)) {
+ if ((__v = __signedLongIntVal(value)) != 0) {
((int *)cp)[0] = __v;
RETURN (value);
}
@@ -2736,8 +2736,8 @@
cls := self class.
(cls == ByteArray or:[cls == ImmutableByteArray or:[cls == ExternalBytes]]) ifTrue:[
- size := self size.
- ^ (String uninitializedNew:size) replaceBytesFrom:1 to:size with:self startingAt:1.
+ size := self size.
+ ^ (String uninitializedNew:size) replaceBytesFrom:1 to:size with:self startingAt:1.
].
^ super asString.
@@ -2773,12 +2773,12 @@
|utf8Encoding original readBack|
1 to:16rFFFF do:[:ascii |
- original := (Character value:ascii) asString.
- utf8Encoding := original utf8Encoded.
- readBack := utf8Encoding utf8Decoded.
- readBack = original ifFalse:[
- self halt
- ]
+ original := (Character value:ascii) asString.
+ utf8Encoding := original utf8Encoded.
+ readBack := utf8Encoding utf8Decoded.
+ readBack = original ifFalse:[
+ self halt
+ ]
]
"
!
@@ -2791,26 +2791,26 @@
|in out c|
self containsNon7BitAscii ifFalse:[
- ^ self asSingleByteString
+ ^ self asSingleByteString
].
out := WriteStream on:(String uninitializedNew:self size * 3 // 2).
in := self readStream.
[in atEnd] whileFalse:[
- c := Character utf8DecodeFrom:in.
- c codePoint > 16rFF ifTrue:[
- c := replacementCharacter
- ].
- out nextPut:c.
+ c := Character utf8DecodeFrom:in.
+ c codePoint > 16rFF ifTrue:[
+ c := replacementCharacter
+ ].
+ out nextPut:c.
].
^ out contents
"
(Character value:16r220) utf8Encoded
- utf8DecodedWithTwoByteCharactersReplacedBy:(Character space)
+ utf8DecodedWithTwoByteCharactersReplacedBy:(Character space)
(Character value:16r220) utf8Encoded asExternalBytes copyButLast
- utf8DecodedWithTwoByteCharactersReplacedBy:(Character space)
+ utf8DecodedWithTwoByteCharactersReplacedBy:(Character space)
"
! !
@@ -3259,9 +3259,9 @@
sz := self size.
1 to:sz do:[:idx|
- (self at:idx) > 16r7F ifTrue:[
- ^ true.
- ].
+ (self at:idx) > 16r7F ifTrue:[
+ ^ true.
+ ].
].
^ false.
!
@@ -3275,14 +3275,14 @@
%{ /* NOCONTEXT */
if (__mkSmallInteger(0) == __ClassInstPtr(__qClass(self))->c_ninstvars) {
- /* I am only bytes */
- RETURN(false)
+ /* I am only bytes */
+ RETURN(false)
}
%}.
^ super referencesAny:aCollection
"
- 'abc' referencesAny:#()
+ 'abc' referencesAny:#()
"
!