ByteArray.st
branchjv
changeset 17763 019bb9c842c5
parent 17761 b0e5971141bc
child 17767 a4a32df3aa5e
--- a/ByteArray.st	Thu Apr 29 16:55:35 2010 +0100
+++ b/ByteArray.st	Tue May 04 12:50:05 2010 +0100
@@ -182,8 +182,8 @@
     |answer|
 
     answer := self copy.
-    1 to: self size do: [ :each | 
-        answer at: each put: ((self at: each) bitXor: (aByteArray at: each))
+    1 to: self size do: [ :each |
+	answer at: each put: ((self at: each) bitXor: (aByteArray at: each))
     ].
     ^ answer
 ! !
@@ -284,20 +284,20 @@
     REGISTER OBJ cls;
 
     if (__isSmallInteger(index)) {
-        indx = __intVal(index) - 1;
-        slf = self;
-
-        byte = indx / 8;
-        indx = indx % 8;
-
-        if ((cls = __qClass(slf)) != @global(ByteArray)) {
-            if (indx < 0) goto badIndex;
-            byte += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
-        }
-        nIndex = __byteArraySize(slf);
-        if ((unsigned)byte < (unsigned)nIndex) {
-            RETURN ( __mkSmallInteger(((__ByteArrayInstPtr(slf)->ba_element[byte] & (1 << indx)) != 0)) );
-        }
+	indx = __intVal(index) - 1;
+	slf = self;
+
+	byte = indx / 8;
+	indx = indx % 8;
+
+	if ((cls = __qClass(slf)) != @global(ByteArray)) {
+	    if (indx < 0) goto badIndex;
+	    byte += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+	}
+	nIndex = __byteArraySize(slf);
+	if ((unsigned)byte < (unsigned)nIndex) {
+	    RETURN ( __mkSmallInteger(((__ByteArrayInstPtr(slf)->ba_element[byte] & (1 << indx)) != 0)) );
+	}
     }
 badIndex: ;
 %}.
@@ -307,7 +307,7 @@
     ^  byte bitTest:(1 bitShift:bitIndex0).
 
    "
-     #[ 1 1 1 1 ] bitAt:9     
+     #[ 1 1 1 1 ] bitAt:9
      #[ 1 1 1 1 ] bitAt:11
      #[ 2 2 2 2 ] bitAt:10
    "
@@ -657,38 +657,38 @@
     REGISTER int indx;
     int nIndex;
     union {
-        unsigned char u_char[2];
-        unsigned short u_ushort;
+	unsigned char u_char[2];
+	unsigned short u_ushort;
     } val;
     unsigned char *byteP;
 
     if (__isSmallInteger(index)) {
-        indx = __intVal(index);
-        if (indx > 0) {
-            if (!__isByteArrayLike(self))
-                indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(self))->c_ninstvars));
-            nIndex = __byteArraySize(self);
-            if ((indx+1) <= nIndex) {
-                byteP = (unsigned char *)(__ByteArrayInstPtr(self)->ba_element) + indx - 1;
+	indx = __intVal(index);
+	if (indx > 0) {
+	    if (!__isByteArrayLike(self))
+		indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(self))->c_ninstvars));
+	    nIndex = __byteArraySize(self);
+	    if ((indx+1) <= nIndex) {
+		byteP = (unsigned char *)(__ByteArrayInstPtr(self)->ba_element) + indx - 1;
 #if defined(__i386__) || defined(UNALIGNED_FETCH_OK)
-                val.u_ushort = ((unsigned short *)byteP)[0];
+		val.u_ushort = ((unsigned short *)byteP)[0];
 #else
-                /*
-                 * mhmh to be measured:
-                 *   the if may hurt more than the additional
-                 *   memory cycles on some machines ...
-                 */
-                if (((INT)byteP & 1) == 0) {
-                    /* aligned */
-                    val.u_ushort = ((unsigned short *)byteP)[0];
-                } else {
-                    val.u_char[0] = byteP[0];
-                    val.u_char[1] = byteP[1];
-                }
+		/*
+		 * mhmh to be measured:
+		 *   the if may hurt more than the additional
+		 *   memory cycles on some machines ...
+		 */
+		if (((INT)byteP & 1) == 0) {
+		    /* aligned */
+		    val.u_ushort = ((unsigned short *)byteP)[0];
+		} else {
+		    val.u_char[0] = byteP[0];
+		    val.u_char[1] = byteP[1];
+		}
 #endif
-                RETURN ( __mkSmallInteger((val.u_ushort)) );
-            }
-        }
+		RETURN ( __mkSmallInteger((val.u_ushort)) );
+	    }
+	}
     }
 %}.
     ^ super wordAt:index
@@ -708,59 +708,59 @@
     unsigned char *byteP;
 
     if (__isSmallInteger(index)) {
-        indx = __intVal(index);
-        if (indx > 0) {
-            if (!__isByteArrayLike(self))
-                indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(self))->c_ninstvars));
-            nIndex = __byteArraySize(self);
-            if ((indx+1) <= nIndex) {
-                byteP = (unsigned char *)(__ByteArrayInstPtr(self)->ba_element) + indx - 1;
-                if (msb == true) {
-                    /*
-                     * most significant byte first (i.e sparc order)
-                     */
+	indx = __intVal(index);
+	if (indx > 0) {
+	    if (!__isByteArrayLike(self))
+		indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(self))->c_ninstvars));
+	    nIndex = __byteArraySize(self);
+	    if ((indx+1) <= nIndex) {
+		byteP = (unsigned char *)(__ByteArrayInstPtr(self)->ba_element) + indx - 1;
+		if (msb == true) {
+		    /*
+		     * most significant byte first (i.e sparc order)
+		     */
 #if defined(__MSBFIRST__)
-                    /*
-                     * mhmh to be measured:
-                     *   the if may hurt more than the additional
-                     *   memory cycles on some machines ...
-                     */
-                    if (((INT)byteP & 1) == 0) {
-                        /* aligned */
-                        val = ((unsigned short *)byteP)[0];
-                    } else
+		    /*
+		     * mhmh to be measured:
+		     *   the if may hurt more than the additional
+		     *   memory cycles on some machines ...
+		     */
+		    if (((INT)byteP & 1) == 0) {
+			/* aligned */
+			val = ((unsigned short *)byteP)[0];
+		    } else
 #endif
-                    {
-                        val = byteP[0];
-                        val = (val << 8) + byteP[1];
-                    }
-                } else {
-                    /*
-                     * least significant byte first (i.e i386/alpha order)
-                     */
+		    {
+			val = byteP[0];
+			val = (val << 8) + byteP[1];
+		    }
+		} else {
+		    /*
+		     * least significant byte first (i.e i386/alpha order)
+		     */
 #if defined(__i386__) || (defined(__LSBFIRST__) && defined(UNALIGNED_FETCH_OK))
-                    val = ((unsigned short *)byteP)[0];
+		    val = ((unsigned short *)byteP)[0];
 #else
 # if defined(__LSBFIRST__)
-                    /*
-                     * mhmh to be measured:
-                     *   the if may hurt more than the additional
-                     *   memory cycles on some machines ...
-                     */
-                    if (((INT)byteP & 1) == 0) {
-                        /* aligned */
-                        val = ((unsigned short *)byteP)[0];
-                    } else
+		    /*
+		     * mhmh to be measured:
+		     *   the if may hurt more than the additional
+		     *   memory cycles on some machines ...
+		     */
+		    if (((INT)byteP & 1) == 0) {
+			/* aligned */
+			val = ((unsigned short *)byteP)[0];
+		    } else
 # endif
-                    {
-                        val = byteP[1];
-                        val = (val << 8) + byteP[0];
-                    }
+		    {
+			val = byteP[1];
+			val = (val << 8) + byteP[0];
+		    }
 #endif
-                }
-                RETURN ( __mkSmallInteger(val) );
-            }
-        }
+		}
+		RETURN ( __mkSmallInteger(val) );
+	    }
+	}
     }
 %}.
     ^ super wordAt:index MSB:msb
@@ -780,41 +780,41 @@
     int nIndex;
     int v;
     union {
-        unsigned char u_char[2];
-        unsigned short u_ushort;
+	unsigned char u_char[2];
+	unsigned short u_ushort;
     } val;
     unsigned char *byteP;
 
     if (__bothSmallInteger(index, value)) {
-        indx = __intVal(index);
-        if (indx > 0) {
-            if (!__isByteArrayLike(self))
-                indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(self))->c_ninstvars));
-            nIndex = __byteArraySize(self);
-            if ((indx+1) <= nIndex) {
-                val.u_ushort = v = __intVal(value);
-                if ((v & ~0xFFFF) == 0 /* i.e. (val >= 0) && (val <= 0xFFFF) */) {
-                    byteP = (unsigned char *)(__ByteArrayInstPtr(self)->ba_element) + indx - 1;
+	indx = __intVal(index);
+	if (indx > 0) {
+	    if (!__isByteArrayLike(self))
+		indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(self))->c_ninstvars));
+	    nIndex = __byteArraySize(self);
+	    if ((indx+1) <= nIndex) {
+		val.u_ushort = v = __intVal(value);
+		if ((v & ~0xFFFF) == 0 /* i.e. (val >= 0) && (val <= 0xFFFF) */) {
+		    byteP = (unsigned char *)(__ByteArrayInstPtr(self)->ba_element) + indx - 1;
 #if defined(__i386__) || defined(UNALIGNED_FETCH_OK)
-                    ((unsigned short *)byteP)[0] = val.u_ushort;
+		    ((unsigned short *)byteP)[0] = val.u_ushort;
 #else
-                    /*
-                     * mhmh to be measured:
-                     *   the if may hurt more than the additional
-                     *   memory cycles on some machines ...
-                     */
-                    if (((INT)byteP & 1) == 0) {
-                        /* aligned */
-                        ((unsigned short *)byteP)[0] = val.u_ushort;
-                    } else {
-                        byteP[0] = val.u_char[0];
-                        byteP[1] = val.u_char[1];
-                    }
+		    /*
+		     * mhmh to be measured:
+		     *   the if may hurt more than the additional
+		     *   memory cycles on some machines ...
+		     */
+		    if (((INT)byteP & 1) == 0) {
+			/* aligned */
+			((unsigned short *)byteP)[0] = val.u_ushort;
+		    } else {
+			byteP[0] = val.u_char[0];
+			byteP[1] = val.u_char[1];
+		    }
 #endif
-                    RETURN ( value );
-                }
-            }
-        }
+		    RETURN ( value );
+		}
+	    }
+	}
     }
 %}.
     ^ super wordAt:index put:value
@@ -844,62 +844,62 @@
     unsigned char *byteP;
 
     if (__bothSmallInteger(index, value)) {
-        indx = __intVal(index);
-        if (indx > 0) {
-            if (!__isByteArrayLike(self))
-                indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(self))->c_ninstvars));
-            nIndex = __byteArraySize(self);
-            if ((indx+1) <= nIndex) {
-                val = __intVal(value);
-                if ((val & ~0xFFFF) == 0 /* i.e. (val >= 0) && (val <= 0xFFFF) */) {
-                    byteP = (unsigned char *)(__ByteArrayInstPtr(self)->ba_element) + indx - 1;
-                    if (msb == true) {
-                        /*
-                         * most significant byte first (i.e sparc order)
-                         */
+	indx = __intVal(index);
+	if (indx > 0) {
+	    if (!__isByteArrayLike(self))
+		indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(self))->c_ninstvars));
+	    nIndex = __byteArraySize(self);
+	    if ((indx+1) <= nIndex) {
+		val = __intVal(value);
+		if ((val & ~0xFFFF) == 0 /* i.e. (val >= 0) && (val <= 0xFFFF) */) {
+		    byteP = (unsigned char *)(__ByteArrayInstPtr(self)->ba_element) + indx - 1;
+		    if (msb == true) {
+			/*
+			 * most significant byte first (i.e sparc order)
+			 */
 #if defined(__MSBFIRST__)
-                        /*
-                         * mhmh to be measured:
-                         *   the if may hurt more than the additional
-                         *   memory cycles on some machines ...
-                         */
-                        if (((INT)byteP & 1) == 0) {
-                            /* aligned */
-                            ((unsigned short *)byteP)[0] = val;
-                        } else
+			/*
+			 * mhmh to be measured:
+			 *   the if may hurt more than the additional
+			 *   memory cycles on some machines ...
+			 */
+			if (((INT)byteP & 1) == 0) {
+			    /* aligned */
+			    ((unsigned short *)byteP)[0] = val;
+			} else
 #endif
-                        {
-                            byteP[1] = val & 0xFF;
-                            byteP[0] = (val>>8) & 0xFF;
-                        }
-                    } else {
-                        /*
-                         * least significant byte first (i.e i386/alpha order)
-                         */
+			{
+			    byteP[1] = val & 0xFF;
+			    byteP[0] = (val>>8) & 0xFF;
+			}
+		    } else {
+			/*
+			 * least significant byte first (i.e i386/alpha order)
+			 */
 #if defined(__i386__) || (defined(__LSBFIRST__) && defined(UNALIGNED_FETCH_OK))
-                        ((unsigned short *)byteP)[0] = val;
+			((unsigned short *)byteP)[0] = val;
 #else
 # if defined(__LSBFIRST__)
-                        /*
-                         * mhmh to be measured:
-                         *   the if may hurt more than the additional
-                         *   memory cycles on some machines ...
-                         */
-                        if (((INT)byteP & 1) == 0) {
-                            /* aligned */
-                            ((unsigned short *)byteP)[0] = val;
-                        } else
+			/*
+			 * mhmh to be measured:
+			 *   the if may hurt more than the additional
+			 *   memory cycles on some machines ...
+			 */
+			if (((INT)byteP & 1) == 0) {
+			    /* aligned */
+			    ((unsigned short *)byteP)[0] = val;
+			} else
 # endif
-                        {
-                            byteP[0] = val & 0xFF;
-                            byteP[1] = (val>>8) & 0xFF;
-                        }
+			{
+			    byteP[0] = val & 0xFF;
+			    byteP[1] = (val>>8) & 0xFF;
+			}
 #endif
-                    }
-                    RETURN ( value );
-                }
-            }
-        }
+		    }
+		    RETURN ( value );
+		}
+	    }
+	}
     }
 %}.
     ^ super wordAt:index put:value MSB:msb
@@ -933,76 +933,76 @@
     INT addrDelta;
 
     if (s == self) {
-        RETURN ( true );
+	RETURN ( true );
     }
     if (! __isNonNilObject(s)) {
-        RETURN ( false );
+	RETURN ( false );
     }
 
     cls = __qClass(s);
     myCls = __qClass(self);
 
     if (cls == myCls) {
-        l2 = __byteArraySize(s);
-        l1 = __byteArraySize(self);
-        if (l1 != l2) {
-            RETURN ( false );
-        }
-
-        cp1 = __stringVal(self);
-        cp2 = __stringVal(s);
-
-        /*
-         * care for instances of subclasses ...
-         */
-        if (cls != ByteArray) {
-            int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
-
-            cp2 += n;
-            cp1 += n;
-            l1 -= n;
-        }
-
-        addrDelta = cp2 - cp1;
-        while (l1 >= (sizeof(unsigned INT) * 4)) {
-            if (((unsigned INT *)cp1)[0] != ((unsigned INT *)(cp1+addrDelta))[0]) {
-                RETURN (false);
-            }
-            if (((unsigned INT *)cp1)[1] != ((unsigned INT *)(cp1+addrDelta))[1]) {
-                RETURN (false);
-            }
-            if (((unsigned INT *)cp1)[2] != ((unsigned INT *)(cp1+addrDelta))[2]) {
-                RETURN (false);
-            }
-            if (((unsigned INT *)cp1)[3] != ((unsigned INT *)(cp1+addrDelta))[3]) {
-                RETURN (false);
-            }
-            l1 -= sizeof(unsigned INT)*4;
-            cp1 += sizeof(unsigned INT)*4;
-        }
-        while (l1 >= sizeof(unsigned INT)) {
-            if (*((unsigned INT *)cp1) != *((unsigned INT *)(cp1+addrDelta))) {
-                RETURN (false);
-            }
-            l1 -= sizeof(unsigned INT);
-            cp1 += sizeof(unsigned INT);
-        }
-        if (l1 >= sizeof(unsigned short)) {
-            if (*((unsigned short *)cp1) != *((unsigned short *)(cp1+addrDelta))) {
-                RETURN (false);
-            }
-            l1 -= sizeof(unsigned short);
-            cp1 += sizeof(unsigned short);
-        }
-        while (l1) {
-            if (*cp1 != *(cp1+addrDelta)) {
-                RETURN (false);
-            }
-            l1--;
-            cp1++;
-        }
-
-        RETURN (true);
+	l2 = __byteArraySize(s);
+	l1 = __byteArraySize(self);
+	if (l1 != l2) {
+	    RETURN ( false );
+	}
+
+	cp1 = __byteArrayVal(self);
+	cp2 = __byteArrayVal(s);
+
+	/*
+	 * care for instances of subclasses ...
+	 */
+	if (cls != ByteArray) {
+	    int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+
+	    cp2 += n;
+	    cp1 += n;
+	    l1 -= n;
+	}
+
+	addrDelta = cp2 - cp1;
+	while (l1 >= (sizeof(unsigned INT) * 4)) {
+	    if (((unsigned INT *)cp1)[0] != ((unsigned INT *)(cp1+addrDelta))[0]) {
+		RETURN (false);
+	    }
+	    if (((unsigned INT *)cp1)[1] != ((unsigned INT *)(cp1+addrDelta))[1]) {
+		RETURN (false);
+	    }
+	    if (((unsigned INT *)cp1)[2] != ((unsigned INT *)(cp1+addrDelta))[2]) {
+		RETURN (false);
+	    }
+	    if (((unsigned INT *)cp1)[3] != ((unsigned INT *)(cp1+addrDelta))[3]) {
+		RETURN (false);
+	    }
+	    l1 -= sizeof(unsigned INT)*4;
+	    cp1 += sizeof(unsigned INT)*4;
+	}
+	while (l1 >= sizeof(unsigned INT)) {
+	    if (*((unsigned INT *)cp1) != *((unsigned INT *)(cp1+addrDelta))) {
+		RETURN (false);
+	    }
+	    l1 -= sizeof(unsigned INT);
+	    cp1 += sizeof(unsigned INT);
+	}
+	if (l1 >= sizeof(unsigned short)) {
+	    if (*((unsigned short *)cp1) != *((unsigned short *)(cp1+addrDelta))) {
+		RETURN (false);
+	    }
+	    l1 -= sizeof(unsigned short);
+	    cp1 += sizeof(unsigned short);
+	}
+	while (l1) {
+	    if (*cp1 != *(cp1+addrDelta)) {
+		RETURN (false);
+	    }
+	    l1--;
+	    cp1++;
+	}
+
+	RETURN (true);
     }
 %}.
     ^ super = aByteArray
@@ -1040,9 +1040,9 @@
     ^ (LargeInteger digitBytes:self MSB:true) normalize
 
     "
-        #[ 2 ] asInteger hexPrintString
-        #[ 16r1 16r2 ] asInteger hexPrintString
-        #[4 0 0 0 0 0 0 0] asInteger hexPrintString
+	#[ 2 ] asInteger hexPrintString
+	#[ 16r1 16r2 ] asInteger hexPrintString
+	#[4 0 0 0 0 0 0 0] asInteger hexPrintString
     "
 !
 
@@ -1053,10 +1053,10 @@
     ^ (LargeInteger digitBytes:self MSB:isMSBFirst) normalize
 
     "
-        (#[ 2 ] asIntegerMSB:true) hexPrintString
-        (#[ 16r1 16r2 ] asIntegerMSB:true) hexPrintString
-        (#[ 16r1 16r2 ] asIntegerMSB:false) hexPrintString
-        (#[4 0 0 0 0 0 0 0] asIntegerMSB:true) hexPrintString
+	(#[ 2 ] asIntegerMSB:true) hexPrintString
+	(#[ 16r1 16r2 ] asIntegerMSB:true) hexPrintString
+	(#[ 16r1 16r2 ] asIntegerMSB:false) hexPrintString
+	(#[4 0 0 0 0 0 0 0] asIntegerMSB:true) hexPrintString
     "
 !
 
@@ -1084,44 +1084,44 @@
     stop := self size.
 
     stop > 100 ifTrue:[
-        "/ cg:
-        "/ initial lineBreak
-        outStream cr.
+	"/ cg:
+	"/ initial lineBreak
+	outStream cr.
     ].
     cpl := 0.
 
     [index <= stop] whileTrue:[
-        "take 3 source bytes"
-        n := (self at:index) bitShift:16.
-        (index < stop) ifTrue:[
-            nextIndex := index + 1.
-            n := n bitOr:((self at:nextIndex) bitShift:8).
-            (nextIndex < stop) ifTrue:[
-                n := n bitOr:(self at:(index + 2)).
-            ].
-        ].
-        index := index + 3.
-
-        "took me a while to find that one out ..."
-        n := n bitXor:16r820820.
-
-        outStream nextPut:(Character value:((n bitShift:-18) bitAnd:16r3F) + 32).
-        outStream nextPut:(Character value:((n bitShift:-12) bitAnd:16r3F) + 32).
-        outStream nextPut:(Character value:((n bitShift:-6) bitAnd:16r3F) + 32).
-        outStream nextPut:(Character value:(n bitAnd:16r3F) + 32).
-
-        "/ cg:
-        "/ lineBreak after every 120 characters
-        "/ fromPackedString will ignore those
-        cpl := cpl + 4.
-        cpl >= 120 ifTrue:[
-            outStream cr.
-            cpl := 0.
-        ].
+	"take 3 source bytes"
+	n := (self at:index) bitShift:16.
+	(index < stop) ifTrue:[
+	    nextIndex := index + 1.
+	    n := n bitOr:((self at:nextIndex) bitShift:8).
+	    (nextIndex < stop) ifTrue:[
+		n := n bitOr:(self at:(index + 2)).
+	    ].
+	].
+	index := index + 3.
+
+	"took me a while to find that one out ..."
+	n := n bitXor:16r820820.
+
+	outStream nextPut:(Character value:((n bitShift:-18) bitAnd:16r3F) + 32).
+	outStream nextPut:(Character value:((n bitShift:-12) bitAnd:16r3F) + 32).
+	outStream nextPut:(Character value:((n bitShift:-6) bitAnd:16r3F) + 32).
+	outStream nextPut:(Character value:(n bitAnd:16r3F) + 32).
+
+	"/ cg:
+	"/ lineBreak after every 120 characters
+	"/ fromPackedString will ignore those
+	cpl := cpl + 4.
+	cpl >= 120 ifTrue:[
+	    outStream cr.
+	    cpl := 0.
+	].
     ].
     (mod := stop \\ 3) ~~ 0 ifTrue:[
-        outStream backStep.
-        outStream nextPut:(Character value:(mod + 96)).
+	outStream backStep.
+	outStream nextPut:(Character value:(mod + 96)).
     ].
     ^ outStream contents
 
@@ -1160,7 +1160,7 @@
     |cls|
 
     ((cls := self class) == ByteArray or:[cls == ImmutableByteArray]) ifTrue:[
-        ^ self
+	^ self
     ].
     ^ super literalArrayEncoding
 
@@ -1195,79 +1195,79 @@
 
     if (__isByteArrayLike(self)
      && __bothSmallInteger(start, stop)) {
-        len = __byteArraySize(self);
-        index1 = __intVal(start);
-        index2 = __intVal(stop);
-
-        if ((index1 <= index2) && (index1 > 0)) {
-            if (index2 <= len) {
-                count = index2 - index1 + 1;
-                __PROTECT_CONTEXT__
-                sz = OHDR_SIZE + count;
-                __qNew(newByteArray, sz);       /* OBJECT ALLOCATION */
-                __UNPROTECT_CONTEXT__
-                if (newByteArray != nil) {
-                    __InstPtr(newByteArray)->o_class = ByteArray;
-                    __qSTORE(newByteArray, ByteArray);
-                    dstp = __ByteArrayInstPtr(newByteArray)->ba_element;
-                    srcp = __ByteArrayInstPtr(self)->ba_element + index1 - 1;
+	len = __byteArraySize(self);
+	index1 = __intVal(start);
+	index2 = __intVal(stop);
+
+	if ((index1 <= index2) && (index1 > 0)) {
+	    if (index2 <= len) {
+		count = index2 - index1 + 1;
+		__PROTECT_CONTEXT__
+		sz = OHDR_SIZE + count;
+		__qNew(newByteArray, sz);       /* OBJECT ALLOCATION */
+		__UNPROTECT_CONTEXT__
+		if (newByteArray != nil) {
+		    __InstPtr(newByteArray)->o_class = ByteArray;
+		    __qSTORE(newByteArray, ByteArray);
+		    dstp = __ByteArrayInstPtr(newByteArray)->ba_element;
+		    srcp = __ByteArrayInstPtr(self)->ba_element + index1 - 1;
 
 #ifdef bcopy4
-                    if (((unsigned INT)srcp & 3) == ((unsigned INT)dstp & 3)) {
-                        int nW;
-
-                        /* copy unaligned part */
-                        while (count && (((unsigned INT)srcp & 3) != 0)) {
-                            *dstp++ = *srcp++;
-                            count--;
-                        }
-                        if (count) {
-                            /* copy aligned part */
-                            nW = count >> 2;
-                            if (count & 3) {
-                                nW++;
-                            }
-                            bcopy4(srcp, dstp, nW);
-                        }
-                        RETURN ( newByteArray );
-                    }
+		    if (((unsigned INT)srcp & 3) == ((unsigned INT)dstp & 3)) {
+			int nW;
+
+			/* copy unaligned part */
+			while (count && (((unsigned INT)srcp & 3) != 0)) {
+			    *dstp++ = *srcp++;
+			    count--;
+			}
+			if (count) {
+			    /* copy aligned part */
+			    nW = count >> 2;
+			    if (count & 3) {
+				nW++;
+			    }
+			    bcopy4(srcp, dstp, nW);
+			}
+			RETURN ( newByteArray );
+		    }
 #endif /* bcopy4 */
 #if __POINTER_SIZE__ == 8
-                    if (((unsigned INT)srcp & 7) == ((unsigned INT)dstp & 7)) {
-                        int nW;
-
-                        /* copy unaligned part */
-                        while (count && (((unsigned INT)srcp & 7) != 0)) {
-                            *dstp++ = *srcp++;
-                            count--;
-                        }
-                        /* copy aligned part */
-                        while (count >= 8) {
-                            ((unsigned INT *)dstp)[0] = ((unsigned INT *)srcp)[0];
-                            dstp += 8;
-                            srcp += 8;
-                            count -= 8;
-                        }
-                        /* copy remaining part */
-                        while (count) {
-                            *dstp++ = *srcp++;
-                            count--;
-                        }
-                        RETURN ( newByteArray );
-                    }
+		    if (((unsigned INT)srcp & 7) == ((unsigned INT)dstp & 7)) {
+			int nW;
+
+			/* copy unaligned part */
+			while (count && (((unsigned INT)srcp & 7) != 0)) {
+			    *dstp++ = *srcp++;
+			    count--;
+			}
+			/* copy aligned part */
+			while (count >= 8) {
+			    ((unsigned INT *)dstp)[0] = ((unsigned INT *)srcp)[0];
+			    dstp += 8;
+			    srcp += 8;
+			    count -= 8;
+			}
+			/* copy remaining part */
+			while (count) {
+			    *dstp++ = *srcp++;
+			    count--;
+			}
+			RETURN ( newByteArray );
+		    }
 #endif /* bcopy4 */
 
 #ifdef FAST_MEMCPY
-                    bcopy(srcp, dstp, count);
+		    bcopy(srcp, dstp, count);
 #else
-                    while (count--) {
-                        *dstp++ = *srcp++;
-                    }
+		    while (count--) {
+			*dstp++ = *srcp++;
+		    }
 #endif
-                    RETURN ( newByteArray );
-                }
-            }
-        }
+		    RETURN ( newByteArray );
+		}
+	    }
+	}
     }
 %}.
     "
@@ -1311,33 +1311,33 @@
     unsigned char scratchBuffer[1024], savec;
 
     if (__isByteArrayLike(self) && __bothSmallInteger(start, stop)) {
-        len = __byteArraySize(self);
-        index1 = __intVal(start);
-        index2 = __intVal(stop);
-
-        if ((index1 <= index2) && (index1 > 0) && (index2 <= len)) {
-            count = index2 - index1 + 1;
-            srcp = __ByteArrayInstPtr(self)->ba_element + index1 - 1;
-            if (index2 < len) {
-                /* temporarily stuff in a '\0' */
-                endp = srcp + count + 1;
-                savec = *endp;
-                *endp = '\0';
-                sym = __MKSYMBOL(srcp, 0);
-                /* must refetch endp (in case of a GC */
-                endp = __ByteArrayInstPtr(self)->ba_element + index1 + count;
-                *endp = savec;
-            } else {
-                /* not enough space for '\0', copy the bytes */
-                if (count < sizeof(scratchBuffer)) {
-                    bcopy(srcp, scratchBuffer, count);
-                    scratchBuffer[count] = '\0';
-                    sym = __MKSYMBOL(scratchBuffer, 0);
-                }
-            }
-        }
-        if (sym != nil)
-            RETURN(sym);
+	len = __byteArraySize(self);
+	index1 = __intVal(start);
+	index2 = __intVal(stop);
+
+	if ((index1 <= index2) && (index1 > 0) && (index2 <= len)) {
+	    count = index2 - index1 + 1;
+	    srcp = __ByteArrayInstPtr(self)->ba_element + index1 - 1;
+	    if (index2 < len) {
+		/* temporarily stuff in a '\0' */
+		endp = srcp + count + 1;
+		savec = *endp;
+		*endp = '\0';
+		sym = __MKSYMBOL(srcp, 0);
+		/* must refetch endp (in case of a GC */
+		endp = __ByteArrayInstPtr(self)->ba_element + index1 + count;
+		*endp = savec;
+	    } else {
+		/* not enough space for '\0', copy the bytes */
+		if (count < sizeof(scratchBuffer)) {
+		    bcopy(srcp, scratchBuffer, count);
+		    scratchBuffer[count] = '\0';
+		    sym = __MKSYMBOL(scratchBuffer, 0);
+		}
+	    }
+	}
+	if (sym != nil)
+	    RETURN(sym);
     }
 %}.
     "
@@ -1518,12 +1518,12 @@
      of some logical operation, as specified by the ruleSymbol.
      SourceBytes are fetched starting at sourceOffset.
      Valid rule symbols are:
-        #copy    - trivial;  same as replaceBytesFrom:to:with:startingAt:
-        #bitXor: - xoring;   byte[dI] = byte[dI] bitXor:(srcByte[sI])
-        #bitAnd: - anding;   byte[dI] = byte[dI] bitAnd:(srcByte[sI])
-        #bitOr:  - oring;    byte[dI] = byte[dI] bitOr:(srcByte[sI])
-        #+       - adding;   byte[dI] = (byte[dI] + (srcByte[sI])) mod: 256
-        #-       - subtract; byte[dI] = (byte[dI] - (srcByte[sI])) mod: 256
+	#copy    - trivial;  same as replaceBytesFrom:to:with:startingAt:
+	#bitXor: - xoring;   byte[dI] = byte[dI] bitXor:(srcByte[sI])
+	#bitAnd: - anding;   byte[dI] = byte[dI] bitAnd:(srcByte[sI])
+	#bitOr:  - oring;    byte[dI] = byte[dI] bitOr:(srcByte[sI])
+	#+       - adding;   byte[dI] = (byte[dI] + (srcByte[sI])) mod: 256
+	#-       - subtract; byte[dI] = (byte[dI] - (srcByte[sI])) mod: 256
      Warning: this is a destructive operation - elements in the receiver are overwritten.
     "
 
@@ -1535,130 +1535,130 @@
      && __isSmallInteger(dstStart)
      && __isSmallInteger(dstEnd)
      && __isSmallInteger(sourceStart)) {
-        unsigned char *srcP = __ByteArrayInstPtr(sourceBytes)->ba_element;
-        unsigned char *dstP = __ByteArrayInstPtr(self)->ba_element;
-        int srcLen = __byteArraySize(sourceBytes);
-        int dstLen = __byteArraySize(self);
-        int __srcStart = __intVal(sourceStart);
-        int __dstStart = __intVal(dstStart);
-        int count = __intVal(dstEnd) - __dstStart + 1;
-
-        if ((__dstStart >= 1)
-         && (__srcStart >= 1)
-         && ((__dstStart + count - 1) <= dstLen)
-         && ((__srcStart + count - 1) <= srcLen)) {
-            srcP += __srcStart - 1;
-            dstP += __dstStart - 1;
+	unsigned char *srcP = __ByteArrayInstPtr(sourceBytes)->ba_element;
+	unsigned char *dstP = __ByteArrayInstPtr(self)->ba_element;
+	int srcLen = __byteArraySize(sourceBytes);
+	int dstLen = __byteArraySize(self);
+	int __srcStart = __intVal(sourceStart);
+	int __dstStart = __intVal(dstStart);
+	int count = __intVal(dstEnd) - __dstStart + 1;
+
+	if ((__dstStart >= 1)
+	 && (__srcStart >= 1)
+	 && ((__dstStart + count - 1) <= dstLen)
+	 && ((__srcStart + count - 1) <= srcLen)) {
+	    srcP += __srcStart - 1;
+	    dstP += __dstStart - 1;
 
 #define OP_LOOP_BYTES(OP) \
     while (count > 0) {                                              \
-        *dstP OP (*srcP);                                            \
-        srcP++;                                                      \
-        dstP++;                                                      \
-        count--;                                                     \
+	*dstP OP (*srcP);                                            \
+	srcP++;                                                      \
+	dstP++;                                                      \
+	count--;                                                     \
     }
 
 #define OP_LOOP(OP) \
     while (count >= 16) {                                            \
-        ((unsigned int *)dstP)[0] OP (((unsigned int *)srcP)[0]);    \
-        ((unsigned int *)dstP)[1] OP (((unsigned int *)srcP)[1]);    \
-        ((unsigned int *)dstP)[2] OP (((unsigned int *)srcP)[2]);    \
-        ((unsigned int *)dstP)[3] OP (((unsigned int *)srcP)[3]);    \
-        srcP += 16;                                                  \
-        dstP += 16;                                                  \
-        count -= 16;                                                 \
+	((unsigned int *)dstP)[0] OP (((unsigned int *)srcP)[0]);    \
+	((unsigned int *)dstP)[1] OP (((unsigned int *)srcP)[1]);    \
+	((unsigned int *)dstP)[2] OP (((unsigned int *)srcP)[2]);    \
+	((unsigned int *)dstP)[3] OP (((unsigned int *)srcP)[3]);    \
+	srcP += 16;                                                  \
+	dstP += 16;                                                  \
+	count -= 16;                                                 \
     }                                                                \
     while (count >= 4) {                                             \
-        ((unsigned int *)dstP)[0] OP (((unsigned int *)srcP)[0]);    \
-        srcP += 4;                                                   \
-        dstP += 4;                                                   \
-        count -= 4;                                                  \
+	((unsigned int *)dstP)[0] OP (((unsigned int *)srcP)[0]);    \
+	srcP += 4;                                                   \
+	dstP += 4;                                                   \
+	count -= 4;                                                  \
     }                                                                \
     while (count > 0) {                                              \
-        *dstP OP (*srcP);                                            \
-        srcP++;                                                      \
-        dstP++;                                                      \
-        count--;                                                     \
+	*dstP OP (*srcP);                                            \
+	srcP++;                                                      \
+	dstP++;                                                      \
+	count--;                                                     \
     }
 
 
-            if (ruleSymbol == @symbol(bitXor:)) {
-                OP_LOOP( ^= )
-                RETURN (self);
-            }
-            if (ruleSymbol == @symbol(bitXorNot:)) {
-                OP_LOOP( ^=~ )
-                RETURN (self);
-            }
-            if (ruleSymbol == @symbol(bitAnd:)) {
-                OP_LOOP( &= )
-                RETURN (self);
-            }
-            if (ruleSymbol == @symbol(bitAndNot:)) {
-                OP_LOOP( &=~ )
-                RETURN (self);
-            }
-            if (ruleSymbol == @symbol(bitOr:)) {
-                OP_LOOP( |= )
-                RETURN (self);
-            }
-            if (ruleSymbol == @symbol(bitOrNot:)) {
-                OP_LOOP( |=~ )
-                RETURN (self);
-            }
-            if (ruleSymbol == @symbol(copy)) {
-                OP_LOOP( = )
-                RETURN (self);
-            }
-            if (ruleSymbol == @symbol(copyNot)) {
-                OP_LOOP( =~ )
-                RETURN (self);
-            }
-            if (ruleSymbol == @symbol(+)) {
-                OP_LOOP_BYTES( += )
-                RETURN (self);
-            }
-            if (ruleSymbol == @symbol(-)) {
-                OP_LOOP_BYTES( -= )
-                RETURN (self);
-            }
-        }
+	    if (ruleSymbol == @symbol(bitXor:)) {
+		OP_LOOP( ^= )
+		RETURN (self);
+	    }
+	    if (ruleSymbol == @symbol(bitXorNot:)) {
+		OP_LOOP( ^=~ )
+		RETURN (self);
+	    }
+	    if (ruleSymbol == @symbol(bitAnd:)) {
+		OP_LOOP( &= )
+		RETURN (self);
+	    }
+	    if (ruleSymbol == @symbol(bitAndNot:)) {
+		OP_LOOP( &=~ )
+		RETURN (self);
+	    }
+	    if (ruleSymbol == @symbol(bitOr:)) {
+		OP_LOOP( |= )
+		RETURN (self);
+	    }
+	    if (ruleSymbol == @symbol(bitOrNot:)) {
+		OP_LOOP( |=~ )
+		RETURN (self);
+	    }
+	    if (ruleSymbol == @symbol(copy)) {
+		OP_LOOP( = )
+		RETURN (self);
+	    }
+	    if (ruleSymbol == @symbol(copyNot)) {
+		OP_LOOP( =~ )
+		RETURN (self);
+	    }
+	    if (ruleSymbol == @symbol(+)) {
+		OP_LOOP_BYTES( += )
+		RETURN (self);
+	    }
+	    if (ruleSymbol == @symbol(-)) {
+		OP_LOOP_BYTES( -= )
+		RETURN (self);
+	    }
+	}
     }
 #undef OP_LOOP_BYTES
 #undef OP_LOOP
 
 %}.
     ruleSymbol == #copy ifTrue:[
-        self replaceFrom:dstStart to:dstEnd with:sourceBytes startingAt:sourceStart.
-        ^ self
+	self replaceFrom:dstStart to:dstEnd with:sourceBytes startingAt:sourceStart.
+	^ self
     ].
 
     srcIdx := sourceStart.
     dstStart to:dstEnd do:[:dstIdx |
-        self at:dstIdx put:((self at:dstIdx) perform:ruleSymbol with:(sourceBytes at:srcIdx)).
-        srcIdx := srcIdx + 1.
+	self at:dstIdx put:((self at:dstIdx) perform:ruleSymbol with:(sourceBytes at:srcIdx)).
+	srcIdx := srcIdx + 1.
     ].
 
     "
      #[1 2 3 4 5 6 7 8]
-        bitBlitBytesFrom:1 to:3 with:#[1 2 3 4 5 6 7 8] startingAt:1 rule:#bitXor:
+	bitBlitBytesFrom:1 to:3 with:#[1 2 3 4 5 6 7 8] startingAt:1 rule:#bitXor:
      #[1 2 3 4 5 6 7 8]
-        bitBlitBytesFrom:1 to:8 with:#[1 2 3 4 5 6 7 8] startingAt:1 rule:#bitXor:
+	bitBlitBytesFrom:1 to:8 with:#[1 2 3 4 5 6 7 8] startingAt:1 rule:#bitXor:
      #[1 2 3 4 5 6 7 8]
-        bitBlitBytesFrom:1 to:8 with:#[1 1 1 1 1 1 1 1] startingAt:1 rule:#bitAnd:
+	bitBlitBytesFrom:1 to:8 with:#[1 1 1 1 1 1 1 1] startingAt:1 rule:#bitAnd:
      #[1 2 3 4 5 6 7 8]
-        bitBlitBytesFrom:1 to:8 with:#[1 2 3 4 5 6 7 8] startingAt:1 rule:#+
+	bitBlitBytesFrom:1 to:8 with:#[1 2 3 4 5 6 7 8] startingAt:1 rule:#+
      #[255 0 0 0 0 0 0 0]
-        bitBlitBytesFrom:1 to:8 with:#[1 2 3 4 5 6 7 8] startingAt:1 rule:#+
+	bitBlitBytesFrom:1 to:8 with:#[1 2 3 4 5 6 7 8] startingAt:1 rule:#+
      #[1 2 3 4 5 6 7 8]
-        bitBlitBytesFrom:1 to:4 with:#[1 1 1 1 1 1 1 1] startingAt:1 rule:#+
+	bitBlitBytesFrom:1 to:4 with:#[1 1 1 1 1 1 1 1] startingAt:1 rule:#+
      #[1 2 3 4 5 6 7 8]
-        bitBlitBytesFrom:1 to:4 with:#[1 1 1 1 2 2 2 2] startingAt:5 rule:#+
+	bitBlitBytesFrom:1 to:4 with:#[1 1 1 1 2 2 2 2] startingAt:5 rule:#+
      #[1 2 3 4 5 6 7 8]
-        bitBlitBytesFrom:1 to:4 with:#[1 1 1 1 2 2 2 2] startingAt:5 rule:#copyNot
+	bitBlitBytesFrom:1 to:4 with:#[1 1 1 1 2 2 2 2] startingAt:5 rule:#copyNot
 
      #[1 2 3 4 5 6 7 8]
-        bitBlitBytesFrom:1 to:8 with:(1 to:8) startingAt:1 rule:#+
+	bitBlitBytesFrom:1 to:8 with:(1 to:8) startingAt:1 rule:#+
     "
 !
 
@@ -2221,7 +2221,7 @@
 reverse
     "reverse the order of my elements inplace -
      WARNING: this is a destructive operation, which modifies the receiver.
-              Please use reversed (with a d) for a functional version.
+	      Please use reversed (with a d) for a functional version.
      Written as a primitive for speed on image manipulations (mirror)"
 
 %{  /* NOCONTEXT */
@@ -2232,98 +2232,98 @@
     OBJ cls;
 
     if (__qClass(self) == @global(ByteArray)) {
-        cnt = __byteArraySize(self);
-        p1 = __ByteArrayInstPtr(self)->ba_element;
-        p2 = p1 + cnt - 1;
+	cnt = __byteArraySize(self);
+	p1 = __ByteArrayInstPtr(self)->ba_element;
+	p2 = p1 + cnt - 1;
 
 #if defined(__BSWAP)
-        /*
-         * can we use the bswap instruction ?
-         * notice - not all CPUs have it (the HAS_BSWAP checks this).
-         */
-        if (__HAS_BSWAP()
-         && ((cnt & 3) == 0)) {
-            unsigned int *ip1, *ip2;
-
-            ip1 = (unsigned int *)p1;
-            ip2 = (unsigned int *)(p2 - 3);
-
-            ip2 -= 7;
-            while (ip1 <= ip2) {
-                int t1, t2;
-
-                t1 = ip1[0];
-                t2 = ip2[7];
-                ip2[7] = __BSWAP(t1);
-                ip1[0] = __BSWAP(t2);
-
-                t1 = ip1[1];
-                t2 = ip2[6];
-                ip2[6] = __BSWAP(t1);
-                ip1[1] = __BSWAP(t2);
-
-                t1 = ip1[2];
-                t2 = ip2[5];
-                ip2[5] = __BSWAP(t1);
-                ip1[2] = __BSWAP(t2);
-
-                t1 = ip1[3];
-                t2 = ip2[4];
-                ip2[4] = __BSWAP(t1);
-                ip1[3] = __BSWAP(t2);
-
-                ip1 += 4;
-                ip2 -= 4;
-            }
-            ip2 += 7;
-
-            while (ip1 < ip2) {
-                int t;
-
-                t = __BSWAP(*ip1);
-                *ip1++ = __BSWAP(*ip2);
-                *ip2-- = t;
-            }
-
-            if (ip1 == ip2) {
-                int t;
-                t = *ip1;
-                t = __BSWAP(t);
-                *ip1 = t;
-            }
-            RETURN ( self );
-        }
+	/*
+	 * can we use the bswap instruction ?
+	 * notice - not all CPUs have it (the HAS_BSWAP checks this).
+	 */
+	if (__HAS_BSWAP()
+	 && ((cnt & 3) == 0)) {
+	    unsigned int *ip1, *ip2;
+
+	    ip1 = (unsigned int *)p1;
+	    ip2 = (unsigned int *)(p2 - 3);
+
+	    ip2 -= 7;
+	    while (ip1 <= ip2) {
+		int t1, t2;
+
+		t1 = ip1[0];
+		t2 = ip2[7];
+		ip2[7] = __BSWAP(t1);
+		ip1[0] = __BSWAP(t2);
+
+		t1 = ip1[1];
+		t2 = ip2[6];
+		ip2[6] = __BSWAP(t1);
+		ip1[1] = __BSWAP(t2);
+
+		t1 = ip1[2];
+		t2 = ip2[5];
+		ip2[5] = __BSWAP(t1);
+		ip1[2] = __BSWAP(t2);
+
+		t1 = ip1[3];
+		t2 = ip2[4];
+		ip2[4] = __BSWAP(t1);
+		ip1[3] = __BSWAP(t2);
+
+		ip1 += 4;
+		ip2 -= 4;
+	    }
+	    ip2 += 7;
+
+	    while (ip1 < ip2) {
+		int t;
+
+		t = __BSWAP(*ip1);
+		*ip1++ = __BSWAP(*ip2);
+		*ip2-- = t;
+	    }
+
+	    if (ip1 == ip2) {
+		int t;
+		t = *ip1;
+		t = __BSWAP(t);
+		*ip1 = t;
+	    }
+	    RETURN ( self );
+	}
 #endif /* __i386__ && __GNUC__ */
 
-        p2 -= 7;
-        while (p1 <= p2) {
-            t = p1[0];
-            p1[0] = p2[7];
-            p2[7] = t;
-
-            t = p1[1];
-            p1[1] = p2[6];
-            p2[6] = t;
-
-            t = p1[2];
-            p1[2] = p2[5];
-            p2[5] = t;
-
-            t = p1[3];
-            p1[3] = p2[4];
-            p2[4] = t;
-
-            p1 += 4;
-            p2 -= 4;
-        }
-        p2 += 7;
-
-        while (p1 < p2) {
-            t = *p1;
-            *p1++ = *p2;
-            *p2-- = t;
-        }
-        RETURN ( self );
+	p2 -= 7;
+	while (p1 <= p2) {
+	    t = p1[0];
+	    p1[0] = p2[7];
+	    p2[7] = t;
+
+	    t = p1[1];
+	    p1[1] = p2[6];
+	    p2[6] = t;
+
+	    t = p1[2];
+	    p1[2] = p2[5];
+	    p2[5] = t;
+
+	    t = p1[3];
+	    p1[3] = p2[4];
+	    p2[4] = t;
+
+	    p1 += 4;
+	    p2 -= 4;
+	}
+	p2 += 7;
+
+	while (p1 < p2) {
+	    t = *p1;
+	    *p1++ = *p2;
+	    *p2-- = t;
+	}
+	RETURN ( self );
     }
 %}.
     ^ super reverse
@@ -2343,32 +2343,32 @@
      (1 to:255) asByteArray reverse
 
      1 to:1024 do:[:i|
-        |bytes test rBytes|
-
-        bytes := ((1 to:i) asArray collect:[:i | i bitAnd:255]) asByteArray.
-        test := ((i to:1 by:-1) asArray collect:[:i | i bitAnd:255]) asByteArray.
-        rBytes := bytes copy.
-        rBytes reverse ~= test ifTrue:[
-            self halt
-        ].
-        rBytes := bytes copy.
-        rBytes reverse reverse ~= bytes ifTrue:[
-            self halt
-        ]
+	|bytes test rBytes|
+
+	bytes := ((1 to:i) asArray collect:[:i | i bitAnd:255]) asByteArray.
+	test := ((i to:1 by:-1) asArray collect:[:i | i bitAnd:255]) asByteArray.
+	rBytes := bytes copy.
+	rBytes reverse ~= test ifTrue:[
+	    self halt
+	].
+	rBytes := bytes copy.
+	rBytes reverse reverse ~= bytes ifTrue:[
+	    self halt
+	]
      ].
 
      Time millisecondsToRun:[
-        10000000 timesRepeat:[
-            #[1 2 3 4 5 6 7 8] reverse
-        ]
+	10000000 timesRepeat:[
+	    #[1 2 3 4 5 6 7 8] reverse
+	]
      ]
 
      |b|
      b := (0 to:255) asByteArray.
      Time millisecondsToRun:[
-        10000000 timesRepeat:[
-            b reverse
-        ]
+	10000000 timesRepeat:[
+	    b reverse
+	]
      ]
     "
 !
@@ -2424,16 +2424,16 @@
     unsigned int t;
 
     if (__qClass(self) == @global(ByteArray) && __bothSmallInteger(i1, i2)) {
-        __i1 = __intVal(i1) - 1;
-        __i2 = __intVal(i2) - 1;
-        cnt = __byteArraySize(self);
-        p = __ByteArrayInstPtr(self)->ba_element;
-        if (__i1 < cnt && __i2 < cnt) {
-            t = p[__i1];
-            p[__i1] = p[__i2];
-            p[__i2] = t;
-        }
-        RETURN ( self );
+	__i1 = __intVal(i1) - 1;
+	__i2 = __intVal(i2) - 1;
+	cnt = __byteArraySize(self);
+	p = __ByteArrayInstPtr(self)->ba_element;
+	if (__i1 < cnt && __i2 < cnt) {
+	    t = p[__i1];
+	    p[__i1] = p[__i2];
+	    p[__i2] = t;
+	}
+	RETURN ( self );
     }
 %}.
     ^ super swapIndex:i1 and:i2 "/ rubbish - there is no one currently
@@ -2571,9 +2571,9 @@
     "print as hex string, eg: 'FF:02:43'"
 
     self do:[:byte|
-        byte printOn:aStream base:16 size:2 fill:$0.
+	byte printOn:aStream base:16 size:2 fill:$0.
     ] separatedBy:[
-        aSeparatorStringOrCharacter printOn:aStream
+	aSeparatorStringOrCharacter printOn:aStream
     ].
 
     "
@@ -2589,7 +2589,7 @@
 
     s := '' writeStream.
     self do:[:byte|
-        byte printOn:s base:16 size:2 fill:$0.
+	byte printOn:s base:16 size:2 fill:$0.
     ].
     ^ s contents.
 
@@ -2623,13 +2623,13 @@
     |cls|
 
     "/ care for subclasses
-    ((cls := self class) == ByteArray or:[cls == ImmutableByteArray]) ifTrue:[    
-        aStream nextPutAll:'#['.
-        self
-            do:[:byte | byte printOn:aStream]
-            separatedBy:[aStream space].
-        aStream nextPut:$].
-        ^ self
+    ((cls := self class) == ByteArray or:[cls == ImmutableByteArray]) ifTrue:[
+	aStream nextPutAll:'#['.
+	self
+	    do:[:byte | byte printOn:aStream]
+	    separatedBy:[aStream space].
+	aStream nextPut:$].
+	^ self
     ].
     ^ super printOn:aStream
 
@@ -2670,13 +2670,13 @@
     |cls|
 
     ((cls := self class) == ByteArray or:[cls == ImmutableByteArray]) ifTrue:[
-        "/ care for subclasses
-        aStream nextPutAll:'#['.
-        self
-            do:[:byte | byte printOn:aStream base:radix showRadix:showRadix]
-            separatedBy:[aStream space].
-        aStream nextPut:$].
-        ^ self
+	"/ care for subclasses
+	aStream nextPutAll:'#['.
+	self
+	    do:[:byte | byte printOn:aStream base:radix showRadix:showRadix]
+	    separatedBy:[aStream space].
+	aStream nextPut:$].
+	^ self
     ].
     ^ self printOn:aStream
 
@@ -2699,14 +2699,14 @@
 
     |cls|
 
-    ((cls := self class) == ByteArray or:[cls == ImmutableByteArray]) ifTrue:[    
-        "/ care for subclasses
-        aStream nextPut:$[.
-        self
-            do:[:byte | byte storeOn:aStream]
-            separatedBy:[aStream space].
-        aStream nextPut:$].
-        ^ self
+    ((cls := self class) == ByteArray or:[cls == ImmutableByteArray]) ifTrue:[
+	"/ care for subclasses
+	aStream nextPut:$[.
+	self
+	    do:[:byte | byte storeOn:aStream]
+	    separatedBy:[aStream space].
+	aStream nextPut:$].
+	^ self
     ].
     super storeArrayElementOn:aStream
 
@@ -2728,14 +2728,14 @@
 
     |cls|
 
-    ((cls := self class) == ByteArray or:[cls == ImmutableByteArray]) ifTrue:[    
-        "/ care for subclasses
-        aStream nextPutAll:'#['.
-        self
-            do:[:byte | byte storeOn:aStream]
-            separatedBy:[aStream space].
-        aStream nextPutAll:']'.
-        ^ self
+    ((cls := self class) == ByteArray or:[cls == ImmutableByteArray]) ifTrue:[
+	"/ care for subclasses
+	aStream nextPutAll:'#['.
+	self
+	    do:[:byte | byte storeOn:aStream]
+	    separatedBy:[aStream space].
+	aStream nextPutAll:']'.
+	^ self
     ].
     ^ super storeOn:aStream
 
@@ -2813,29 +2813,29 @@
     INT icounts[256];
 
     if (__isByteArrayLike(self) && __isArray(counts)) {
-        /*
-         * zero counts
-         */
-        for (index=0; index<256; index++) {
-            icounts[index] = 0;
-        }
-
-        /*
-         * count
-         */
-        nByte = __qSize(self) - OHDR_SIZE;
-        cp = &(__ByteArrayInstPtr(self)->ba_element[0]);
-        while (nByte--) {
-            icounts[*cp++]++;
-        }
-
-        /*
-         * make it real counts
-         */
-        for (index=0; index<256; index++) {
-            __ArrayInstPtr(counts)->a_element[index] = __mkSmallInteger(icounts[index]);
-        }
-        RETURN ( counts );
+	/*
+	 * zero counts
+	 */
+	for (index=0; index<256; index++) {
+	    icounts[index] = 0;
+	}
+
+	/*
+	 * count
+	 */
+	nByte = __qSize(self) - OHDR_SIZE;
+	cp = &(__ByteArrayInstPtr(self)->ba_element[0]);
+	while (nByte--) {
+	    icounts[*cp++]++;
+	}
+
+	/*
+	 * make it real counts
+	 */
+	for (index=0; index<256; index++) {
+	    __ArrayInstPtr(counts)->a_element[index] = __mkSmallInteger(icounts[index]);
+	}
+	RETURN ( counts );
     }
 %}
 .
@@ -2858,8 +2858,8 @@
     REGISTER int len;
     OBJ result;
     union {
-        unsigned char flags[256];
-        int toForceAlignmentOfFlags;
+	unsigned char flags[256];
+	int toForceAlignmentOfFlags;
     } f;
 
 #ifdef TO_BE_MEASURED
@@ -2867,53 +2867,53 @@
 #endif
 
     if (__isByteArrayLike(self)) {
-        memset(f.flags, 0, sizeof(f.flags));
-        len = __qSize(self) - OHDR_SIZE;
-        cp = &(__ByteArrayInstPtr(self)->ba_element[0]);
-
-        /* for each used byte, set flag */
-        while (len > 0) {
+	memset(f.flags, 0, sizeof(f.flags));
+	len = __qSize(self) - OHDR_SIZE;
+	cp = &(__ByteArrayInstPtr(self)->ba_element[0]);
+
+	/* for each used byte, set flag */
+	while (len > 0) {
 #ifdef TO_BE_MEASURED
-            unsigned  byte;
-
-            byte = *cp;
-            if (! f.flags[byte]) {
-                f.flags[byte] = 1;
-                coverage++;
-                if (coverage == 256) {
-                    /* no need to scan rest */
-                    break;
-                }
-            }
+	    unsigned  byte;
+
+	    byte = *cp;
+	    if (! f.flags[byte]) {
+		f.flags[byte] = 1;
+		coverage++;
+		if (coverage == 256) {
+		    /* no need to scan rest */
+		    break;
+		}
+	    }
 #else
-            f.flags[*cp] = 1;
+	    f.flags[*cp] = 1;
 #endif
-            cp++;
-            len--;
-        }
-
-        /* count 1's */
-        len = 0;
-        for (cp=f.flags, endp=f.flags+256; cp < endp;) {
-            if ( *((unsigned int *)cp)) {
-                if (cp[0]) len++;
-                if (cp[1]) len++;
-                if (cp[2]) len++;
-                if (cp[3]) len++;
-            }
-            cp += 4;
-        }
-
-        /* create ByteArray of used values */
-        result = __BYTEARRAY_UNINITIALIZED_NEW_INT(len);
-        if (result) {
-            cp = __ByteArrayInstPtr(result)->ba_element;
-            for (len=0; len < 256; len++) {
-                if (f.flags[len])
-                    *cp++ = len;
-            }
-            RETURN ( result );
-        }
+	    cp++;
+	    len--;
+	}
+
+	/* count 1's */
+	len = 0;
+	for (cp=f.flags, endp=f.flags+256; cp < endp;) {
+	    if ( *((unsigned int *)cp)) {
+		if (cp[0]) len++;
+		if (cp[1]) len++;
+		if (cp[2]) len++;
+		if (cp[3]) len++;
+	    }
+	    cp += 4;
+	}
+
+	/* create ByteArray of used values */
+	result = __BYTEARRAY_UNINITIALIZED_NEW_INT(len);
+	if (result) {
+	    cp = __ByteArrayInstPtr(result)->ba_element;
+	    for (len=0; len < 256; len++) {
+		if (f.flags[len])
+		    *cp++ = len;
+	    }
+	    RETURN ( result );
+	}
     }
 %}.
     ^ self asIdentitySet asByteArray
@@ -3005,13 +3005,14 @@
 !ByteArray class methodsFor:'documentation'!
 
 version
-    ^ '$Id: ByteArray.st 10517 2010-04-26 18:26:38Z vranyj1 $'
+    ^ '$Id: ByteArray.st 10520 2010-05-04 11:50:05Z vranyj1 $'
 !
 
 version_CVS
-    ^ '§Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.200 2010/03/08 07:42:51 stefan Exp §'
+    ^ 'Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.201 2010/04/14 08:33:59 cg Exp §'
 !
 
 version_SVN
-    ^ '$Id: ByteArray.st 10517 2010-04-26 18:26:38Z vranyj1 $'
+    ^ '$Id: ByteArray.st 10520 2010-05-04 11:50:05Z vranyj1 $'
 ! !
+