Merge jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sun, 18 Dec 2016 11:19:27 +0000
branchjv
changeset 21242 19fabe339f8b
parent 21092 6dc23c67620f (current diff)
parent 21143 89370f05de89 (diff)
child 21243 f0ac467b9ade
Merge
ArithmeticValue.st
Block.st
CharacterArray.st
CharacterEncoder.st
CharacterEncoderImplementations__SingleByteEncoder.st
CharacterEncoderImplementations__TwoByteEncoder.st
Collection.st
CompiledCode.st
Complex.st
Dictionary.st
ExternalStream.st
Lookup.st
NamespaceAwareLookup.st
NonPositionableExternalStream.st
Number.st
ObjectMemory.st
PCFilename.st
PeekableStream.st
PositionableStream.st
Process.st
ProcessorScheduler.st
ProjectDefinition.st
ProtoObject.st
ReadStream.st
ReadWriteStream.st
Semaphore.st
SmallInteger.st
Smalltalk.st
Stream.st
Symbol.st
UserPreferences.st
Win32OperatingSystem.st
WriteStream.st
--- a/.cvsignore	Tue Dec 06 07:06:38 2016 +0100
+++ b/.cvsignore	Sun Dec 18 11:19:27 2016 +0000
@@ -14,6 +14,7 @@
 *.S
 *.sc
 *.xc
+*.res
 .listOfSTfiles
 .dependencies
 *.exp
@@ -31,3 +32,7 @@
 objtcc
 objmingw
 *.@@@
+.DS_Store
+*.sav
+*.bad
+*.fixed
--- a/.hgtags	Tue Dec 06 07:06:38 2016 +0100
+++ b/.hgtags	Sun Dec 18 11:19:27 2016 +0000
@@ -18,7 +18,6 @@
 4306fb61b9f8004278974861ad3d1fb0cc9a9529 expecco_1_6_0rc5
 43bb5d8495e0048a1ba8f299b56d6411394dc6d1 expecco_1_7_0rc1
 484307b07a7b64f21b0a6dd83d5856556904a435 expecco_2_9_0
-484307b07a7b64f21b0a6dd83d5856556904a435 expecco_2_9_0_a
 484307b07a7b64f21b0a6dd83d5856556904a435 expecco_2_9_0_win75_lx36
 484307b07a7b64f21b0a6dd83d5856556904a435 expecco_2_9_1
 508e9e5d9254027c7f4aed4fe7734dab793e5230 expecco_ALM_1_9_7
@@ -61,6 +60,7 @@
 aa93e348e5d3c964977d1571451e24069a17f88a expecco_1_8_2rc1
 aebca3972774d3331f0bcedbaef81aec29ff2026 expecco_1_7_0rc5
 b2c6e6d23adc8a68c359806eefdda97535773e31 expeccoNET_1_4_0rc1
+b7b94965c192beb293580982917bdb29636385e4 expecco_2_10_0
 ba5f4421848f248753a0e2454ffee0c055040a45 rel5_2_2
 bf65bdad3827b0eb8d7763ffbaf5eb7bee41219d expecco_1_7_0b3
 c12795ed7ddc998f7f9ad0fa8ae47fc06a9f1aec rel4_1_7
--- a/ArithmeticValue.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/ArithmeticValue.st	Sun Dec 18 11:19:27 2016 +0000
@@ -776,13 +776,13 @@
 !
 
 degreesToRadians
-    "interpreting the receiver as radians, return the degrees"
+    "interpreting the receiver as degrees, return the radians"
 
     ^ self asFloat degreesToRadians
 !
 
 radiansToDegrees
-    "interpreting the receiver as degrees, return the radians"
+    "interpreting the receiver as radians, return the degrees"
 
     ^ self asFloat radiansToDegrees
 ! !
--- a/Block.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/Block.st	Sun Dec 18 11:19:27 2016 +0000
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
@@ -711,7 +709,6 @@
 ! !
 
 
-
 !Block methodsFor:'accessing'!
 
 home
@@ -762,7 +759,7 @@
 
 numArgs
     "return the number of arguments I expect for evaluation.
-     Please use argumentCount, which is ANSI"
+     Please use argumentCount for ANSI compatibility"
 
 "/    <resource: #obsolete>
 
@@ -906,7 +903,7 @@
     micros < 1000 ifTrue:[
         "/ too stupid: many fonts do not have a mu,
         "/ so I output it as us here.
-        Transcript show:micros; show:' µs'.
+        Transcript show:micros; show:' s'.
     ] ifFalse:[
         micros < 100000 ifTrue:[
             millis := (micros / 1000.0) asFixedPointRoundedToScale:2.
--- a/CharacterArray.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/CharacterArray.st	Sun Dec 18 11:19:27 2016 +0000
@@ -6590,7 +6590,7 @@
                         (argArrayOrDictionary includesKey:key) ifTrue:[
                             v := argArrayOrDictionary at:key
                         ] ifFalse:[
-                            key := key asSymbolIfInterned ? key.
+                            key := key asSymbolIfInternedOrSelf.
                             (argArrayOrDictionary includesKey:key) ifTrue:[
                                 v := argArrayOrDictionary at:key
                             ] ifFalse:[
@@ -6610,9 +6610,9 @@
                             v := argArrayOrDictionary
                                     at:next
                                     ifAbsent:[
-                                        "try symbol instead of character"
+                                        "try symbol or string instead of character"
                                         argArrayOrDictionary
-                                            at:next asSymbol
+                                            at:next asString asSymbolIfInternedOrSelf
                                             ifAbsent:[String with:escapeCharacter with:next].
                                  ].
                         ] ifFalse:[
@@ -8042,6 +8042,42 @@
     "
 !
 
+isInfix
+    "return true, if the receiver is a binary message selector"
+
+    ^ self first isLetterOrDigit not
+
+    "
+     #at:put: isInfix
+     #at: isInfix
+     #+ isInfix
+     #size isInfix
+    "
+
+    "Created: / 1.11.1997 / 12:34:55 / cg"
+    "Modified: / 1.11.1997 / 12:36:37 / cg"
+!
+
+isKeyword
+    "return true, if the receiver is a keyword message selector.
+     This is a quick check, which only looks at the last character.
+     Should only be used, if we already know that the receiver forms a valid selector.
+     To check an arbitrary string, use isKeywordSelector.
+     Bad naming, but compatibility is asking for it."
+
+    ^ self last == $:
+
+    "
+     #at:put: isKeyword
+     #at: isKeyword
+     #+ isKeyword
+     #size isKeyword
+    "
+
+    "Created: / 01-11-1997 / 12:34:55 / cg"
+    "Modified (comment): / 30-04-2016 / 18:19:11 / cg"
+!
+
 isKeywordSelector
     "return true, iff there are only alphanumeric or underline characters separated by colons.
      Must end with a colon.
@@ -8154,6 +8190,14 @@
     ^ true
 !
 
+isUnary
+    "Answer true if the receiver is a unary selector.
+     That is not a check for being a valid selector, but instead relies on
+     the selector being valid."
+
+    ^ self isUnarySelector
+!
+
 isUnarySelector
     "Answer true if the receiver contains only chars in an ANSI unary method selector, false otherwise."
 
@@ -8223,7 +8267,8 @@
 
 numArgs
     <resource: #obsolete>
-    "treating the receiver as a message selector, return how many arguments would it take"
+    "treating the receiver as a message selector, return how many arguments would it take.
+     Please use argumentCount for ANSI compatibility."
 
     ^ self argumentCount
 !
--- a/CharacterEncoder.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/CharacterEncoder.st	Sun Dec 18 11:19:27 2016 +0000
@@ -1666,6 +1666,8 @@
 !CharacterEncoder::InverseEncoder methodsFor:'queries'!
 
 characterSize:charOrcodePoint
+    "return the number of bytes required to encode codePoint"
+
     ^ decoder characterSize:charOrcodePoint
 ! !
 
@@ -1780,6 +1782,8 @@
 !CharacterEncoder::TwoStepEncoder methodsFor:'queries'!
 
 characterSize:codePoint
+    "return the number of bytes required to encode codePoint"
+
     "/ naive; actually, we have to do a real encoding to get this info proper
     ^ (encoder2 characterSize:codePoint)
 
--- a/CharacterEncoderImplementations__SingleByteEncoder.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/CharacterEncoderImplementations__SingleByteEncoder.st	Sun Dec 18 11:19:27 2016 +0000
@@ -58,6 +58,7 @@
 !SingleByteEncoder methodsFor:'queries'!
 
 characterSize:codePoint
+    "return the number of bytes required to encode codePoint"
 
     ^1
 
--- a/CharacterEncoderImplementations__TwoByteEncoder.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/CharacterEncoderImplementations__TwoByteEncoder.st	Sun Dec 18 11:19:27 2016 +0000
@@ -49,6 +49,7 @@
 !TwoByteEncoder methodsFor:'queries'!
 
 characterSize:codePoint
+    "return the number of bytes required to encode codePoint"
 
     ^2
 
--- a/Collection.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/Collection.st	Sun Dec 18 11:19:27 2016 +0000
@@ -3613,6 +3613,7 @@
 
     "
      #(1 2 3 4) select:[:e | e > 10] ifNone:['sorry']  
+     #(1 2 3 4) select:[:e | e > 10] 
     "
 !
 
--- a/CompiledCode.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/CompiledCode.st	Sun Dec 18 11:19:27 2016 +0000
@@ -201,6 +201,32 @@
     "
 ! !
 
+!CompiledCode methodsFor:'Compatibility-ANSI'!
+
+argumentCount
+    "ANSI alias for numArgs: return the number of arguments, the method expects."
+
+%{  /* NOCONTEXT */
+#ifdef __SCHTEAM__
+    return __c__._RETURN( self.getNumberOfArguments() );
+#else
+    /* made this a primitive to get define in stc.h */
+
+    RETURN (__mkSmallInteger((__intVal(__INST(flags)) & F_NARGS) >> F_NARGSHIFT));
+#endif
+%}.
+    "
+     The old implementation simply counted the arguments from
+     the methods source - new versions include this information
+     in the flag instVar, for more security in #perform:
+    "
+
+    "
+     (Method compiledMethodAt:#source) numArgs
+     (Method compiledMethodAt:#source:) numArgs
+    "
+! !
+
 !CompiledCode methodsFor:'Compatibility-ST80'!
 
 getSource
@@ -1692,30 +1718,6 @@
 
 !CompiledCode methodsFor:'queries'!
 
-argumentCount
-    "ANSI alias for numArgs: return the number of arguments, the method expects."
-
-%{  /* NOCONTEXT */
-#ifdef __SCHTEAM__
-    return __c__._RETURN( self.getNumberOfArguments() );
-#else
-    /* made this a primitive to get define in stc.h */
-
-    RETURN (__mkSmallInteger((__intVal(__INST(flags)) & F_NARGS) >> F_NARGSHIFT));
-#endif
-%}.
-    "
-     The old implementation simply counted the arguments from
-     the methods source - new versions include this information
-     in the flag instVar, for more security in #perform:
-    "
-
-    "
-     (Method compiledMethodAt:#source) numArgs
-     (Method compiledMethodAt:#source:) numArgs
-    "
-!
-
 decompileTo:aStream
     |decompilerClass decompiler|
 
@@ -1849,7 +1851,8 @@
 !
 
 numArgs
-    "return the number of arguments, the method expects."
+    "return the number of arguments, the method expects.
+     Please use argumentCount for ANSI compatibility."
 
 %{  /* NOCONTEXT */
 #ifdef __SCHTEAM__
--- a/Complex.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/Complex.st	Sun Dec 18 11:19:27 2016 +0000
@@ -448,6 +448,8 @@
 !
 
 differenceFromFixedPoint: aFixedPoint
+    "Return the difference of the argument, aFixedPoint and the receiver."
+
     ^ aFixedPoint asComplex - self
 !
 
@@ -469,10 +471,14 @@
 !
 
 differenceFromFraction: aFraction
+    "Return the difference of the argument, aFraction and the receiver."
+
     ^ aFraction asComplex - self
 !
 
 differenceFromInteger: anInteger
+    "Return the difference of the argument, anInteger and the receiver."
+
     ^ anInteger asComplex - self
 !
 
@@ -499,6 +505,8 @@
 !
 
 productFromFixedPoint: aFixedPoint
+    "Return the product of the receiver and the argument, aFixedPoint."
+
     ^ aFixedPoint asComplex * self
 !
 
@@ -523,10 +531,14 @@
 !
 
 productFromFraction: aFraction
+    "Return the product of the receiver and the argument, aFraction."
+
     ^ aFraction asComplex * self
 !
 
 productFromInteger: anInteger
+    "Return the product of the receiver and the argument, anInteger."
+
     ^ anInteger asComplex * self
 !
 
@@ -601,6 +613,8 @@
 !
 
 sumFromFixedPoint: aFixedPoint
+    "Return the sum of the receiver and the argument, aFixedPoint."
+
     ^ aFixedPoint asComplex + self
 !
 
@@ -622,10 +636,14 @@
 !
 
 sumFromFraction: aFraction
+    "Return the sum of the receiver and the argument, aFraction."
+
     ^ aFraction asComplex + self
 !
 
 sumFromInteger: anInteger
+    "Return the sum of the receiver and the argument, anInteger."
+
     ^ anInteger asComplex + self
 ! !
 
--- a/Dictionary.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/Dictionary.st	Sun Dec 18 11:19:27 2016 +0000
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1991 by Claus Gittinger
 	      All Rights Reserved
@@ -992,10 +990,10 @@
      If it was not in the collection report an error.
 
      WARNING: do not remove elements while iterating over the receiver.
-	      See #saveRemoveKey: to do this."
+              See #safeRemoveKey: to do this."
 
     aKeyCollection do:[:eachKey |
-	self removeKey:eachKey ifAbsent:[self errorKeyNotFound:eachKey]
+        self removeKey:eachKey ifAbsent:[self errorKeyNotFound:eachKey]
     ].
 !
 
--- a/ExternalStream.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/ExternalStream.st	Sun Dec 18 11:19:27 2016 +0000
@@ -2072,8 +2072,8 @@
     "return the kind of object to be returned by sub-collection builders
      (such as upTo)"
 
-    binary == true ifTrue:[
-	^ ByteArray
+    binary ifTrue:[
+        ^ ByteArray
     ].
     ^ String
 !
@@ -2081,33 +2081,42 @@
 eolMode
     "return how end-of-line (EOL) is to be marked.
      Returns one one of:
-	#crlf         -> add a CR-NL, as in MSDOS
-	#cr           -> add a CR, as in VMS
-	#nl           -> add a NL, as in Unix
-	nil           -> transparent
+        #crlf         -> add a CR-NL, as in MSDOS
+        #cr           -> add a CR, as in VMS
+        #nl           -> add a NL, as in Unix
+        #eot          -> add an EOT (= 0x04, as used in some modems/protocols)
+        #etx          -> add an ETX (= 0x03, as used in some modems/protocols)
+        #nl           -> add a NL, as in Unix
+        nil           -> transparent
     "
 
     ^ eolMode
+
+    "Modified (comment): / 06-12-2016 / 14:26:24 / cg"
 !
 
 eolMode:aSymbolOrNil
     "specify how end-of-line (EOL) is to be marked.
      The argument may be one of:
-	#crlf         -> add a CR-NL, as in MSDOS
-	#cr           -> add a CR, as in VMS
-	#nl           -> add a NL, as in Unix
-	anyOther      -> like #nl
+        #crlf         -> add a CR-NL, as in MSDOS
+        #cr           -> add a CR, as in VMS
+        #nl           -> add a NL, as in Unix
+        #eot          -> add an EOT (= 0x04, as used in some modems/protocols)
+        #etx          -> add an ETX (= 0x03, as used in some modems/protocols)
+        anyOther      -> like #nl
     "
 
     aSymbolOrNil == #crnl ifTrue:[
-	eolMode := #crlf
+        eolMode := #crlf
     ] ifFalse:[
-	aSymbolOrNil == #lf ifTrue:[
-	    eolMode := #nl
-	] ifFalse:[
-	    eolMode := aSymbolOrNil
-	]
+        aSymbolOrNil == #lf ifTrue:[
+            eolMode := #nl
+        ] ifFalse:[
+            eolMode := aSymbolOrNil
+        ]
     ].
+
+    "Modified (comment): / 06-12-2016 / 14:26:37 / cg"
 !
 
 fileDescriptor
@@ -2744,14 +2753,14 @@
         ^ line , self nextLine
     ].
 
-    (hitEOF == true) ifTrue:[^ self pastEndRead].
+    hitEOF ifTrue:[^ self pastEndRead].
     error notNil ifTrue:[
         lastErrorNumber := error.
         ^ self readError:error
     ].
     handle isNil ifTrue:[^ self errorNotOpen].
     (mode == #writeonly) ifTrue:[^ self errorWriteOnly].
-    (binary == true) ifTrue:[^ self errorBinary].
+    binary ifTrue:[^ self errorBinary].
     ^ super nextLine
 !
 
@@ -3022,13 +3031,6 @@
     "
 !
 
-create
-    "create the stream
-     - this must be redefined in subclass"
-
-    ^ self subclassResponsibility
-!
-
 ioctl:ioctlNumber
     "to provide a simple ioctl facility - an ioctl is performed
      on the underlying file; no arguments are passed."
@@ -5137,37 +5139,8 @@
 !
 
 numAvailable
-    "return the number of bytes available for reading"
-
-    |fd|
-
-    handle isNil ifTrue:[^ self errorNotOpen].
-    mode == #writeonly ifTrue:[^ self errorWriteOnly].
-    fd := self fileDescriptor.
-
-%{
-#ifdef __win32__
-    int res = 1;
-    int success = 0;
-
-    if (__INST(handleType) == @symbol(socketHandle)) {
-	success = ioctlsocket((SOCKET)__externalAddressVal(fd), FIONREAD, &res) == 0;
-    } else if (__INST(handleType) == @symbol(socketFilePointer)) {
-	success = ioctlsocket((SOCKET)_get_osfhandle(__intVal(fd)), FIONREAD, &res) == 0;
-    } else if (__INST(handleType) == @symbol(pipeFilePointer)) {
-	success = PeekNamedPipe((HANDLE)_get_osfhandle(__intVal(fd)),0,0,0,&res,0);
-    }
-    if (success) {
-	if (__INST(readAhead) != nil) res++;
-	RETURN(__mkSmallInteger(res));
-    }
-#endif
-%}.
-
-    ^ (readAhead notNil or:[OperatingSystem readCheck:fd]) ifTrue:[1] ifFalse:[0].
-
-    "Created: / 4.2.1998 / 16:56:01 / cg"
-    "Modified: / 4.2.1998 / 17:31:11 / cg"
+    <resource: #obsolete>
+    ^ self numAvailableForRead
 ! !
 
 !ExternalStream methodsFor:'reading'!
@@ -5245,7 +5218,7 @@
     }
 #endif /* not SCHTEAM */
 %}.
-    hitEOF == true ifTrue:[^ self pastEndRead].
+    hitEOF ifTrue:[^ self pastEndRead].
     error notNil ifTrue:[
         lastErrorNumber := error.
         ^ self readError:error
@@ -5264,7 +5237,7 @@
     c isNil ifTrue:[
         ^ self pastEndRead.
     ].
-    binary == true ifTrue:[
+    binary ifTrue:[
         ^ c
     ].
     ^ Character value:c
@@ -5343,7 +5316,7 @@
         }
     }
 %}.
-    hitEOF == true ifTrue:[^ nil].
+    hitEOF ifTrue:[^ nil].
     error notNil ifTrue:[
         lastErrorNumber := error.
         ^ self readError:error.
@@ -5423,7 +5396,7 @@
         }
     }
 %}.
-    hitEOF == true ifTrue:[^ self pastEndRead].
+    hitEOF ifTrue:[^ self pastEndRead].
     error notNil ifTrue:[
         lastErrorNumber := error.
         ^ self readError:error.
@@ -5495,7 +5468,7 @@
         }
     }
 %}.
-    hitEOF == true ifTrue:[^ nil].
+    hitEOF ifTrue:[^ nil].
     error notNil ifTrue:[
         lastErrorNumber := error.
         ^ self readError:error.
@@ -5706,7 +5679,7 @@
 gotErrorOrEOF
     "answer true, if amn error or eof has been occurred on the stream"
 
-    ^ hitEOF == true or:[lastErrorNumber notNil]
+    ^ hitEOF or:[lastErrorNumber notNil]
 !
 
 isBinary
@@ -5739,13 +5712,13 @@
 isReadable
     "return true, if this stream can be read from"
 
-    ^ (mode ~~ #writeonly)
+    ^ mode ~~ #writeonly
 !
 
 isWritable
     "return true, if this stream can be written to"
 
-    ^ (mode ~~ #readonly)
+    ^ mode ~~ #readonly
 ! !
 
 !ExternalStream methodsFor:'waiting for I/O'!
@@ -5774,7 +5747,8 @@
     ^ available.
 
     "
-        '/etc/hosts' asFilename readStream bytesAvailable"
+        '/etc/hosts' asFilename readStream numAvailableForRead
+    "
 !
 
 readWaitWithTimeoutMs:timeoutOrNil
@@ -6008,7 +5982,7 @@
     lastErrorNumber notNil ifTrue:[self writeError. ^ self].
     handle isNil ifTrue:[self errorNotOpen. ^ self].
     (mode == #readonly) ifTrue:[self errorReadOnly. ^ self].
-    (binary==true) ifTrue:[self errorBinary. ^ self].
+    binary ifTrue:[self errorBinary. ^ self].
 
     (eolMode == #cr) ifTrue:[
         self nextPut:(Character return).
@@ -6071,9 +6045,9 @@
 
     if ((handle != STObject.Nil)
      && (aCharacter.isSTCharacter())) {
-	handle.writeChar( aCharacter );
-	self.instVarAt_put(I_position, STObject.Nil);
-	return __c__._RETURN_self();
+        handle.writeChar( aCharacter );
+        self.instVarAt_put(I_position, STObject.Nil);
+        return __c__._RETURN_self();
     }
 #else
     __INST(lastErrorNumber) = nil;
@@ -6082,112 +6056,109 @@
      || (__INST(handleType) == @symbol(socketFilePointer))
      || (__INST(handleType) == @symbol(socketHandle))
      || (__INST(handleType) == @symbol(pipeFilePointer))) {
-	OBJ fp;
-
-	if (((fp = __INST(handle)) != nil)
-	 && (__INST(mode) != @symbol(readonly))
-	) {
-	    FILEPOINTER f = __FILEVal(fp);
-	    int _buffered = (__INST(buffered) == true);
-	    unsigned codePoint;
-	    unsigned char c;
-	    int cnt;
-	    char buff[2];
-	    int nBytes = 1;
-
-	    if (__INST(binary) != true) {
-		if (__isCharacter(aCharacter)) {
-
-		    codePoint = __intVal(__characterVal(aCharacter));
-		    if (codePoint <= 0xFF) {
-			c = codePoint;
-			buff[0] = c; nBytes = 1;
-
-			if (c == '\n') {
-			    OBJ mode = __INST(eolMode);
-			    if (mode == @symbol(nl)) {
-				// no EOL translation
-			    } else if (mode == nil) {
-				// no EOL translation
-			    } else if (mode == @symbol(cr)) {
-				buff[0] = '\r';
-			    } else if (mode == @symbol(eot)) {
-				buff[0] = '\004';
-			    } else if (mode == @symbol(etx)) {
-				buff[0] = '\003';
-			    } else if (mode == @symbol(crlf)) {
-				buff[0] = '\r';
-				buff[1] = '\n';
-				nBytes = 2;
-			    }
-			}
+        OBJ fp;
+
+        if (((fp = __INST(handle)) != nil)
+         && (__INST(mode) != @symbol(readonly))
+        ) {
+            FILEPOINTER f = __FILEVal(fp);
+            int _buffered = (__INST(buffered) == true);
+            int cnt;
+            char buff[2];
+            int nBytes = 1;
+
+            if (__INST(binary) != true) {
+                if (__isCharacter(aCharacter)) {
+                    unsigned int codePoint = __intVal(__characterVal(aCharacter));
+                    if (codePoint <= 0xFF) {
+                        unsigned char c = codePoint;
+                        buff[0] = c; nBytes = 1;
+
+                        if (c == '\n') {
+                            OBJ mode = __INST(eolMode);
+                            if (mode == @symbol(nl)) {
+                                // no EOL translation
+                            } else if (mode == nil) {
+                                // no EOL translation
+                            } else if (mode == @symbol(cr)) {
+                                buff[0] = '\r';
+                            } else if (mode == @symbol(eot)) {
+                                buff[0] = '\004';
+                            } else if (mode == @symbol(etx)) {
+                                buff[0] = '\003';
+                            } else if (mode == @symbol(crlf)) {
+                                buff[0] = '\r';
+                                buff[1] = '\n';
+                                nBytes = 2;
+                            }
+                        }
     doWrite:
-			if (! f) {
-			    fprintf(stderr, "oops - fileHandle is NULL in nextPut:\n");
-			    __INST(handle) = nil;
-			    goto out;
-			}
-
-			if (_buffered) {
-			    __WRITING__(f)
-			}
+                        if (! f) {
+                            fprintf(stderr, "oops - fileHandle is NULL in nextPut:\n");
+                            __INST(handle) = nil;
+                            goto out;
+                        }
+
+                        if (_buffered) {
+                            __WRITING__(f)
+                        }
 #if defined(WIN32) && !defined(__MINGW__)
-			if ((f == __win32_stdout()) || (f == __win32_stderr())) {
-			    cnt = __win32_fwrite(buff, 1, nBytes, f);
-			} else
+                        if ((f == __win32_stdout()) || (f == __win32_stderr())) {
+                            cnt = __win32_fwrite(buff, 1, nBytes, f);
+                        } else
 # endif
-			{
-			    __WRITEBYTES__(cnt, f, buff, nBytes, _buffered, __INST(handleType));
-			}
-			if (cnt == nBytes) {
-			    if (__isSmallInteger(__INST(position))) {
-				INT np = __intVal(__INST(position)) + nBytes;
-				OBJ t;
-
-				t = __MKINT(np); __INST(position) = t; __STORE(self, t);
-			    } else {
-				__INST(position) = nil; /* i.e. do not know */
-			    }
-			    RETURN ( self );
-			}
-			error = __mkSmallInteger(__threadErrno);
-		    }
-		}
-	    } else {
-		if (__isSmallInteger(aCharacter)) {
-		    c = __intVal(aCharacter);
-		    buff[0] = c; nBytes = 1;
-		    goto doWrite;
-		}
-	    }
-	}
+                        {
+                            __WRITEBYTES__(cnt, f, buff, nBytes, _buffered, __INST(handleType));
+                        }
+                        if (cnt == nBytes) {
+                            if (__isSmallInteger(__INST(position))) {
+                                INT np = __intVal(__INST(position)) + nBytes;
+                                OBJ t;
+
+                                t = __MKINT(np); __INST(position) = t; __STORE(self, t);
+                            } else {
+                                __INST(position) = nil; /* i.e. do not know */
+                            }
+                            RETURN ( self );
+                        }
+                        error = __mkSmallInteger(__threadErrno);
+                    }
+                }
+            } else {
+                if (__isSmallInteger(aCharacter)) {
+                    unsigned char c = __intVal(aCharacter);
+                    buff[0] = c; nBytes = 1;
+                    goto doWrite;
+                }
+            }
+        }
     }
 out: ;
 #endif /* not SCHTEAM */
 %}.
     error notNil ifTrue:[
-	lastErrorNumber := error.
-	self writeError:error.
-	^ self
+        lastErrorNumber := error.
+        self writeError:error.
+        ^ self
     ].
     handle isNil ifTrue:[self errorNotOpen. ^ self].
     (mode == #readonly) ifTrue:[self errorReadOnly. ^ self].
-    binary == true ifFalse:[
-	(aCharacter isCharacter not
-	or:[aCharacter codePoint > 16rFF]) ifTrue:[
-	    self argumentMustBeCharacter.
-	    ^ self.
-	].
-    ] ifTrue:[
-	aCharacter isInteger ifFalse:[
-	    self argumentMustBeInteger.
-	    ^ self.
-	].
+    binary == true ifTrue:[
+        aCharacter isInteger ifFalse:[
+            self argumentMustBeInteger.
+            ^ self.
+        ].
+    ] ifFalse:[
+        (aCharacter isCharacter not
+         or:[aCharacter codePoint > 16rFF]) ifTrue:[
+            self argumentMustBeCharacter.
+            ^ self.
+        ].
     ].
     "/ migration support
     self
-	nextPutByte:aCharacter asInteger
-	toFile:handle
+        nextPutByte:aCharacter asInteger
+        toFile:handle
 !
 
 nextPutAll:aCollection
@@ -6762,100 +6733,6 @@
     "normal streams can not handle multi-byte characters, so convert them to utf8"
 
     self nextPutUtf8:aCharacter.
-!
-
-old_nextPut:aCharacter
-    "write the argument, aCharacter - return nil if failed, self if ok.
-     Only single-byte characters are currently supported"
-
-    |error|
-%{
-    OBJ fp;
-
-    __INST(lastErrorNumber) = nil;
-    if ((__INST(handleType) == nil)
-     || (__INST(handleType) == @symbol(filePointer))
-     || (__INST(handleType) == @symbol(socketFilePointer))
-     || (__INST(handleType) == @symbol(socketHandle))
-     || (__INST(handleType) == @symbol(pipeFilePointer))) {
-	if (((fp = __INST(handle)) != nil)
-	 && (__INST(mode) != @symbol(readonly))
-	) {
-	    unsigned char c;
-	    int _buffered = (__INST(buffered) == true);
-	    FILEPOINTER f = __FILEVal(fp);
-
-	    if (__INST(binary) != true) {
-		if (__isCharacter(aCharacter)) {
-		    unsigned codePoint = __intVal(__characterVal(aCharacter));
-
-		    if (codePoint <= 0xFF) {
-			int cnt;
-
-			c = codePoint;
-    doWrite:
-			if (! f) {
-			    fprintf(stderr, "oops - fileHandle is NULL in nextPut:\n");
-			    __INST(handle) = nil;
-			    goto out;
-			}
-
-			if (_buffered) {
-			    __WRITING__(f)
-			}
-#if defined(WIN32) && !defined(__MINGW__)
-			if ((f == __win32_stdout()) || (f == __win32_stderr())) {
-			    cnt = __win32_fwrite(&c, 1, 1, f);
-			} else
-#endif
-			__WRITEBYTE__(cnt, f, &c, _buffered, __INST(handleType));
-			if (cnt == 1) {
-			    if (__isSmallInteger(__INST(position))) {
-				INT np = __intVal(__INST(position)) + 1;
-				OBJ t;
-
-				t = __MKINT(np); __INST(position) = t; __STORE(self, t);
-			    } else {
-				__INST(position) = nil; /* i.e. do not know */
-			    }
-			    RETURN ( self );
-			}
-			error = __mkSmallInteger(__threadErrno);
-		    }
-		}
-	    } else {
-		if (__isSmallInteger(aCharacter)) {
-		    c = __intVal(aCharacter);
-		    goto doWrite;
-		}
-	    }
-	}
-    }
-out: ;
-%}.
-    error notNil ifTrue:[
-	lastErrorNumber := error.
-	self writeError:error.
-	^ self
-    ].
-    handle isNil ifTrue:[self errorNotOpen. ^ self].
-    (mode == #readonly) ifTrue:[self errorReadOnly. ^ self].
-    binary == true ifFalse:[
-	(aCharacter isCharacter not
-	or:[aCharacter codePoint > 16rFF]) ifTrue:[
-	    self argumentMustBeCharacter.
-	    ^ self.
-	].
-    ] ifTrue:[
-	aCharacter isInteger ifFalse:[
-	    self argumentMustBeInteger.
-	    ^ self.
-	].
-    ].
-    "/ migration support
-    self
-	nextPutByte:aCharacter asInteger
-	toFile:handle
 ! !
 
 !ExternalStream class methodsFor:'documentation'!
--- a/Lookup.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/Lookup.st	Sun Dec 18 11:19:27 2016 +0000
@@ -89,7 +89,7 @@
     |cls md method|
 
     "Following C code is just a performance optimization.
-     It is not neccessary, however it speeds up UI code,
+     It is not necessary, however it speeds up UI code,
      since it heavily uses perform:"
 %{
     RETURN (  __lookup(initialSearchClass, selector) );
@@ -128,15 +128,13 @@
      |cls md method|
 
     "Following C code is just a performance optimization.
-     It is not neccessary, however it speeds up UI code,
+     It is not necessary, however it speeds up UI code,
      since it heavily uses perform:"
 %{
     RETURN (  __lookup(initialSearchClass, selector) );
 %}.
     ^ self lookupMethodForSelector: selector
-		   directedTo: initialSearchClass
-
-
+                   directedTo: initialSearchClass
 !
 
 lookupMethodForSelector:selector directedTo:initialSearchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext ilc: ilcCache
@@ -157,7 +155,7 @@
     | method |
 
     "Following C code is just a performance optimization.
-     It is not neccessary, however it speeds up UI code,
+     It is not necessary, however it speeds up UI code,
      since it heavily uses perform:"
 %{
     method = __lookup(initialSearchClass, selector);
--- a/NamespaceAwareLookup.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/NamespaceAwareLookup.st	Sun Dec 18 11:19:27 2016 +0000
@@ -89,11 +89,11 @@
 
     "JV @ 2010-07-24
      Following C code is just a performance optimization.
-     It is not neccessary, however it speeds things in most
+     It is not necessary, however it speeds things in most
      cases. Such optimization significantly speeds up the IDE
      since class browser involves dozens of super-polymorphic
      sends (> 1000 receiver classes per send-site).
-	"
+        "
 
 %{
     OBJ sendingMthd = nil;
@@ -110,17 +110,16 @@
     }
 	          
     if (__Class(sendingMthd) == Method &&
-	    __MethodInstPtr(sendingMthd)->m_annotation == nil) {
-	    OBJ m = __lookup(initialSearchClass, selector);
-	    if (m != nil) RETURN ( m );
+            __MethodInstPtr(sendingMthd)->m_annotation == nil) {
+            OBJ m = __lookup(initialSearchClass, selector);
+            if (m != nil) RETURN ( m );
     }
 %}.
 
     ^Instance lookupMethodForSelector: selector directedTo: initialSearchClass
-			  for: receiver withArguments: argArrayOrNil
-			  from: sendingContext
+                          for: receiver withArguments: argArrayOrNil
+                          from: sendingContext
 			  ilc: ilc
-
 ! !
 
 !NamespaceAwareLookup methodsFor:'lookup'!
@@ -133,7 +132,7 @@
 
     "JV @ 2010-07-24
      Following C code is just a performance optimization.
-     It is not neccessary, however it speeds things in most
+     It is not necessary, however it speeds things in most
      cases. Such optimization significantly speeds up the IDE
      since class browser involves dozens of super-polymorphic
      sends (> 1000 receiver classes per send-site).
@@ -423,7 +422,7 @@
 !NamespaceAwareLookup class methodsFor:'documentation'!
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/NamespaceAwareLookup.st,v 1.4 2015-05-18 00:05:38 cg Exp $'
+    ^ '$Header$'
 !
 
 version_HG
@@ -432,7 +431,7 @@
 !
 
 version_SVN
-    ^ '$Id: NamespaceAwareLookup.st,v 1.4 2015-05-18 00:05:38 cg Exp $'
+    ^ '$Id$'
 ! !
 
 
--- a/NonPositionableExternalStream.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/NonPositionableExternalStream.st	Sun Dec 18 11:19:27 2016 +0000
@@ -303,12 +303,25 @@
     ^ bytes signedInt32At:1 MSB:msbFlag.
 !
 
+nextInt64MSB:msbFlag
+    "redefined to wait for data on pipes and sockets"
+
+    |bytes nRead|
+
+    bytes := ByteArray uninitializedNew:8.
+    nRead := self nextBytes:8 into:bytes startingAt:1.
+    nRead ~~ 8 ifTrue:[
+        ^ self pastEndRead.
+    ].
+    ^ bytes signedInt64At:1 MSB:msbFlag.
+!
+
 nextUnsignedInt16MSB:msbFlag
     "redefined to wait for data on pipes and sockets"
 
     |bytes nRead|
 
-    bytes := ByteArray uninitializedNew:4.
+    bytes := ByteArray uninitializedNew:2.
     nRead := self nextBytes:2 into:bytes startingAt:1.
     nRead ~~ 2 ifTrue:[
         ^ self pastEndRead.
@@ -327,6 +340,19 @@
         ^ self pastEndRead.
     ].
     ^ bytes unsignedInt32At:1 MSB:msbFlag.
+!
+
+nextUnsignedInt64MSB:msbFlag
+    "redefined to wait for data on pipes and sockets"
+
+    |bytes nRead|
+
+    bytes := ByteArray uninitializedNew:8.
+    nRead := self nextBytes:8 into:bytes startingAt:1.
+    nRead ~~ 8 ifTrue:[
+        ^ self pastEndRead.
+    ].
+    ^ bytes unsignedInt64At:1 MSB:msbFlag.
 ! !
 
 !NonPositionableExternalStream methodsFor:'positioning'!
@@ -620,7 +646,20 @@
 
     answerStream := WriteStream on:(String uninitializedNew:80).
     [
+        "#atEnd waits for new data or EOF"
+        self atEnd ifTrue:[
+            answerStream size == 0 ifTrue:[
+                ^ self pastEndRead.
+            ].
+            ^ answerStream contents.
+        ].
         available := self numAvailableForRead.
+        available == 0 ifTrue:[
+            "so #atEnd didn't wait above, but no data is present - check for error"
+            self peek.
+            available := self numAvailableForRead.        
+        ].
+        
         wasBinary := binary.            "temporarily set to text mode"
         binary := false.
         available timesRepeat:[
@@ -637,14 +676,6 @@
             ].
         ].
         binary := wasBinary.            "restore saved mode"
-
-        "#atEnd waits for new data or EOF"
-        self atEnd ifTrue:[
-            answerStream size == 0 ifTrue:[
-                ^ self pastEndRead.
-            ].
-            ^ answerStream contents.
-        ].
     ] loop.
 
     "not reached"
@@ -700,7 +731,17 @@
     |element available "{ Class:SmallInteger }"|
 
     [
+        "#atEnd waits for new data or EOF"
+        self atEnd ifTrue:[
+            ^ self.
+        ].
         available := self numAvailableForRead.
+        available == 0 ifTrue:[
+            "so #atEnd didn't wait above, but no data is present - check for error"
+            self peek.
+            available := self numAvailableForRead.        
+        ].
+
         available timesRepeat:[
             element := super next.      "we know that there is data"
             element = anObject ifTrue:[
@@ -708,10 +749,6 @@
             ].
             aStream nextPut:element.
         ].
-        "#atEnd waits for new data or EOF"
-        self atEnd ifTrue:[
-            ^ self.
-        ].
     ] loop.
 
     "not reached"
--- a/Number.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/Number.st	Sun Dec 18 11:19:27 2016 +0000
@@ -157,11 +157,25 @@
      In contrast to readFrom:, no garbage is allowed after the number.
      I.e. the string must contain exactly one valid number (with optional separators around)"
 
-    ^ self readFrom:aString decimalPointCharacters:decimalPointCharacters onError:exceptionBlock
+    |s num|
+
+    s := aString readStream.
+    num := self readFrom:s decimalPointCharacters:decimalPointCharacters onError:[^ exceptionBlock value].
+    s atEnd ifFalse:[
+        s skipSeparators.
+        s atEnd ifFalse:[
+            ^ exceptionBlock value "/ - garbage at end of number'
+        ].
+    ].
+    ^ num.
 
     "
      Number fromString:'12345' onError:0
+     Number fromString:'12,345' decimalPointCharacters:',' onError:0
+     Number fromString:'12,345' decimalPointCharacters:',' onError:0
      Number fromString:'fooBarBaz' onError:0
+     Number fromString:'123fooBarBaz' onError:0
+     Number fromString:'123,fooBarBaz' decimalPointCharacters:',' onError:0
     "
 
     "Modified: / 3.8.1998 / 20:05:34 / cg"
@@ -172,11 +186,12 @@
      In contrast to readFrom:, no garbage is allowed after the number.
      I.e. the string must contain exactly one valid number (with optional separators around)"
 
-    ^ self readFrom:aString onError:exceptionBlock
+    ^ self fromString:aString decimalPointCharacters:(self decimalPointCharactersForReading) onError:exceptionBlock
 
     "
      Number fromString:'12345' onError:0
      Number fromString:'fooBarBaz' onError:0
+     Number fromString:'123fooBarBaz' onError:0
     "
 
     "Modified: / 3.8.1998 / 20:05:34 / cg"
@@ -503,6 +518,7 @@
     ^ Integer readFrom:aStream radix:radix
 ! !
 
+
 !Number class methodsFor:'constants'!
 
 decimalPointCharacter
@@ -710,6 +726,7 @@
     "
 ! !
 
+
 !Number class methodsFor:'private'!
 
 readMantissaAndScaleFrom:aStream radix:radix
@@ -784,6 +801,7 @@
     ^ self == Number
 ! !
 
+
 !Number methodsFor:'Compatibility-Squeak'!
 
 asSmallAngleDegrees
@@ -933,6 +951,7 @@
     ^ self rounded printString
 ! !
 
+
 !Number methodsFor:'coercing & converting'!
 
 i
@@ -1105,7 +1124,7 @@
 !
 
 degreesToRadians
-    "interpreting the receiver as radians, return the degrees"
+    "interpreting the receiver as degrees, return the radians"
 
     ^ self * (Float pi / 180.0)
 
@@ -1138,7 +1157,7 @@
 !
 
 radiansToDegrees
-    "interpreting the receiver as degrees, return the radians"
+    "interpreting the receiver as radians, return the degrees"
 
     ^ self * (180.0 / Float pi)
 
@@ -2791,6 +2810,7 @@
     "Modified: / 5.11.2001 / 17:54:22 / cg"
 ! !
 
+
 !Number class methodsFor:'documentation'!
 
 version
--- a/ObjectMemory.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/ObjectMemory.st	Sun Dec 18 11:19:27 2016 +0000
@@ -1996,40 +1996,40 @@
     |names oClass|
 
     referent == Smalltalk ifTrue:[
-	referent keysAndValuesDo:[:key :val |
-	    |idx|
-
-	    (anObject == val) ifTrue:[
-		"/ for our convenience - if its a nameSpace, cut off Smalltalk.
-		idx := key string indexOf:$:.
-		(idx ~~ 0
-		and:[idx < key string size
-		and:[(key string at:(idx+1)) == $:]]) ifTrue:[
-		    ^ key allBold "/ (key copyFrom:(idx+2)) allBold
-		].
-		^ 'Smalltalk:' , (key allBold).
-	    ]
-	].
+        referent keysAndValuesDo:[:key :val |
+            |idx|
+
+            (anObject == val) ifTrue:[
+                "/ for our convenience - if its a nameSpace, cut off Smalltalk.
+                idx := key string indexOf:$:.
+                (idx ~~ 0
+                and:[idx < key string size
+                and:[(key string at:(idx+1)) == $:]]) ifTrue:[
+                    ^ key allBold "/ (key copyFrom:(idx+2)) allBold
+                ].
+                ^ 'Smalltalk:' , (key allBold).
+            ]
+        ].
     ] ifFalse:[
-	names := referent class allInstVarNames.
-	oClass := referent class.
-	oClass == anObject ifTrue:[
-	    ^ oClass name.
-	].
-	1 to:oClass instSize do:[:i |
-	    ((referent instVarAt:i) == anObject) ifTrue:[
-		^ '%1 [%2]' bindWith:referent classNameWithArticle with:(names at:i) allBold.
-	    ].
-	].
-	oClass isVariable ifTrue:[
-	    oClass isPointers ifTrue:[
-		1 to:referent basicSize do:[:i |
-		    ((referent basicAt:i) == anObject) ifTrue:[
-			^ '%1 [%2] (sz=%2)' bindWith:referent classNameWithArticle with:i printString allBold with:referent basicSize printString
-		    ]
-		]
-	    ]
-	].
+        names := referent class allInstVarNames.
+        oClass := referent class.
+        oClass == anObject ifTrue:[
+            ^ oClass name.
+        ].
+        1 to:oClass instSize do:[:i |
+            ((referent instVarAt:i) == anObject) ifTrue:[
+                ^ '%1 [%2]' bindWith:referent class nameWithArticle with:(names at:i) allBold.
+            ].
+        ].
+        oClass isVariable ifTrue:[
+            oClass isPointers ifTrue:[
+                1 to:referent basicSize do:[:i |
+                    ((referent basicAt:i) == anObject) ifTrue:[
+                        ^ '%1 [%2] (sz=%2)' bindWith:referent class nameWithArticle with:i printString allBold with:referent basicSize printString
+                    ]
+                ]
+            ]
+        ].
     ].
     self error:'no reference' mayProceed:true.
     ^ nil.
--- a/PCFilename.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/PCFilename.st	Sun Dec 18 11:19:27 2016 +0000
@@ -422,33 +422,37 @@
 
     |retryCtr newFilename|
 
-    newFilename := newName asFilename.
-    newFilename exists ifTrue:[
-        (self pathName sameAs:newFilename pathName) ifFalse:[
-            newFilename delete
+
+    "try 5 times (retry 4 times) if file has just been written to and is locked by a virus scanner"
+    retryCtr := 4.
+    [
+        ^ super renameTo:newName
+    ] on:OSErrorHolder existingReferentSignal do:[:ex|
+        |newFilename|
+
+        newFilename := newName asFilename.
+        (self pathName sameAs:newFilename pathName) ifTrue:[
+            ex reject.
         ].
-    ].
-
-    "try 5 times if file has just been written to and is locked by a virus scanner"
-    retryCtr := 5.
-    OperatingSystem accessDeniedErrorSignal handle:[:ex|
-        retryCtr := retryCtr - 1.
+        newFilename remove.
+        ex restart.
+    ] on:OSErrorHolder noPermissionsSignal do:[:ex|
         retryCtr > 0 ifTrue:[
             Logger warning:'Error caught while renaming %1 to %2 - maybe temporary locked by virus scanner, still trying: %3'
                                 with:self pathName
                                 with:newFilename pathName
                                 with:ex description.
+            retryCtr := retryCtr - 1.
+            Delay waitForMilliseconds:200.
+            ex restart.
         ] ifFalse:[
             ex reject
         ].
-        Delay waitForMilliseconds:200.
-        ex restart.
-    ] do:[
-        ^ super renameTo:newName
     ].
 
     "
-     '\tmp\foo' asFilename renameTo:'\tmp\bar'
+     'c:\users\stefan\test.txt' asFilename  renameTo:'c:\users\stefan\test1.txt'
+     'c:\users\stefan\test12.txt' asFilename  renameTo:'c:\users\stefan\test.txt'
     "
 
     "Modified: / 20-01-1998 / 15:33:00 / md"
--- a/PeekableStream.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/PeekableStream.st	Sun Dec 18 11:19:27 2016 +0000
@@ -530,61 +530,25 @@
 
 !PeekableStream methodsFor:'reading'!
 
-nextDecimalInteger
-    "read the next integer in radix 10. 
-     Does NOT skip initial whitespace.
-     The streams elements should be characters.
-
-     Be careful - this method returns 0 if not positioned on a digit intitially
-     or if the end of the stream is encountered."
-
-    |nextOne value|
-
-    nextOne := self peekOrNil.
-    value := 0.
-    [nextOne notNil and:[nextOne isDigitRadix:10]] whileTrue:[
-        value := (value * 10) + nextOne digitValue.
-        self next.
-        nextOne := self peekOrNil
-    ].
-    ^ value
-
-    "
-     |s|
+nextDelimited:terminator
+    "return the contents of the receiver, up to the next terminator element. 
+     Doubled terminators indicate an embedded terminator element.  
+     For example: 'this '' was a quote'. 
+     Start positioned before the initial terminator."
 
-     s := '1234 5678' readStream.
-     s nextDecimalInteger. 
-    "
-
-    "
-     |s|
-
-     s := '1234 5678' readStream.
-     s nextDecimalInteger.
-     s skipSpaces.
-     s nextDecimalInteger. 
-    "
-!
-
-nextDelimited:terminator
-    "return the contents of the receiver, up to the next terminator character. 
-     Doubled terminators indicate an embedded terminator character.  
-     For example: 'this '' was a quote'. 
-     Start postioned before the initial terminator."
-
-    | out ch |
+    | out element |
 
     self atEnd ifTrue: [^ ''].
     self next == terminator ifFalse: [self skip: -1].       "absorb initial terminator"
     out := WriteStream on:(self contentsSpecies new).
-    [(ch := self next) == nil] whileFalse: [
-        (ch == terminator) ifTrue: [
+    [(element := self nextOrNil) isNil and:[self atEnd]] whileFalse:[
+        element == terminator ifTrue: [
             self peek == terminator ifFalse: [
                 ^ out contents  "terminator is not doubled; we're done!!"
             ].
             self next.  "skip doubled terminator"
         ].
-        out nextPut: ch.
+        out nextPut:element.
     ].
     ^ out contents
 
@@ -694,6 +658,42 @@
     "Modified: / 5.3.1998 / 13:45:07 / cg"
 !
 
+skipUntil:aBlock
+    "skip all elements for which aBlock returns false.
+     Return true if more elements can be read, false if eof has been reached."
+
+    [self atEnd] whileFalse:[
+        (aBlock value: self peek) ifTrue:[^ true].
+        self next
+    ].
+    ^ false
+
+    "
+     #(1 2 3 4 5 6 7 8 9 10) readStream
+        skipUntil:[:el | el >= 5];
+        next
+    "
+!
+
+skipWhile:aBlock
+    "skip all elements for which aBlock returns true. Return true if more elements can be read,
+     false if eof has been reached."
+
+    [self atEnd] whileFalse:[
+	(aBlock value: self peek) ifFalse:[^ true].
+	self next
+    ].
+    ^ false
+
+    "
+     #(1 2 3 4 5 6 7 8 9 10) readStream
+	skipWhile:[:el | el <= 5];
+	next
+    "
+
+    "Created: / 23-09-2011 / 13:32:40 / cg"
+!
+
 throughAnyForWhich:checkBlock
     "read & return a collection of all objects up-to and including 
      the elements for which checkBlock returns true.
@@ -728,6 +728,137 @@
     "
 
     "Modified: / 11.1.1998 / 15:28:04 / cg"
+!
+
+upToAny:aCollectionOfObjects
+    "read a collection of all objects up-to a element which is contained in
+     aCollectionOfObjects and return these elements, but excluding the matching one.
+     The next read operation will return the element AFTER anObject.
+     If no such element is encountered, all elements up to the end are read
+     and returned.
+     Compare this with #throughAll: which also reads up to some object
+     and also positions behind it, but DOES include it in the returned
+     value."
+
+    |result|
+
+    result := self upToBeforeAny:aCollectionOfObjects.
+    self atEnd ifFalse:[
+        self next.
+    ].
+    ^ result
+
+    "
+     |s|
+     s := ReadStream on:'hello world'.
+     Transcript showCR:(s upToAny:(Array with:Character space)).
+     Transcript showCR:(s upToEnd)
+
+     'Makefile' asFilename readStream upToAny:($A to:$Z)
+    "
+
+    "Created: / 30.8.1997 / 03:02:05 / cg"
+    "Modified: / 11.1.1998 / 15:19:18 / cg"
+!
+
+upToBeforeAny:aCollectionOfObjects
+    "read a collection of all objects up-to a element which is contained in
+     aCollectionOfObjects and return these elements, but excluding the matching one.
+     The next read operation will return the matching element.
+     If no such element is encountered, all elements up to the end are read
+     and returned.
+     This returns the exact same as upToAny: would, but leaves the stream's position so that
+     the next read returns the matching delimiter instead of skipping it.
+     Caveat: this is the one which should have been called upTo: in the first place;
+     however, it seems now too late for a change."
+
+    |answerStream element|
+
+    answerStream := WriteStream on:(self contentsSpecies new).
+    [self atEnd] whileFalse:[
+        element := self peek.
+        (aCollectionOfObjects includes:element) ifTrue: [
+            ^ answerStream contents
+        ].
+        answerStream nextPut:element.
+        self next.
+    ].
+    ^ answerStream contents
+
+    "
+     |s|
+     s := ReadStream on:'hello world'.
+     Transcript showCR:(s upToBeforeAny:(Array with:Character space)).
+     Transcript showCR:(s upToEnd)
+
+     'Make.proto' asFilename readStream upToBeforeAny:($A to:$Z)
+    "
+
+    "Created: / 30.8.1997 / 03:02:05 / cg"
+    "Modified: / 11.1.1998 / 15:19:18 / cg"
+!
+
+upToElementForWhich:aBlock
+    "read elements until aBlock returns true for an element.
+     Return the collected elements excluding that element.
+     Leave the stream positioned for the next read to return that element.
+     If no element matches, all elements up to the end are returned"
+
+    |answerStream next|
+
+    answerStream := WriteStream on:(self contentsSpecies new).
+
+    [
+        self atEnd
+        or:[ (aBlock value: (next := self peek)) ]
+    ] whileFalse:[
+        answerStream nextPut:next.
+        self next.
+    ].
+    ^ answerStream contents
+
+    "
+     #(1 2 3 4 5 6 7 8 9 10) readStream
+        upToElementForWhich:[:el | el > 5]
+    "
+! !
+
+!PeekableStream methodsFor:'reading-numbers'!
+
+nextDecimalInteger
+    "read the next integer in radix 10. 
+     Does NOT skip initial whitespace.
+     The streams elements should be characters.
+
+     Be careful - this method returns 0 if not positioned on a digit intitially
+     or if the end of the stream is encountered."
+
+    |nextOne value|
+
+    nextOne := self peekOrNil.
+    value := 0.
+    [nextOne notNil and:[nextOne isDigitRadix:10]] whileTrue:[
+        value := (value * 10) + nextOne digitValue.
+        self next.
+        nextOne := self peekOrNil
+    ].
+    ^ value
+
+    "
+     |s|
+
+     s := '1234 5678' readStream.
+     s nextDecimalInteger. 
+    "
+
+    "
+     |s|
+
+     s := '1234 5678' readStream.
+     s nextDecimalInteger.
+     s skipSpaces.
+     s nextDecimalInteger. 
+    "
 ! !
 
 !PeekableStream methodsFor:'reading-strings'!
--- a/PositionableStream.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/PositionableStream.st	Sun Dec 18 11:19:27 2016 +0000
@@ -218,16 +218,6 @@
     ^ collection
 !
 
-peek
-    "look ahead for and return the next element"
-
-    |peekObject|
-
-    peekObject := self next.
-    self backStep.
-    ^ peekObject
-!
-
 peekForAll:aCollection
     "return true and advance if the next elements are the same
      as aCollection. 
@@ -386,6 +376,48 @@
     "
 ! !
 
+!PositionableStream methodsFor:'non homogenous reading'!
+
+nextBytes:numBytes into:aCollection startingAt:initialIndex
+    "return the next numBytes from the stream. If the end is
+     reached before, only that many bytes are copyied into the
+     collection.
+     Returns the number of bytes that have been actually read.
+     The receiver must support reading of binary bytes.
+
+     Notice: this method is provided here for protocol completeness
+             with externalStreams - it is normally not used with other
+             streams."
+
+    |max|
+
+    (collection isByteCollection
+     and:[aCollection isByteCollection]) ifTrue:[
+        "do it the fast way"
+        max := (readLimit - position) min: numBytes.
+        aCollection
+            replaceBytesFrom:initialIndex 
+            to:(initialIndex + max - 1)
+            with:collection 
+            startingAt:position+1.
+        position := position + max.
+        ^ max
+    ].
+    "do it the hard way"
+    ^ super nextBytes:numBytes into:aCollection startingAt:initialIndex
+
+    "
+     |s n buffer|
+
+     buffer := ByteArray new:10.
+
+     s := ReadStream on:#[1 2 3 4 5 6 7 8 9].
+     s next:3.
+     n := s nextBytes:9 into:buffer startingAt:1.
+     Transcript showCR:('n = %1; buffer = <%2>' bindWith:n with:buffer)
+    "
+! !
+
 !PositionableStream methodsFor:'positioning'!
 
 backStep
@@ -816,91 +848,14 @@
     "
 !
 
-nextBytes:numBytes into:aCollection startingAt:initialIndex
-    "return the next numBytes from the stream. If the end is
-     reached before, only that many bytes are copyied into the
-     collection.
-     Returns the number of bytes that have been actually read.
-     The receiver must support reading of binary bytes.
-
-     Notice: this method is provided here for protocol completeness
-             with externalStreams - it is normally not used with other
-             streams."
-
-    |max|
-
-    (collection isByteCollection
-     and:[aCollection isByteCollection]) ifTrue:[
-        "do it the fast way"
-        max := (readLimit - position) min: numBytes.
-        aCollection
-            replaceBytesFrom:initialIndex 
-            to:(initialIndex + max - 1)
-            with:collection 
-            startingAt:position+1.
-        position := position + max.
-        ^ max
-    ].
-    "do it the hard way"
-    ^ super nextBytes:numBytes into:aCollection startingAt:initialIndex
-
-    "
-     |s n buffer|
-
-     buffer := ByteArray new:10.
-
-     s := ReadStream on:#[1 2 3 4 5 6 7 8 9].
-     s next:3.
-     n := s nextBytes:9 into:buffer startingAt:1.
-     Transcript showCR:('n = %1; buffer = <%2>' bindWith:n with:buffer)
-    "
-!
+peek
+    "look ahead for and return the next element"
 
-nextLine
-    "return the characters upTo (but excluding) the next cr (carriage return)
-     character (i.e. read a single line of text).
-     If the previous-to-last character is a cr, this is also removed,
-     so it's possible to read alien (i.e. ms-dos) text as well.
-     Added for protocol compatibility with externalStreams."
-
-    |start "{ Class:SmallInteger }" 
-     end "{ Class:SmallInteger }"|
-
-    collection isString ifTrue:[
-        position == readLimit ifTrue:[
-            ^ self pastEndRead
-        ].
-        start := position+1.
-        end := collection indexOf:Character cr startingAt:start.
+    |peekObject|
 
-        (end == 0 or:[end > readLimit]) ifTrue:[
-            end := position := readLimit.
-        ] ifFalse:[
-            position := end.
-            end := end - 1.    "skip lf"
-        ].
-        start > end ifTrue:[
-            ^ ''.
-        ].
-        (collection at:end) == Character return ifTrue:[
-            end := end - 1.    "skip return"
-        ].
-        ^ collection copyFrom:start to:end.
-    ].
-    ^ super nextLine.
-
-    "
-        '12345678' readStream nextLine
-        '12345678' allBold readStream nextLine
-        '12\34\56\78' withCRs readStream nextLine
-        '12\34\56\78' withCRs readStream nextLine; nextLine
-        (ReadStream on:('12\34\56\78' withCRs) from:1 to:4) nextLine; nextLine
-        ('12\' withCRs, Character return, '34') readStream nextLine; nextLine
-        Character cr asString readStream nextLine
-        Character return asString readStream nextLine
-        (Character return, Character cr) asString readStream nextLine
-        Character return asString readStream nextLine; nextLine
-    "
+    peekObject := self next.
+    self backStep.
+    ^ peekObject
 !
 
 upToAll:aCollection
@@ -1019,6 +974,55 @@
     "
 ! !
 
+!PositionableStream methodsFor:'reading-strings'!
+
+nextLine
+    "return the characters upTo (but excluding) the next cr (carriage return)
+     character (i.e. read a single line of text).
+     If the previous-to-last character is a cr, this is also removed,
+     so it's possible to read alien (i.e. ms-dos) text as well.
+     Added for protocol compatibility with externalStreams."
+
+    |start "{ Class:SmallInteger }" 
+     end "{ Class:SmallInteger }"|
+
+    collection isString ifTrue:[
+        position == readLimit ifTrue:[
+            ^ self pastEndRead
+        ].
+        start := position+1.
+        end := collection indexOf:Character cr startingAt:start.
+
+        (end == 0 or:[end > readLimit]) ifTrue:[
+            end := position := readLimit.
+        ] ifFalse:[
+            position := end.
+            end := end - 1.    "skip lf"
+        ].
+        start > end ifTrue:[
+            ^ ''.
+        ].
+        (collection at:end) == Character return ifTrue:[
+            end := end - 1.    "skip return"
+        ].
+        ^ collection copyFrom:start to:end.
+    ].
+    ^ super nextLine.
+
+    "
+        '12345678' readStream nextLine
+        '12345678' allBold readStream nextLine
+        '12\34\56\78' withCRs readStream nextLine
+        '12\34\56\78' withCRs readStream nextLine; nextLine
+        (ReadStream on:('12\34\56\78' withCRs) from:1 to:4) nextLine; nextLine
+        ('12\' withCRs, Character return, '34') readStream nextLine; nextLine
+        Character cr asString readStream nextLine
+        Character return asString readStream nextLine
+        (Character return, Character cr) asString readStream nextLine
+        Character return asString readStream nextLine; nextLine
+    "
+! !
+
 !PositionableStream methodsFor:'testing'!
 
 atEnd
--- a/Process.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/Process.st	Sun Dec 18 11:19:27 2016 +0000
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1992 by Claus Gittinger
 	      All Rights Reserved
@@ -471,9 +473,12 @@
 !Process class methodsFor:'instance retrieval'!
 
 findProcessWithId:id
+    <resource: #obsolete>
     "return a process with a particular id.
      This is only a debugging helper, to allow
-     easy access of a process by name in the MiniDebugger"
+     easy access of a process by name in the MiniDebugger.
+     Do not use - ask Processor instead!!"
+
 
     ^ self allSubInstances detect:[:aProcess | aProcess id = id] ifNone:nil.
 
@@ -485,9 +490,11 @@
 !
 
 findProcessWithName:name
+    <resource: #obsolete>
     "return a process with a particular name.
      This is only a debugging helper, to allow
-     easy access of a process by name in the MiniDebugger"
+     easy access of a process by name in the MiniDebugger
+     Do not use - ask Processor instead!!"
 
     ^ self allSubInstances detect:[:aProcess | aProcess name = name] ifNone:nil.
 
@@ -499,8 +506,9 @@
 !
 
 findProcessesWithGroupId:aGroupId
+    <resource: #obsolete>
     "return a collection of processes with the particular group id.
-    "
+     Do not use - ask Processor instead!!"
 
     ^ self allSubInstances select:[:aProcess | aProcess processGroupId = aGroupId ].
 
--- a/ProcessorScheduler.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/ProcessorScheduler.st	Sun Dec 18 11:19:27 2016 +0000
@@ -578,6 +578,16 @@
     "Processor currentPriority"
 !
 
+exitWhenNoMoreUserProcesses:aBoolean
+    "set/clear the flag, which controls if the scheduler should exit and return
+     when the last user process finishes (and therefore exit the smalltalk system).
+     A userProcess is defined as a process with a non-zero processGroup.
+     This flag is typically set for standAlone operation, to terminate the (Unix-)
+     process, when the last thread terminates."
+
+    exitWhenNoMoreUserProcesses := aBoolean
+!
+
 interruptCounter
     "for statistics: counts the overall number of interrupts"
 
@@ -899,16 +909,6 @@
 
     "Modified: / 23-09-1996 / 14:19:56 / stefan"
     "Modified: / 20-07-2012 / 18:34:48 / cg"
-!
-
-exitWhenNoMoreUserProcesses:aBoolean
-    "set/clear the flag, which controls if the scheduler should exit and return
-     when the last user process finishes (and therefore exit the smalltalk system).
-     A userProcess is defined as a process with a non-zero processGroup.
-     This flag is typically set for standAlone operation, to terminate the (Unix-)
-     process, when the last thread terminates."
-
-    exitWhenNoMoreUserProcesses := aBoolean
 ! !
 
 !ProcessorScheduler methodsFor:'initialization'!
@@ -1735,6 +1735,32 @@
 	Processor processWithId:4
 	Processor processWithId:4711
     "
+!
+
+processesWithGroupId:anInteger
+    "answer a collection of processes with processGroupId, anInteger"
+
+    |wasBlocked coll|
+
+    coll := OrderedCollection new.
+
+    wasBlocked := OperatingSystem blockInterrupts.
+    KnownProcesses validElementsDo:[:eachProcess| 
+        eachProcess processGroupId = anInteger ifTrue:[
+            coll add:eachProcess.
+        ].
+    ].
+
+    wasBlocked ifFalse:[
+        OperatingSystem unblockInterrupts.
+    ].
+
+    ^ coll.
+
+    "
+        Processor processesWithGroupId:0
+        Processor processesWithGroupId:4711
+    "
 ! !
 
 !ProcessorScheduler methodsFor:'scheduling'!
@@ -3407,158 +3433,158 @@
 
     newProcessMaybeReady := false.
     readableResultFdArray size < readFdArray size ifTrue:[
-	readableResultFdArray := Array new:(40 max:readFdArray size).
+        readableResultFdArray := Array new:(40 max:readFdArray size).
     ].
     writableResultFdArray size < writeFdArray size ifTrue:[
-	writableResultFdArray := Array new:(40 max:writeFdArray size).
+        writableResultFdArray := Array new:(40 max:writeFdArray size).
     ].
 
     exceptArray := exceptFdArray.
 
     OperatingSystem isMSWINDOWSlike ifTrue:[
-	"/
-	"/ win32 does a WaitForMultipleObjects in select...
-	"/ unix waits for SIGCHLD
-	"/
-	|hasPids|
-
-	hasPids := false.
-	osChildExitActions keysDo:[:eachPid|
-	    eachPid address = 0 ifTrue:[
-		'Processor: remove 0-handle pid: ' infoPrint. eachPid infoPrintCR.
-		osChildExitActions safeRemoveKey:eachPid.
-	    ] ifFalse:[
-		hasPids := true.
-	    ].
-	].
-	hasPids ifTrue:[
-	    exceptArray := (exceptArray upTo:nil), osChildExitActions keys asArray.
+        "/
+        "/ win32 does a WaitForMultipleObjects in select...
+        "/ unix waits for SIGCHLD
+        "/
+        |hasPids|
+
+        hasPids := false.
+        osChildExitActions keysDo:[:eachPid|
+            eachPid address = 0 ifTrue:[
+                Logger warning:'Processor: remove 0-handle pid: %1' with:eachPid.
+                osChildExitActions safeRemoveKey:eachPid.
+            ] ifFalse:[
+                hasPids := true.
+            ].
+        ].
+        hasPids ifTrue:[
+            exceptArray := (exceptArray upTo:nil), osChildExitActions keys asArray.
 "/'exceptArray: ' print. exceptArray printCR.
-	].
+        ].
     ].
 
     exceptResultFdArray size < exceptArray size ifTrue:[
-	exceptResultFdArray := Array new:(40 max:exceptArray size).
+        exceptResultFdArray := Array new:(40 max:exceptArray size).
     ].
 
     nReady := OperatingSystem
-		selectOnAnyReadable:readFdArray
-		writable:writeFdArray
-		exception:exceptArray
-		readableInto:readableResultFdArray
-		writableInto:writableResultFdArray
-		exceptionInto:exceptResultFdArray
-		withTimeOut:millis.
+                selectOnAnyReadable:readFdArray
+                writable:writeFdArray
+                exception:exceptArray
+                readableInto:readableResultFdArray
+                writableInto:writableResultFdArray
+                exceptionInto:exceptResultFdArray
+                withTimeOut:millis.
 
     wasBlocked ifTrue:[
-	OperatingSystem blockInterrupts.
+        OperatingSystem blockInterrupts.
     ].
 
     nReady <= 0 ifTrue:[
-	"/ either still nothing to do,
-	"/ or error (which should not happen)
-
-	(nReady < 0 and:[(err := OperatingSystem lastErrorSymbol) notNil]) ifTrue:[
-	    err == #EBADF ifTrue:[
-		"/ mhmh - one of the fd's given to me is corrupt.
-		"/ find out which one .... and remove it
-		self removeCorruptedFds
-	    ] ifFalse:[
-		err == #ENOENT ifTrue:[
-		    'Processor [warning]: ENOENT in select; rd=' infoPrint.
-		    readFdArray infoPrint. ' wr=' infoPrint. writeFdArray infoPrintCR.
-		] ifFalse:[
-		    'Processor [warning]: error in select: ' infoPrint. err infoPrintCR.
-		]
-	    ].
-	]
+        "/ either still nothing to do,
+        "/ or error (which should not happen)
+
+        (nReady < 0 and:[(err := OperatingSystem lastErrorSymbol) notNil]) ifTrue:[
+            err == #EBADF ifTrue:[
+                "/ mhmh - one of the fd's given to me is corrupt.
+                "/ find out which one .... and remove it
+                self removeCorruptedFds
+            ] ifFalse:[
+                err == #ENOENT ifTrue:[
+                    'Processor [warning]: ENOENT in select; rd=' infoPrint.
+                    readFdArray infoPrint. ' wr=' infoPrint. writeFdArray infoPrintCR.
+                ] ifFalse:[
+                    'Processor [warning]: error in select: ' infoPrint. err infoPrintCR.
+                ]
+            ].
+        ]
     ] ifFalse:[
-	readyIndex := 1.
-	[nReady > 0
-	     and:[ readyIndex <= readableResultFdArray size
-	     and:[ (fd := readableResultFdArray at:readyIndex) notNil ]]
-	] whileTrue:[
-	    index := readFdArray identityIndexOf:fd.
-	    index ~~ 0 ifTrue:[
-		action := readCheckArray at:index.
-		sema := readSemaphoreArray at:index.
-		sema notNil ifTrue:[
-		    sema signalOnce.
-		    newProcessMaybeReady := true.
-		    action isNil ifTrue:[
-			"before May 2014 we disabled the sema in the caller after wakeup.
-			 This caused ST/X to consume 100% cpu, when the caller didn't read
-			 the data (e.g. because his process was stopped)."
-			"disable possible write side and timeouts as well"
-			self disableSemaphore:sema.
-		    ].
-		].
-		(action notNil and:[action value]) ifTrue:[
-		    newProcessMaybeReady := true.
-		].
-	    ].
-	    nReady := nReady - 1.
-	    readyIndex := readyIndex + 1.
-	].
-
-	readyIndex := 1.
-	[nReady > 0
-	     and:[ readyIndex <= writableResultFdArray size
-	     and:[ (fd := writableResultFdArray at:readyIndex) notNil ]]
-	] whileTrue:[
-	    index := writeFdArray identityIndexOf:fd.
-	    index ~~ 0 ifTrue:[
-		action := writeCheckArray at:index.
-		sema := writeSemaphoreArray at:index.
-		sema notNil ifTrue:[
-		    sema signalOnce.
-		    newProcessMaybeReady := true.
-		    action isNil ifTrue:[
-			"now this is a one shot operation - see the input above"
-			"disable possible read side and timeouts as well"
-			self disableSemaphore:sema.
-		    ].
-		].
-		(action notNil and:[action value]) ifTrue:[
-		    newProcessMaybeReady := true.
-		].
-	    ].
-	    nReady := nReady - 1.
-	    readyIndex := readyIndex + 1.
-	].
+        readyIndex := 1.
+        [nReady > 0
+             and:[ readyIndex <= readableResultFdArray size
+             and:[ (fd := readableResultFdArray at:readyIndex) notNil ]]
+        ] whileTrue:[
+            index := readFdArray identityIndexOf:fd.
+            index ~~ 0 ifTrue:[
+                action := readCheckArray at:index.
+                sema := readSemaphoreArray at:index.
+                sema notNil ifTrue:[
+                    sema signalOnce.
+                    newProcessMaybeReady := true.
+                    action isNil ifTrue:[
+                        "before May 2014 we disabled the sema in the caller after wakeup.
+                         This caused ST/X to consume 100% cpu, when the caller didn't read
+                         the data (e.g. because his process was stopped)."
+                        "disable possible write side and timeouts as well"
+                        self disableSemaphore:sema.
+                    ].
+                ].
+                (action notNil and:[action value]) ifTrue:[
+                    newProcessMaybeReady := true.
+                ].
+            ].
+            nReady := nReady - 1.
+            readyIndex := readyIndex + 1.
+        ].
+
+        readyIndex := 1.
+        [nReady > 0
+             and:[ readyIndex <= writableResultFdArray size
+             and:[ (fd := writableResultFdArray at:readyIndex) notNil ]]
+        ] whileTrue:[
+            index := writeFdArray identityIndexOf:fd.
+            index ~~ 0 ifTrue:[
+                action := writeCheckArray at:index.
+                sema := writeSemaphoreArray at:index.
+                sema notNil ifTrue:[
+                    sema signalOnce.
+                    newProcessMaybeReady := true.
+                    action isNil ifTrue:[
+                        "now this is a one shot operation - see the input above"
+                        "disable possible read side and timeouts as well"
+                        self disableSemaphore:sema.
+                    ].
+                ].
+                (action notNil and:[action value]) ifTrue:[
+                    newProcessMaybeReady := true.
+                ].
+            ].
+            nReady := nReady - 1.
+            readyIndex := readyIndex + 1.
+        ].
 
 "/'except result got: ' print. exceptArray printCR. exceptResultFdArray printCR.
-	readyIndex := 1.
-	[nReady > 0
-	     and:[ readyIndex <= exceptResultFdArray size
-	     and:[ (fdOrPid := exceptResultFdArray at:readyIndex) notNil ]]
-	] whileTrue:[
+        readyIndex := 1.
+        [nReady > 0
+             and:[ readyIndex <= exceptResultFdArray size
+             and:[ (fdOrPid := exceptResultFdArray at:readyIndex) notNil ]]
+        ] whileTrue:[
 "/'except got: ' print. fdOrPid printCR.
-	    index := exceptFdArray identityIndexOf:fdOrPid.
-	    index ~~ 0 ifTrue:[
-		sema := exceptSemaphoreArray at:index.
-		sema notNil ifTrue:[
-		    sema signalOnce.
-		    newProcessMaybeReady := true.
-		    "disable possible read/write side and timeouts as well"
-		    self disableSemaphore:sema.
-		].
-	    ] ifFalse:[ "may be a PID?"
-		|osProcessStatus actionBlock|
-
-		actionBlock := osChildExitActions removeKey:fdOrPid ifAbsent:nil.
+            index := exceptFdArray identityIndexOf:fdOrPid.
+            index ~~ 0 ifTrue:[
+                sema := exceptSemaphoreArray at:index.
+                sema notNil ifTrue:[
+                    sema signalOnce.
+                    newProcessMaybeReady := true.
+                    "disable possible read/write side and timeouts as well"
+                    self disableSemaphore:sema.
+                ].
+            ] ifFalse:[ "may be a PID?"
+                |osProcessStatus actionBlock|
+
+                actionBlock := osChildExitActions removeKey:fdOrPid ifAbsent:nil.
 "/'pid signaled: ' print. fdOrPid printCR.
-		actionBlock notNil ifTrue:[
-		    osProcessStatus := OperatingSystem childProcessWait:false pid:fdOrPid.
-		    (osProcessStatus notNil and:[osProcessStatus pid = fdOrPid]) ifTrue:[
-			actionBlock value:osProcessStatus.
-			newProcessMaybeReady := true.
-		    ].
-		].
-	    ].
-	    nReady := nReady - 1.
-	    readyIndex := readyIndex + 1.
-	].
+                actionBlock notNil ifTrue:[
+                    osProcessStatus := OperatingSystem childProcessWait:false pid:fdOrPid.
+                    (osProcessStatus notNil and:[osProcessStatus pid = fdOrPid]) ifTrue:[
+                        actionBlock value:osProcessStatus.
+                        newProcessMaybeReady := true.
+                    ].
+                ].
+            ].
+            nReady := nReady - 1.
+            readyIndex := readyIndex + 1.
+        ].
     ].
     ^ newProcessMaybeReady
 
--- a/ProjectDefinition.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/ProjectDefinition.st	Sun Dec 18 11:19:27 2016 +0000
@@ -2869,6 +2869,7 @@
     "Created: / 18-08-2006 / 12:51:38 / cg"
 ! !
 
+
 !ProjectDefinition class methodsFor:'description - project information'!
 
 applicationAdditionalIconFileNames
@@ -4990,6 +4991,7 @@
     ^ self subProjectMakeCallsUsing:'call vcmake %1 %2'.
 ! !
 
+
 !ProjectDefinition class methodsFor:'file templates'!
 
 autopackage_default_dot_apspec
@@ -5749,7 +5751,7 @@
      of 'super additionalClassAttributesFor: aClass'.
 
      Here, we add #autoload attributes to all test cases and
-     test resources, as they are not neccessary for the package
+     test resources, as they are not necessary for the package
      and should not be compiled (because of unwanted dependency
      on stx:goodies/sunit package)
 
--- a/ProtoObject.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/ProtoObject.st	Sun Dec 18 11:19:27 2016 +0000
@@ -159,6 +159,497 @@
         valueWithReceiver:self
         arguments:{index}
         selector:#instVarAt:
+!
+
+isKindOf:aBehavior
+    "this method is required Behavior>>#allSubInstancesDo:"
+
+    aBehavior == Object ifTrue:[^ true].
+
+    ^ (Object compiledMethodAt:#isKindOf:)
+        valueWithReceiver:self
+        arguments:{aBehavior}
+        selector:#isKindOf:
+!
+
+perform:aSelector
+    "this method is required to allow inspection of the object"
+
+    ^ self perform:aSelector withArguments:#().
+!
+
+perform:aSelector with:arg1 
+    "this method is required to allow inspection of the object"
+
+    ^ self perform:aSelector withArguments:{arg1}.
+!
+
+perform:aSelector with:arg1 with:arg2
+    "this method is required to allow inspection of the object"
+
+    ^ self perform:aSelector withArguments:{arg1. arg2}.
+!
+
+perform:aSelector with:arg1 with:arg2 with:arg3
+    "this method is required to allow inspection of the object"
+
+    ^ self perform:aSelector withArguments:{arg1. arg2. arg3}.
+!
+
+perform:aSelector with:arg1 with:arg2 with:arg3 with:arg4
+    "this method is required to allow inspection of the object"
+
+    ^ self perform:aSelector withArguments:{arg1. arg2. arg3. arg4}.
+!
+
+perform:aSelector with:arg1 with:arg2 with:arg3 with:arg4 with:arg5
+    "this method is required to allow inspection of the object"
+
+    ^ self perform:aSelector withArguments:{arg1. arg2. arg3. arg4. arg5}.
+!
+
+perform:aSelector with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6
+    "this method is required to allow inspection of the object"
+
+    ^ self perform:aSelector withArguments:{arg1. arg2. arg3. arg4. arg5. arg6}.
+!
+
+perform:aSelector withArguments:argArray
+    "send the message aSelector with all args taken from argArray
+     to the receiver.
+
+     1-to-1 Copy from the same method in Object!!"
+
+    |numberOfArgs a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15|
+
+%{
+#ifdef __SCHTEAM__
+    return context.PERFORM_WITH_ARGUMENTS(self, aSelector, argArray);
+#else
+    REGISTER OBJ *argP;
+    int nargs;
+    OBJ l;
+
+    if (__isArrayLike(argArray)) {
+        nargs = __arraySize(argArray);
+        argP = __arrayVal(argArray);
+    } else {
+        if (__isNonNilObject(argArray)) {
+            static struct inlineCache ilcSize = __ILC0(@line);
+            int i;
+
+            numberOfArgs = (*ilcSize.ilc_func)(argArray, @symbol(size), nil, &ilcSize);
+            if (!__isSmallInteger(numberOfArgs))
+                goto bad;
+            nargs = __intVal(numberOfArgs);
+            argP = (OBJ *)(&a1);
+            for (i=1; i <= nargs; i++) {
+                *argP++ = __AT_(argArray, __mkSmallInteger(i));
+            }
+            argP = (OBJ *)(&a1);
+        } else {
+            nargs = 0;
+        }
+    }
+    switch (nargs) {
+        case 0:
+            if (InterruptPending == nil) {
+                static OBJ last0_0 = nil; static struct inlineCache ilc0_0 = __ILCPERF0(@line);
+                static OBJ last0_1 = nil; static struct inlineCache ilc0_1 = __ILCPERF0(@line);
+                static OBJ last0_2 = nil; static struct inlineCache ilc0_2 = __ILCPERF0(@line);
+                static OBJ last0_3 = nil; static struct inlineCache ilc0_3 = __ILCPERF0(@line);
+                static int flip0 = 0;
+                struct inlineCache *pIlc;
+
+                if (aSelector == last0_0) {
+                    pIlc = &ilc0_0;
+                } else if (aSelector == last0_1) {
+                    pIlc = &ilc0_1;
+                } else if (aSelector == last0_2) {
+                    pIlc = &ilc0_2;
+                } else if (aSelector == last0_3) {
+                    pIlc = &ilc0_3;
+                } else {
+                    if (flip0 == 0) {
+                        pIlc = &ilc0_0;
+                        flip0 = 1;
+                        last0_0 = aSelector;
+                    } else if (flip0 == 1) {
+                        pIlc = &ilc0_1;
+                        flip0 = 2;
+                        last0_1 = aSelector;
+                    } else if (flip0 == 2) {
+                        pIlc = &ilc0_2;
+                        flip0 = 3;
+                        last0_2 = aSelector;
+                    } else {
+                        pIlc = &ilc0_3;
+                        flip0 = 0;
+                        last0_3 = aSelector;
+                    }
+
+                    pIlc->ilc_func = __SEND0ADDR__;
+                    if (pIlc->ilc_poly) {
+                        __flushPolyCache(pIlc->ilc_poly);
+                        pIlc->ilc_poly = 0;
+                    }
+                }
+                RETURN ((*pIlc->ilc_func)(self, aSelector, nil, pIlc));
+            } else {
+                static struct inlineCache ilc0 = __DUMMYILCSELF0(@line+1);
+                RETURN (_SEND0(self, aSelector, nil, &ilc0));
+            }
+
+        case 1:
+            if (InterruptPending == nil) {
+                static OBJ last1_0 = nil; static struct inlineCache ilc1_0 = __ILCPERF1(@line);
+                static OBJ last1_1 = nil; static struct inlineCache ilc1_1 = __ILCPERF1(@line);
+                static OBJ last1_2 = nil; static struct inlineCache ilc1_2 = __ILCPERF1(@line);
+                static OBJ last1_3 = nil; static struct inlineCache ilc1_3 = __ILCPERF1(@line);
+                static int flip1 = 0;
+                struct inlineCache *pIlc;
+
+                if (aSelector == last1_0) {
+                    pIlc = &ilc1_0;
+                } else if (aSelector == last1_1) {
+                    pIlc = &ilc1_1;
+                } else if (aSelector == last1_2) {
+                    pIlc = &ilc1_2;
+                } else if (aSelector == last1_3) {
+                    pIlc = &ilc1_3;
+                } else {
+                    if (flip1 == 0) {
+                        pIlc = &ilc1_0;
+                        flip1 = 1;
+                        last1_0 = aSelector;
+                    } else if (flip1 == 1) {
+                        pIlc = &ilc1_1;
+                        flip1 = 2;
+                        last1_1 = aSelector;
+                    } else if (flip1 == 2) {
+                        pIlc = &ilc1_2;
+                        flip1 = 3;
+                        last1_2 = aSelector;
+                    } else {
+                        pIlc = &ilc1_3;
+                        flip1 = 0;
+                        last1_3 = aSelector;
+                    }
+
+                    pIlc->ilc_func = __SEND1ADDR__;
+                    if (pIlc->ilc_poly) {
+                        __flushPolyCache(pIlc->ilc_poly);
+                        pIlc->ilc_poly = 0;
+                    }
+                }
+                RETURN ((*pIlc->ilc_func)(self, aSelector, nil, pIlc, argP[0]));
+            } else {
+                static struct inlineCache ilc1 = __DUMMYILCSELF1(@line+1);
+                RETURN (_SEND1(self, aSelector, nil, &ilc1, argP[0]));
+            }
+
+        case 2:
+            if (InterruptPending == nil) {
+                static OBJ last2_0 = nil; static struct inlineCache ilc2_0 = __ILCPERF2(@line);
+                static OBJ last2_1 = nil; static struct inlineCache ilc2_1 = __ILCPERF2(@line);
+                static int flip2 = 0;
+                struct inlineCache *pIlc;
+
+                if (aSelector == last2_0) {
+                    pIlc = &ilc2_0;
+                } else if (aSelector == last2_1) {
+                    pIlc = &ilc2_1;
+                } else {
+                    if (flip2 == 0) {
+                        pIlc = &ilc2_0;
+                        flip2 = 1;
+                        last2_0 = aSelector;
+                    } else {
+                        pIlc = &ilc2_1;
+                        flip2 = 0;
+                        last2_1 = aSelector;
+                    }
+
+                    pIlc->ilc_func = __SEND2ADDR__;
+                    if (pIlc->ilc_poly) {
+                        __flushPolyCache(pIlc->ilc_poly);
+                        pIlc->ilc_poly = 0;
+                    }
+                }
+                RETURN ((*pIlc->ilc_func)(self, aSelector, nil, pIlc, argP[0], argP[1]));
+            } else {
+                static struct inlineCache ilc2 = __DUMMYILCSELF2(@line+1);
+                RETURN (_SEND2(self, aSelector, nil, &ilc2, argP[0], argP[1]));
+            }
+
+        case 3:
+            if (InterruptPending == nil) {
+                static OBJ last3_0 = nil; static struct inlineCache ilc3_0 = __ILCPERF3(@line);
+                static OBJ last3_1 = nil; static struct inlineCache ilc3_1 = __ILCPERF3(@line);
+                static int flip3 = 0;
+                struct inlineCache *pIlc;
+
+                if (aSelector == last3_0) {
+                    pIlc = &ilc3_0;
+                } else if (aSelector == last3_1) {
+                    pIlc = &ilc3_1;
+                } else {
+                    if (flip3 == 0) {
+                        pIlc = &ilc3_0;
+                        flip3 = 1;
+                        last3_0 = aSelector;
+                    } else {
+                        pIlc = &ilc3_1;
+                        flip3 = 0;
+                        last3_1 = aSelector;
+                    }
+
+                    pIlc->ilc_func = __SEND3ADDR__;
+                    if (pIlc->ilc_poly) {
+                        __flushPolyCache(pIlc->ilc_poly);
+                        pIlc->ilc_poly = 0;
+                    }
+                }
+                RETURN ((*pIlc->ilc_func)(self, aSelector, nil, pIlc, argP[0], argP[1], argP[2]));
+            } else {
+                static struct inlineCache ilc3 = __DUMMYILCSELF3(@line+1);
+                RETURN (_SEND3(self, aSelector, nil, &ilc3, argP[0], argP[1], argP[2]));
+            }
+
+        case 4:
+            {
+                static OBJ last4 = nil; static struct inlineCache ilc4 = __ILCPERF4(@line);
+
+                if ((InterruptPending != nil) || (aSelector != last4)) {
+                    ilc4.ilc_func = __SEND4ADDR__;
+                    if (ilc4.ilc_poly) {
+                        __flushPolyCache(ilc4.ilc_poly);
+                        ilc4.ilc_poly = 0;
+                    }
+                    last4 = aSelector;
+                }
+                RETURN ( (*ilc4.ilc_func)(self, aSelector, nil, &ilc4,
+                                                argP[0], argP[1], argP[2], argP[3]));
+            }
+
+        case 5:
+            {
+                static OBJ last5 = nil; static struct inlineCache ilc5 = __ILCPERF5(@line);
+
+                if ((InterruptPending != nil) || (aSelector != last5)) {
+                    ilc5.ilc_func = __SEND5ADDR__;
+                    if (ilc5.ilc_poly) {
+                        __flushPolyCache(ilc5.ilc_poly);
+                        ilc5.ilc_poly = 0;
+                    }
+                    last5 = aSelector;
+                }
+                RETURN ( (*ilc5.ilc_func)(self, aSelector, nil, &ilc5,
+                                                argP[0], argP[1], argP[2], argP[3], argP[4]));
+            }
+
+        case 6:
+            {
+                static OBJ last6 = nil; static struct inlineCache ilc6 = __ILCPERF6(@line);
+
+                if ((InterruptPending != nil) || (aSelector != last6)) {
+                    ilc6.ilc_func = __SEND6ADDR__;
+                    if (ilc6.ilc_poly) {
+                        __flushPolyCache(ilc6.ilc_poly);
+                        ilc6.ilc_poly = 0;
+                    }
+                    last6 = aSelector;
+                }
+                RETURN ( (*ilc6.ilc_func)(self, aSelector, nil, &ilc6,
+                                                argP[0], argP[1], argP[2], argP[3], argP[4],
+                                                argP[5]));
+            }
+
+        case 7:
+            {
+                static OBJ last7 = nil; static struct inlineCache ilc7 = __ILCPERF7(@line);
+
+                if ((InterruptPending != nil) || (aSelector != last7)) {
+                    ilc7.ilc_func = __SEND7ADDR__;
+                    if (ilc7.ilc_poly) {
+                        __flushPolyCache(ilc7.ilc_poly);
+                        ilc7.ilc_poly = 0;
+                    }
+                    last7 = aSelector;
+                }
+                RETURN ( (*ilc7.ilc_func)(self, aSelector, nil, &ilc7,
+                                                argP[0], argP[1], argP[2], argP[3], argP[4],
+                                                argP[5], argP[6]));
+            }
+
+        case 8:
+            {
+                static OBJ last8 = nil; static struct inlineCache ilc8 = __ILCPERF8(@line);
+
+                if ((InterruptPending != nil) || (aSelector != last8)) {
+                    ilc8.ilc_func = __SEND8ADDR__;
+                    if (ilc8.ilc_poly) {
+                        __flushPolyCache(ilc8.ilc_poly);
+                        ilc8.ilc_poly = 0;
+                    }
+                    last8 = aSelector;
+                }
+                RETURN ( (*ilc8.ilc_func)(self, aSelector, nil, &ilc8,
+                                                argP[0], argP[1], argP[2], argP[3], argP[4],
+                                                argP[5], argP[6], argP[7]));
+            }
+
+        case 9:
+            {
+                static OBJ last9 = nil; static struct inlineCache ilc9 = __ILCPERF9(@line);
+
+                if ((InterruptPending != nil) || (aSelector != last9)) {
+                    ilc9.ilc_func = __SEND9ADDR__;
+                    if (ilc9.ilc_poly) {
+                        __flushPolyCache(ilc9.ilc_poly);
+                        ilc9.ilc_poly = 0;
+                    }
+                    last9 = aSelector;
+                }
+                RETURN ( (*ilc9.ilc_func)(self, aSelector, nil, &ilc9,
+                                                argP[0], argP[1], argP[2], argP[3], argP[4],
+                                                argP[5], argP[6], argP[7], argP[8]));
+            }
+
+        case 10:
+            {
+                static OBJ last10 = nil; static struct inlineCache ilc10 = __ILCPERF10(@line);
+
+                if ((InterruptPending != nil) || (aSelector != last10)) {
+                    ilc10.ilc_func = __SEND10ADDR__;
+                    if (ilc10.ilc_poly) {
+                        __flushPolyCache(ilc10.ilc_poly);
+                        ilc10.ilc_poly = 0;
+                    }
+                    last10 = aSelector;
+                }
+                RETURN ( (*ilc10.ilc_func)(self, aSelector, nil, &ilc10,
+                                                argP[0], argP[1], argP[2], argP[3], argP[4],
+                                                argP[5], argP[6], argP[7], argP[8], argP[9]));
+            }
+
+        case 11:
+            {
+                static OBJ last11 = nil; static struct inlineCache ilc11 = __ILCPERF11(@line);
+
+                if ((InterruptPending != nil) || (aSelector != last11)) {
+                    ilc11.ilc_func = __SEND11ADDR__;
+                    if (ilc11.ilc_poly) {
+                        __flushPolyCache(ilc11.ilc_poly);
+                        ilc11.ilc_poly = 0;
+                    }
+                    last11 = aSelector;
+                }
+                RETURN ( (*ilc11.ilc_func)(self, aSelector, nil, &ilc11,
+                                                argP[0], argP[1], argP[2], argP[3], argP[4],
+                                                argP[5], argP[6], argP[7], argP[8], argP[9],
+                                                argP[10]));
+            }
+
+        case 12:
+            {
+                static OBJ last12 = nil; static struct inlineCache ilc12 = __ILCPERF12(@line);
+
+                if ((InterruptPending != nil) || (aSelector != last12)) {
+                    ilc12.ilc_func = __SEND12ADDR__;
+                    if (ilc12.ilc_poly) {
+                        __flushPolyCache(ilc12.ilc_poly);
+                        ilc12.ilc_poly = 0;
+                    }
+                    last12 = aSelector;
+                }
+                RETURN ( (*ilc12.ilc_func)(self, aSelector, nil, &ilc12,
+                                                argP[0], argP[1], argP[2], argP[3], argP[4],
+                                                argP[5], argP[6], argP[7], argP[8], argP[9],
+                                                argP[10], argP[11]));
+            }
+
+        case 13:
+            {
+                static OBJ last13 = nil; static struct inlineCache ilc13 = __ILCPERF13(@line);
+
+                if ((InterruptPending != nil) || (aSelector != last13)) {
+                    ilc13.ilc_func = __SEND13ADDR__;
+                    if (ilc13.ilc_poly) {
+                        __flushPolyCache(ilc13.ilc_poly);
+                        ilc13.ilc_poly = 0;
+                    }
+                    last13 = aSelector;
+                }
+                RETURN ( (*ilc13.ilc_func)(self, aSelector, nil, &ilc13,
+                                                argP[0], argP[1], argP[2], argP[3], argP[4],
+                                                argP[5], argP[6], argP[7], argP[8], argP[9],
+                                                argP[10], argP[11], argP[12]));
+            }
+
+        case 14:
+            {
+                static OBJ last14 = nil; static struct inlineCache ilc14 = __ILCPERF14(@line);
+
+                if ((InterruptPending != nil) || (aSelector != last14)) {
+                    ilc14.ilc_func = __SEND14ADDR__;
+                    if (ilc14.ilc_poly) {
+                        __flushPolyCache(ilc14.ilc_poly);
+                        ilc14.ilc_poly = 0;
+                    }
+                    last14 = aSelector;
+                }
+                RETURN ( (*ilc14.ilc_func)(self, aSelector, nil, &ilc14,
+                                                argP[0], argP[1], argP[2], argP[3], argP[4],
+                                                argP[5], argP[6], argP[7], argP[8], argP[9],
+                                                argP[10], argP[11], argP[12], argP[13]));
+            }
+
+        case 15:
+            {
+                static OBJ last15 = nil; static struct inlineCache ilc15 = __ILCPERF15(@line);
+
+                if ((InterruptPending != nil) || (aSelector != last15)) {
+                    ilc15.ilc_func = __SEND15ADDR__;
+                    if (ilc15.ilc_poly) {
+                        __flushPolyCache(ilc15.ilc_poly);
+                        ilc15.ilc_poly = 0;
+                    }
+                    last15 = aSelector;
+                }
+                RETURN ( (*ilc15.ilc_func)(self, aSelector, nil, &ilc15,
+                                                argP[0], argP[1], argP[2], argP[3], argP[4],
+                                                argP[5], argP[6], argP[7], argP[8], argP[9],
+                                                argP[10], argP[11], argP[12], argP[13],
+                                                argP[14]));
+            }
+    }
+bad:;
+#endif
+%}.
+
+    "/ arrive here, if bad number of arguments (too many)
+    "/ ST/X (currently) only allows up to 15 method arguments
+
+    ^ self primitiveFailed
+!
+
+referencesAny:anObject
+    "this method is required to allow inspection of the object"
+
+    ^ (Object compiledMethodAt:#referencesAny:)
+        valueWithReceiver:self
+        arguments:{anObject}
+        selector:#referencesAny
+!
+
+referencesObject:anObject
+    "this method is required to allow inspection of the object"
+
+    ^ (Object compiledMethodAt:#referencesObject:)
+        valueWithReceiver:self
+        arguments:{anObject}
+        selector:#referencesObject
 ! !
 
 !ProtoObject methodsFor:'queries'!
--- a/ReadStream.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/ReadStream.st	Sun Dec 18 11:19:27 2016 +0000
@@ -428,69 +428,6 @@
     ^ ret
 !
 
-nextDecimalInteger
-    "read the next integer in radix 10.
-     Does NOT skip initial whitespace.
-     The streams elements should be characters.
-
-     Be careful - this method returns 0 if not positioned on a digit intitially
-     or if the end of the stream is encountered.
-
-     Tuned for speed on String-Streams for faster scanning"
-
-    |value nextOne|
-%{
-    INT pos, limit, sz;
-    REGISTER unsigned char *cp;
-    REGISTER unsigned ch;
-    INT val = 0;
-    OBJ coll, p, l;
-
-    coll = __INST(collection);
-    p = __INST(position);
-    l = __INST(readLimit);
-
-    if (__isStringLike(coll) && __bothSmallInteger(p, l)) {
-
-	pos = __intVal(p);
-	/* make 1-based */
-	pos++;
-	limit = __intVal(l);
-	sz = __qSize(coll) - OHDR_SIZE;
-	if (sz < limit)
-	    limit = sz;
-	cp = __stringVal(coll) + pos - 1;
-
-	for (;;) {
-	    if (pos > limit) break;
-	    ch = *cp;
-
-	    if ((ch < '0') || (ch > '9')) break;
-	    val = val * 10 + (ch - '0');
-	    pos++;
-	    if (val > (_MAX_INT / 10)) goto oops;
-	    cp++;
-	}
-	pos--;
-	__INST(position) = __mkSmallInteger(pos);
-	RETURN (__mkSmallInteger(val));
-    }
-oops:
-    value = __mkSmallInteger(val);
-%}
-.
-    "fall-back for non-string streams - we have to continue where
-     above primitive left off, in case of a large integer ...
-     (instead of doing a super nextDecimalInteger)"
-
-    nextOne := self peek.
-    [nextOne notNil and:[nextOne isDigitRadix:10]] whileTrue:[
-	value := (value * 10) + nextOne digitValue.
-	nextOne := self nextPeek
-    ].
-    ^ value
-!
-
 nextOrNil
     "return the next element; advance read pointer.
      return nil, if there is no next element.
@@ -950,6 +887,71 @@
     ^ super upTo:anObject
 ! !
 
+!ReadStream methodsFor:'reading-numbers'!
+
+nextDecimalInteger
+    "read the next integer in radix 10.
+     Does NOT skip initial whitespace.
+     The streams elements should be characters.
+
+     Be careful - this method returns 0 if not positioned on a digit intitially
+     or if the end of the stream is encountered.
+
+     Tuned for speed on String-Streams for faster scanning"
+
+    |value nextOne|
+%{
+    INT pos, limit, sz;
+    REGISTER unsigned char *cp;
+    REGISTER unsigned ch;
+    INT val = 0;
+    OBJ coll, p, l;
+
+    coll = __INST(collection);
+    p = __INST(position);
+    l = __INST(readLimit);
+
+    if (__isStringLike(coll) && __bothSmallInteger(p, l)) {
+
+	pos = __intVal(p);
+	/* make 1-based */
+	pos++;
+	limit = __intVal(l);
+	sz = __qSize(coll) - OHDR_SIZE;
+	if (sz < limit)
+	    limit = sz;
+	cp = __stringVal(coll) + pos - 1;
+
+	for (;;) {
+	    if (pos > limit) break;
+	    ch = *cp;
+
+	    if ((ch < '0') || (ch > '9')) break;
+	    val = val * 10 + (ch - '0');
+	    pos++;
+	    if (val > (_MAX_INT / 10)) goto oops;
+	    cp++;
+	}
+	pos--;
+	__INST(position) = __mkSmallInteger(pos);
+	RETURN (__mkSmallInteger(val));
+    }
+oops:
+    value = __mkSmallInteger(val);
+%}
+.
+    "fall-back for non-string streams - we have to continue where
+     above primitive left off, in case of a large integer ...
+     (instead of doing a super nextDecimalInteger)"
+
+    nextOne := self peek.
+    [nextOne notNil and:[nextOne isDigitRadix:10]] whileTrue:[
+	value := (value * 10) + nextOne digitValue.
+	nextOne := self nextPeek
+    ].
+    ^ value
+! !
+
 !ReadStream methodsFor:'writing'!
 
 nextPut:anElement
--- a/ReadWriteStream.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/ReadWriteStream.st	Sun Dec 18 11:19:27 2016 +0000
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
@@ -102,16 +100,6 @@
         ].
     ].
     ^ super next:count
-!
-
-peek
-    "return the element to be read next without advancing read position.
-     If there are no more elements, nil is returned."
-
-    (position >= readLimit) ifTrue:[^ self pastEndRead].
-    ^ collection at:(position+1)
-
-    "Modified: 5.2.1996 / 21:57:47 / stefan"
 ! !
 
 !ReadWriteStream methodsFor:'accessing'!
@@ -198,6 +186,18 @@
     ^ (readLimit ? 0) max:(position ? 0).
 ! !
 
+!ReadWriteStream methodsFor:'reading'!
+
+peek
+    "return the element to be read next without advancing read position.
+     If there are no more elements, nil is returned."
+
+    (position >= readLimit) ifTrue:[^ self pastEndRead].
+    ^ collection at:(position+1)
+
+    "Modified: 5.2.1996 / 21:57:47 / stefan"
+! !
+
 !ReadWriteStream class methodsFor:'documentation'!
 
 version
--- a/Semaphore.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/Semaphore.st	Sun Dec 18 11:19:27 2016 +0000
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1993 by Claus Gittinger
 	      All Rights Reserved
@@ -1016,7 +1014,8 @@
     |millis|
 
     secondsOrNilOrTimeDuration notNil ifTrue:[
-        millis := secondsOrNilOrTimeDuration asFloat * 1000
+        "asFloat converts a TimeDuration to a Float"
+        millis := (secondsOrNilOrTimeDuration asFloat * 1000) asInteger
     ].
     ^ self waitWithTimeoutMs:millis.
 !
--- a/SmallInteger.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/SmallInteger.st	Sun Dec 18 11:19:27 2016 +0000
@@ -209,6 +209,7 @@
     "Modified: 23.4.1996 / 16:00:33 / cg"
 ! !
 
+
 !SmallInteger methodsFor:'arithmetic'!
 
 * aNumber
@@ -5239,6 +5240,13 @@
      9 nextPowerOf2
 
      22 nextPowerOf2
+     32 nextPowerOf2
+     16rFFFF nextPowerOf2 = 16r10000 
+     16rFFFFFFFF nextPowerOf2 = 16r100000000 
+     16r1FFFFFFFFFFFFFFF nextPowerOf2 = 16r2000000000000000 
+     16r3FFFFFFFFFFFFFFF nextPowerOf2 = 16r4000000000000000 
+     16r7FFFFFFFFFFFFFFF nextPowerOf2 = 16r8000000000000000 
+     16rFFFFFFFFFFFFFFFF nextPowerOf2 = 16r10000000000000000 
      10 factorial nextPowerOf2
      20 factorial nextPowerOf2
      100 factorial nextPowerOf2
--- a/Smalltalk.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/Smalltalk.st	Sun Dec 18 11:19:27 2016 +0000
@@ -2075,24 +2075,25 @@
 allClassesAndMetaclassesDo:aBlock
     "evaluate the argument, aBlock for all classes and metaclasses in the system."
 
-    |already|
-
-    already := IdentitySet new:NumberOfClassesHint*2.
+    |already numClassesHintTimes2|
+
+    numClassesHintTimes2 := NumberOfClassesHint*2.
+    already := IdentitySet new:numClassesHintTimes2.
     self allClassesDo:[:eachClass |
-        |cls|
-
-        cls := eachClass theNonMetaclass.
-        (already includes:cls) ifFalse:[
-            aBlock value:cls.
-            already add:cls.
+        |theNonMeta theMeta|
+
+        theNonMeta := eachClass theNonMetaclass.
+        (already includes:theNonMeta) ifFalse:[
+            aBlock value:theNonMeta.
+            already add:theNonMeta.
         ].
-        cls := cls class.
-        (already includes:cls) ifFalse:[
-            aBlock value:cls.
-            already add:cls.
+        theMeta := theNonMeta class.
+        (already includes:theMeta) ifFalse:[
+            aBlock value:theMeta.
+            already add:theMeta.
         ].
-        already size > (NumberOfClassesHint * 2) ifTrue:[
-            NumberOfClassesHint := (already size // 2) + 1
+        already size > numClassesHintTimes2 ifTrue:[
+            NumberOfClassesHint := (already size // 2) + 10
         ].    
     ].
 !
--- a/Stream.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/Stream.st	Sun Dec 18 11:19:27 2016 +0000
@@ -3244,42 +3244,6 @@
     "Modified: 11.1.1997 / 19:09:06 / cg"
 !
 
-skipUntil:aBlock
-    "skip all elements for which aBlock returns false.
-     Return true if more elements can be read, false if eof has been reached."
-
-    [self atEnd] whileFalse:[
-        (aBlock value: self peek) ifTrue:[^ true].
-        self next
-    ].
-    ^ false
-
-    "
-     #(1 2 3 4 5 6 7 8 9 10) readStream
-        skipUntil:[:el | el >= 5];
-        next
-    "
-!
-
-skipWhile:aBlock
-    "skip all elements for which aBlock returns true. Return true if more elements can be read,
-     false if eof has been reached."
-
-    [self atEnd] whileFalse:[
-	(aBlock value: self peek) ifFalse:[^ true].
-	self next
-    ].
-    ^ false
-
-    "
-     #(1 2 3 4 5 6 7 8 9 10) readStream
-	skipWhile:[:el | el <= 5];
-	next
-    "
-
-    "Created: / 23-09-2011 / 13:32:40 / cg"
-!
-
 through:anObject
     "read a collection of all objects up-to anObject and return these
      elements, including anObject.
@@ -3330,16 +3294,15 @@
      If aCollection is not encountered, all elements up to the end are read
      and returned."
 
-    |answerStream element last rslt|
+    |answerStream element last|
 
     last := aCollection last.
     answerStream := WriteStream on:(self contentsSpecies new).
-    [self atEnd] whileFalse:[
-        element := self next.
+    [(element := self nextOrNil) isNil and:[self atEnd]] whileFalse:[
         answerStream nextPut:element.
         element == last ifTrue:[
-            ((rslt := answerStream contents) endsWith:aCollection) ifTrue:[
-                ^ rslt
+            (answerStream endsWith:aCollection) ifTrue:[
+                ^ answerStream contents
             ]
         ].
     ].
@@ -3521,10 +3484,10 @@
 
     last := aCollection last.
     answerStream := ReadWriteStream on:(self contentsSpecies new).
-    [(element := self nextOrNil) notNil] whileTrue:[
+    [(element := self nextOrNil) isNil and:[self atEnd]] whileFalse:[
         answerStream nextPut:element.
         element == last ifTrue:[
-            (answerStream contents endsWith:aCollection) ifTrue:[
+            (answerStream endsWith:aCollection) ifTrue:[
                 |pos|
                 pos := answerStream position.
                 answerStream reset.
@@ -3545,99 +3508,6 @@
     "Created: / 15.6.1998 / 19:11:31 / cg"
 !
 
-upToAny:aCollectionOfObjects
-    "read a collection of all objects up-to a element which is contained in
-     aCollectionOfObjects and return these elements, but excluding the matching one.
-     The next read operation will return the element AFTER anObject.
-     If no such element is encountered, all elements up to the end are read
-     and returned.
-     Compare this with #throughAll: which also reads up to some object
-     and also positions behind it, but DOES include it in the returned
-     value."
-
-    |result|
-
-    result := self upToBeforeAny:aCollectionOfObjects.
-    self atEnd ifFalse:[
-        self next.
-    ].
-    ^ result
-
-    "
-     |s|
-     s := ReadStream on:'hello world'.
-     Transcript showCR:(s upToAny:(Array with:Character space)).
-     Transcript showCR:(s upToEnd)
-
-     'Makefile' asFilename readStream upToAny:($A to:$Z)
-    "
-
-    "Created: / 30.8.1997 / 03:02:05 / cg"
-    "Modified: / 11.1.1998 / 15:19:18 / cg"
-!
-
-upToBeforeAny:aCollectionOfObjects
-    "read a collection of all objects up-to a element which is contained in
-     aCollectionOfObjects and return these elements, but excluding the matching one.
-     The next read operation will return the matching element.
-     If no such element is encountered, all elements up to the end are read
-     and returned.
-     This returns the exact same as upToAny: would, but leaves the stream's position so that
-     the next read returns the matching delimiter instead of skipping it.
-     Caveat: this is the one which should have been called upTo: in the first place;
-     however, it seems now too late for a change."
-
-    |answerStream element|
-
-    answerStream := WriteStream on:(self contentsSpecies new).
-    [self atEnd] whileFalse:[
-        element := self peek.
-        (aCollectionOfObjects includes:element) ifTrue: [
-            ^ answerStream contents
-        ].
-        answerStream nextPut:element.
-        self next.
-    ].
-    ^ answerStream contents
-
-    "
-     |s|
-     s := ReadStream on:'hello world'.
-     Transcript showCR:(s upToBeforeAny:(Array with:Character space)).
-     Transcript showCR:(s upToEnd)
-
-     'Make.proto' asFilename readStream upToBeforeAny:($A to:$Z)
-    "
-
-    "Created: / 30.8.1997 / 03:02:05 / cg"
-    "Modified: / 11.1.1998 / 15:19:18 / cg"
-!
-
-upToElementForWhich:aBlock
-    "read elements until aBlock returns true for an element.
-     Return the collected elements excluding that element.
-     Leave the stream positioned for the next read to return that element.
-     If no element matches, all elements up to the end are returned"
-
-    |answerStream next|
-
-    answerStream := WriteStream on:(self contentsSpecies new).
-
-    [
-        self atEnd
-        or:[ (aBlock value: (next := self peek)) ]
-    ] whileFalse:[
-        answerStream nextPut:next.
-        self next.
-    ].
-    ^ answerStream contents
-
-    "
-     #(1 2 3 4 5 6 7 8 9 10) readStream
-        upToElementForWhich:[:el | el > 5]
-    "
-!
-
 upToEnd
     "return a collection of the elements up-to the end.
      Return an empty collection, if the stream-end is already at the end."
--- a/Symbol.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/Symbol.st	Sun Dec 18 11:19:27 2016 +0000
@@ -788,57 +788,6 @@
 
 !Symbol methodsFor:'queries'!
 
-isInfix
-    "return true, if the receiver is a binary message selector"
-
-    ^ self first isLetterOrDigit not
-
-    "
-     #at:put: isInfix
-     #at: isInfix
-     #+ isInfix
-     #size isInfix
-    "
-
-    "Created: / 1.11.1997 / 12:34:55 / cg"
-    "Modified: / 1.11.1997 / 12:36:37 / cg"
-!
-
-isKeyword
-    "return true, if the receiver is a keyword message selector.
-     This is a quick check, which only looks at the last character.
-     Should only be used, if we already know that the receiver forms a valid selector.
-     To check an arbitrary string, use isKeywordSelector.
-     Bad naming, but compatibility is asking for it."
-
-    ^ self last == $:
-
-    "
-     #at:put: isKeyword
-     #at: isKeyword
-     #+ isKeyword
-     #size isKeyword
-    "
-
-    "Created: / 01-11-1997 / 12:34:55 / cg"
-    "Modified (comment): / 30-04-2016 / 18:19:11 / cg"
-!
-
-isSymbol
-    "return true, if the receiver is some kind of symbol.
-     Since I am a symbol, return always true"
-
-    ^ true
-!
-
-isUnary
-    "Answer true if the receiver is a unary selector.
-     That is not a check for being a valid selector, but instead relies on
-     the selector being valid."
-
-    ^ self isUnarySelector
-!
-
 species
     "when copying, or concatenating, return instances of this class"
 
@@ -906,6 +855,13 @@
      Must replace foo isMemberOf:String and foo class == String"
 
     ^ false
+!
+
+isSymbol
+    "return true, if the receiver is some kind of symbol.
+     Since I am a symbol, return always true"
+
+    ^ true
 ! !
 
 !Symbol methodsFor:'tracing'!
--- a/UserPreferences.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/UserPreferences.st	Sun Dec 18 11:19:27 2016 +0000
@@ -2079,7 +2079,7 @@
 
     "/ read comment in menuPanel - for now, it should be on,
     "/ otherwise you cannot control a menu with cursor keys or escape. sigh.
-    ^ self at:#menuPanelTakesFocusOnClick ifAbsent:[ false ]
+    ^ self at:#menuPanelTakesFocusOnClick ifAbsent:[ true "false" ]
 
     "
      UserPreferences current menuPanelTakesFocusOnClick
--- a/Win32OperatingSystem.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/Win32OperatingSystem.st	Sun Dec 18 11:19:27 2016 +0000
@@ -2115,6 +2115,11 @@
                 typ = @symbol(existingReferentSignal);
                 break;
 
+            case ERROR_ALREADY_EXISTS:
+                sym = @symbol(ERROR_ALREADY_EXISTS);
+                typ = @symbol(existingReferentSignal);
+                break;
+
             default:
                 break;
         }
@@ -2775,212 +2780,222 @@
      */
 #ifdef ERROR_INVALID_FUNCTION
     if (sym == @symbol(ERROR_INVALID_FUNCTION)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_INVALID_FUNCTION)) );
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_INVALID_FUNCTION)) );
     }
 #endif
 #ifdef ERROR_BAD_FORMAT
     if (sym == @symbol(ERROR_BAD_FORMAT)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_BAD_FORMAT)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_BAD_FORMAT)));
     }
 #endif
 #ifdef ERROR_FILE_NOT_FOUND
     if (sym == @symbol(ERROR_FILE_NOT_FOUND)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_FILE_NOT_FOUND)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_FILE_NOT_FOUND)));
     }
 #endif
 #ifdef ERROR_PATH_NOT_FOUND
     if (sym == @symbol(ERROR_PATH_NOT_FOUND)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_PATH_NOT_FOUND)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_PATH_NOT_FOUND)));
     }
 #endif
 #ifdef ERROR_TOO_MANY_OPEN_FILES
     if (sym == @symbol(ERROR_TOO_MANY_OPEN_FILES)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_TOO_MANY_OPEN_FILES)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_TOO_MANY_OPEN_FILES)));
     }
 #endif
 #ifdef ERROR_OPEN_FAILED
     if (sym == @symbol(ERROR_OPEN_FAILED)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_OPEN_FAILED)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_OPEN_FAILED)));
     }
 #endif
 #ifdef ERROR_ACCESS_DENIED
     if (sym == @symbol(ERROR_ACCESS_DENIED)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_ACCESS_DENIED)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_ACCESS_DENIED)));
     }
 #endif
 #ifdef ERROR_INVALID_HANDLE
     if (sym == @symbol(ERROR_INVALID_HANDLE)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_INVALID_HANDLE)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_INVALID_HANDLE)));
     }
 #endif
 #ifdef ERROR_NOT_ENOUGH_MEMORY
     if (sym == @symbol(ERROR_NOT_ENOUGH_MEMORY)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NOT_ENOUGH_MEMORY)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NOT_ENOUGH_MEMORY)));
     }
 #endif
 #ifdef ERROR_NO_SYSTEM_RESOURCES
     if (sym == @symbol(ERROR_NO_SYSTEM_RESOURCES)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NO_SYSTEM_RESOURCES)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NO_SYSTEM_RESOURCES)));
     }
 #endif
 #ifdef ERROR_INVALID_ACCESS
     if (sym == @symbol(ERROR_INVALID_ACCESS)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_INVALID_ACCESS)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_INVALID_ACCESS)));
     }
 #endif
 #ifdef ERROR_INVALID_DATA
     if (sym == @symbol(ERROR_INVALID_DATA)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_INVALID_DATA)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_INVALID_DATA)));
     }
 #endif
 #ifdef ERROR_INVALID_NAME
     if (sym == @symbol(ERROR_INVALID_NAME)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_INVALID_NAME)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_INVALID_NAME)));
     }
 #endif
 #ifdef ERROR_ARENA_TRASHED
     if (sym == @symbol(ERROR_ARENA_TRASHED)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_ARENA_TRASHED)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_ARENA_TRASHED)));
     }
 #endif
 #ifdef ERROR_OUTOFMEMORY
     if (sym == @symbol(ERROR_OUTOFMEMORY)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_OUTOFMEMORY)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_OUTOFMEMORY)));
     }
 #endif
 #ifdef ERROR_BROKEN_PIPE
     if (sym == @symbol(ERROR_BROKEN_PIPE)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_BROKEN_PIPE)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_BROKEN_PIPE)));
     }
 #endif
 #ifdef ERROR_GEN_FAILURE
     if (sym == @symbol(ERROR_GEN_FAILURE)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_GEN_FAILURE)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_GEN_FAILURE)));
     }
 #endif
 #ifdef ERROR_WRITE_PROTECT
     if (sym == @symbol(ERROR_WRITE_PROTECT)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_WRITE_PROTECT)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_WRITE_PROTECT)));
     }
 #endif
 #ifdef ERROR_WRITE_FAULT
     if (sym == @symbol(ERROR_WRITE_FAULT)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_WRITE_FAULT)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_WRITE_FAULT)));
     }
 #endif
 #ifdef ERROR_READ_FAULT
     if (sym == @symbol(ERROR_READ_FAULT)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_READ_FAULT)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_READ_FAULT)));
     }
 #endif
 #ifdef ERROR_HANDLE_DISK_FULL
     if (sym == @symbol(ERROR_HANDLE_DISK_FULL)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_HANDLE_DISK_FULL)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_HANDLE_DISK_FULL)));
     }
 #endif
 #ifdef ERROR_DISK_FULL
     if (sym == @symbol(ERROR_DISK_FULL)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_DISK_FULL)));
-    }
-#endif
-#ifdef ERROR_ERROR_SHARING_VIOLATION
-    if (sym == @symbol(ERROR_ERROR_SHARING_VIOLATION)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_ERROR_SHARING_VIOLATION)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_DISK_FULL)));
+    }
+#endif
+#ifdef ERROR_SHARING_VIOLATION
+    if (sym == @symbol(ERROR_SHARING_VIOLATION)) {
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_SHARING_VIOLATION)));
     }
 #endif
 #ifdef ERROR_LOCK_VIOLATION
     if (sym == @symbol(ERROR_LOCK_VIOLATION)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_LOCK_VIOLATION)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_LOCK_VIOLATION)));
     }
 #endif
 #ifdef ERROR_INVALID_PARAMETER
     if (sym == @symbol(ERROR_INVALID_PARAMETER)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_INVALID_PARAMETER)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_INVALID_PARAMETER)));
     }
 #endif
 #ifdef ERROR_NET_WRITE_FAULT
     if (sym == @symbol(ERROR_NET_WRITE_FAULT)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NET_WRITE_FAULT)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NET_WRITE_FAULT)));
     }
 #endif
 #ifdef ERROR_NOT_SUPPORTED
     if (sym == @symbol(ERROR_NOT_SUPPORTED)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NOT_SUPPORTED)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NOT_SUPPORTED)));
     }
 #endif
 #ifdef ERROR_REM_NOT_LIST
     if (sym == @symbol(ERROR_REM_NOT_LIST)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_REM_NOT_LIST)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_REM_NOT_LIST)));
     }
 #endif
 #ifdef ERROR_NETWORK_ACCESS_DENIED
     if (sym == @symbol(ERROR_NETWORK_ACCESS_DENIED)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NETWORK_ACCESS_DENIED)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NETWORK_ACCESS_DENIED)));
     }
 #endif
 #ifdef ERROR_DUP_NAME
     if (sym == @symbol(ERROR_DUP_NAME)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_DUP_NAME)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_DUP_NAME)));
     }
 #endif
 #ifdef ERROR_BAD_NETPATH
     if (sym == @symbol(ERROR_BAD_NETPATH)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_BAD_NETPATH)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_BAD_NETPATH)));
     }
 #endif
 #ifdef ERROR_NETWORK_BUSY
     if (sym == @symbol(ERROR_NETWORK_BUSY)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NETWORK_BUSY)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NETWORK_BUSY)));
     }
 #endif
 #ifdef ERROR_DRIVE_LOCKED
     if (sym == @symbol(ERROR_DRIVE_LOCKED)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_DRIVE_LOCKED)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_DRIVE_LOCKED)));
     }
 #endif
 #ifdef ERROR_INVALID_DRIVE
     if (sym == @symbol(ERROR_INVALID_DRIVE)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_INVALID_DRIVE)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_INVALID_DRIVE)));
     }
 #endif
 #ifdef ERROR_WRONG_DISK
     if (sym == @symbol(ERROR_WRONG_DISK)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_WRONG_DISK)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_WRONG_DISK)));
     }
 #endif
 #ifdef ERROR_CURRENT_DIRECTORY
     if (sym == @symbol(ERROR_CURRENT_DIRECTORY)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_CURRENT_DIRECTORY)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_CURRENT_DIRECTORY)));
+    }
+#endif
+#ifdef ERROR_FILE_EXISTS
+    if (sym == @symbol(ERROR_FILE_EXISTS)) {
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_FILE_EXISTS)));
+    }
+#endif
+#ifdef ERROR_ALREADY_EXISTS
+    if (sym == @symbol(ERROR_FILE_EXISTS)) {
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_ALREADY_EXISTS)));
     }
 #endif
 #ifdef ERROR_CANNOT_MAKE
     if (sym == @symbol(ERROR_CANNOT_MAKE)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_CANNOT_MAKE)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_CANNOT_MAKE)));
     }
 #endif
 #ifdef ERROR_NO_MORE_FILES
     if (sym == @symbol(ERROR_NO_MORE_FILES)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NO_MORE_FILES)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NO_MORE_FILES)));
     }
 #endif
 #ifdef ERROR_NOT_READY
     if (sym == @symbol(ERROR_NOT_READY)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NOT_READY)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NOT_READY)));
     }
 #endif
 #ifdef ERROR_NOT_DOS_DISK
     if (sym == @symbol(ERROR_NOT_DOS_DISK)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NOT_DOS_DISK)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_NOT_DOS_DISK)));
     }
 #endif
 #ifdef ERROR_OUT_OF_PAPER
     if (sym == @symbol(ERROR_OUT_OF_PAPER)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_OUT_OF_PAPER)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_OUT_OF_PAPER)));
     }
 #endif
 #ifdef ERROR_PRINTQ_FULL
     if (sym == @symbol(ERROR_PRINTQ_FULL)) {
-	RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_PRINTQ_FULL)));
+        RETURN ( __mkSmallInteger(__WIN32_ERR(ERROR_PRINTQ_FULL)));
     }
 #endif
 
@@ -2989,229 +3004,229 @@
      */
 #ifdef EPERM
     if (sym == @symbol(EPERM)) {
-	RETURN ( __mkSmallInteger(EPERM) );
+        RETURN ( __mkSmallInteger(EPERM) );
     }
 #endif
 
 #ifdef ENOENT
     if (sym == @symbol(ENOENT)) {
-	RETURN ( __mkSmallInteger(ENOENT) );
-    }
-#endif
+        RETURN ( __mkSmallInteger(ENOENT) );
+    }
+#endif                                               
 
 #ifdef ESRCH
     if (sym == @symbol(ESRCH)) {
-	RETURN ( __mkSmallInteger(ESRCH) );
+        RETURN ( __mkSmallInteger(ESRCH) );
     }
 #endif
 
 #ifdef EINTR
     if (sym == @symbol(EINTR)) {
-	RETURN ( __mkSmallInteger(EINTR) );
+        RETURN ( __mkSmallInteger(EINTR) );
     }
 #endif
 
 #ifdef EIO
     if (sym == @symbol(EIO)) {
-	RETURN ( __mkSmallInteger(EIO) );
+        RETURN ( __mkSmallInteger(EIO) );
     }
 #endif
 
 #ifdef ENXIO
     if (sym == @symbol(ENXIO)) {
-	RETURN ( __mkSmallInteger(ENXIO) );
+        RETURN ( __mkSmallInteger(ENXIO) );
     }
 #endif
 
 #ifdef E2BIG
     if (sym == @symbol(E2BIG)) {
-	RETURN ( __mkSmallInteger(E2BIG) );
+        RETURN ( __mkSmallInteger(E2BIG) );
     }
 #endif
 
 #ifdef ENOEXEC
     if (sym == @symbol(ENOEXEC)) {
-	RETURN ( __mkSmallInteger(ENOEXEC) );
+        RETURN ( __mkSmallInteger(ENOEXEC) );
     }
 #endif
 
 #ifdef EBADF
     if (sym == @symbol(EBADF)) {
-	RETURN ( __mkSmallInteger(EBADF) );
+        RETURN ( __mkSmallInteger(EBADF) );
     }
 #endif
 
 #ifdef ECHILD
     if (sym == @symbol(ECHILD)) {
-	RETURN ( __mkSmallInteger(ECHILD) );
+        RETURN ( __mkSmallInteger(ECHILD) );
     }
 #endif
 
 #if defined(EAGAIN)
     if (sym == @symbol(EAGAIN)) {
-	RETURN ( __mkSmallInteger(EAGAIN) );
+        RETURN ( __mkSmallInteger(EAGAIN) );
     }
 #endif
 
 #ifdef ENOMEM
     if (sym == @symbol(ENOMEM)) {
-	RETURN ( __mkSmallInteger(ENOMEM) );
+        RETURN ( __mkSmallInteger(ENOMEM) );
     }
 #endif
 
 #ifdef EACCES
     if (sym == @symbol(EACCES)) {
-	RETURN ( __mkSmallInteger(EACCES) );
+        RETURN ( __mkSmallInteger(EACCES) );
     }
 #endif
 
 #ifdef EFAULT
     if (sym == @symbol(EFAULT)) {
-	RETURN ( __mkSmallInteger(EFAULT) );
+        RETURN ( __mkSmallInteger(EFAULT) );
     }
 #endif
 
 #ifdef EBUSY
     if (sym == @symbol(EBUSY)) {
-	RETURN ( __mkSmallInteger(EBUSY) );
+        RETURN ( __mkSmallInteger(EBUSY) );
     }
 #endif
 
 #ifdef EXDEV
     if (sym == @symbol(EXDEV)) {
-	RETURN ( __mkSmallInteger(EXDEV) );
+        RETURN ( __mkSmallInteger(EXDEV) );
     }
 #endif
 
 #ifdef ENODEV
     if (sym == @symbol(ENODEV)) {
-	RETURN ( __mkSmallInteger(ENODEV) );
+        RETURN ( __mkSmallInteger(ENODEV) );
     }
 #endif
 
 #ifdef ENOTDIR
     if (sym == @symbol(ENOTDIR)) {
-	RETURN ( __mkSmallInteger(ENOTDIR) );
+        RETURN ( __mkSmallInteger(ENOTDIR) );
     }
 #endif
 
 #ifdef EISDIR
     if (sym == @symbol(EISDIR)) {
-	RETURN ( __mkSmallInteger(EISDIR) );
+        RETURN ( __mkSmallInteger(EISDIR) );
     }
 #endif
 
 #ifdef EINVAL
     if (sym == @symbol(EINVAL)) {
-	RETURN ( __mkSmallInteger(EINVAL) );
+        RETURN ( __mkSmallInteger(EINVAL) );
     }
 #endif
 
 #ifdef ENFILE
     if (sym == @symbol(ENFILE)) {
-	RETURN ( __mkSmallInteger(ENFILE) );
+        RETURN ( __mkSmallInteger(ENFILE) );
     }
 #endif
 
 #ifdef EMFILE
     if (sym == @symbol(EMFILE)) {
-	RETURN ( __mkSmallInteger(EMFILE) );
+        RETURN ( __mkSmallInteger(EMFILE) );
     }
 #endif
 
 #ifdef ENOTTY
     if (sym == @symbol(ENOTTY)) {
-	RETURN ( __mkSmallInteger(ENOTTY) );
+        RETURN ( __mkSmallInteger(ENOTTY) );
     }
 #endif
 
 #ifdef EFBIG
     if (sym == @symbol(EFBIG)) {
-	RETURN ( __mkSmallInteger(EFBIG) );
+        RETURN ( __mkSmallInteger(EFBIG) );
     }
 #endif
 
 #ifdef ENOSPC
     if (sym == @symbol(ENOSPC)) {
-	RETURN ( __mkSmallInteger(ENOSPC) );
+        RETURN ( __mkSmallInteger(ENOSPC) );
     }
 #endif
 
 #ifdef ESPIPE
     if (sym == @symbol(ESPIPE)) {
-	RETURN ( __mkSmallInteger(ESPIPE) );
+        RETURN ( __mkSmallInteger(ESPIPE) );
     }
 #endif
 
 #ifdef EROFS
     if (sym == @symbol(EROFS)) {
-	RETURN ( __mkSmallInteger(EROFS) );
+        RETURN ( __mkSmallInteger(EROFS) );
     }
 #endif
 
 #ifdef EMLINK
     if (sym == @symbol(EMLINK)) {
-	RETURN ( __mkSmallInteger(EMLINK) );
+        RETURN ( __mkSmallInteger(EMLINK) );
     }
 #endif
 
 #ifdef EPIPE
     if (sym == @symbol(EPIPE)) {
-	RETURN ( __mkSmallInteger(EPIPE) );
+        RETURN ( __mkSmallInteger(EPIPE) );
     }
 #endif
 
 #ifdef EDOM
     if (sym == @symbol(EDOM)) {
-	RETURN ( __mkSmallInteger(EDOM) );
+        RETURN ( __mkSmallInteger(EDOM) );
     }
 #endif
 
 #ifdef ERANGE
     if (sym == @symbol(ERANGE)) {
-	RETURN ( __mkSmallInteger(ERANGE) );
+        RETURN ( __mkSmallInteger(ERANGE) );
     }
 #endif
 
 #ifdef EDEADLK
     if (sym == @symbol(EDEADLK)) {
-	RETURN ( __mkSmallInteger(EDEADLK) );
+        RETURN ( __mkSmallInteger(EDEADLK) );
     }
 #endif
 
 #ifdef ENAMETOOLONG
     if (sym == @symbol(ENAMETOOLONG)) {
-	RETURN ( __mkSmallInteger(ENAMETOOLONG) );
+        RETURN ( __mkSmallInteger(ENAMETOOLONG) );
     }
 #endif
 
 #ifdef ENOLCK
     if (sym == @symbol(ENOLCK)) {
-	RETURN ( __mkSmallInteger(ENOLCK) );
+        RETURN ( __mkSmallInteger(ENOLCK) );
     }
 #endif
 
 #ifdef ENOSYS
     if (sym == @symbol(ENOSYS)) {
-	RETURN ( __mkSmallInteger(ENOSYS) );
+        RETURN ( __mkSmallInteger(ENOSYS) );
     }
 #endif
 
 #ifdef ENOTEMPTY
     if (sym == @symbol(ENOTEMPTY)) {
-	RETURN ( __mkSmallInteger(ENOTEMPTY) );
+        RETURN ( __mkSmallInteger(ENOTEMPTY) );
     }
 #endif
 
 #ifdef EEXIST
     if (sym == @symbol(EEXIST)) {
-	RETURN ( __mkSmallInteger(EEXIST) );
+        RETURN ( __mkSmallInteger(EEXIST) );
     }
 #endif
 
 #ifdef EILSEQ
     if (sym == @symbol(EILSEQ)) {
-	RETURN ( __mkSmallInteger(EILSEQ) );
+        RETURN ( __mkSmallInteger(EILSEQ) );
     }
 #endif
 
@@ -3220,13 +3235,13 @@
      */
 #ifdef ENOTBLK
     if (sym == @symbol(ENOTBLK)) {
-	RETURN ( __mkSmallInteger(ENOTBLK) );
+        RETURN ( __mkSmallInteger(ENOTBLK) );
     }
 #endif
 
 #ifdef ETXTBSY
     if (sym == @symbol(ETXTBSY)) {
-	RETURN ( __mkSmallInteger(ETXTBSY) );
+        RETURN ( __mkSmallInteger(ETXTBSY) );
     }
 #endif
 
@@ -3235,19 +3250,19 @@
      */
 #ifdef EWOULDBLOCK
     if (sym == @symbol(EWOULDBLOCK)) {
-	RETURN ( __mkSmallInteger(EWOULDBLOCK) );
+        RETURN ( __mkSmallInteger(EWOULDBLOCK) );
     }
 #endif
 
 #ifdef ENOMSG
     if (sym == @symbol(ENOMSG)) {
-	RETURN ( __mkSmallInteger(ENOMSG) );
+        RETURN ( __mkSmallInteger(ENOMSG) );
     }
 #endif
 
 #ifdef ELOOP
     if (sym == @symbol(ELOOP)) {
-	RETURN ( __mkSmallInteger(ELOOP) );
+        RETURN ( __mkSmallInteger(ELOOP) );
     }
 #endif
 
@@ -3256,31 +3271,31 @@
      */
 #ifdef ETIME
     if (sym == @symbol(ETIME)) {
-	RETURN ( __mkSmallInteger(ETIME) );
+        RETURN ( __mkSmallInteger(ETIME) );
     }
 #endif
 
 #ifdef ENOSR
     if (sym == @symbol(ENOSR)) {
-	RETURN ( __mkSmallInteger(ENOSR) );
+        RETURN ( __mkSmallInteger(ENOSR) );
     }
 #endif
 
 #ifdef ENOSTR
     if (sym == @symbol(ENOSTR)) {
-	RETURN ( __mkSmallInteger(ENOSTR) );
+        RETURN ( __mkSmallInteger(ENOSTR) );
     }
 #endif
 
 #ifdef ECOMM
     if (sym == @symbol(ECOMM)) {
-	RETURN ( __mkSmallInteger(ECOMM) );
+        RETURN ( __mkSmallInteger(ECOMM) );
     }
 #endif
 
 #ifdef EPROTO
     if (sym == @symbol(EPROTO)) {
-	RETURN ( __mkSmallInteger(EPROTO) );
+        RETURN ( __mkSmallInteger(EPROTO) );
     }
 #endif
 
@@ -3289,13 +3304,13 @@
      */
 #ifdef ESTALE
     if (sym == @symbol(ESTALE)) {
-	RETURN ( __mkSmallInteger(ESTALE) );
+        RETURN ( __mkSmallInteger(ESTALE) );
     }
 #endif
 
 #ifdef EREMOTE
     if (sym == @symbol(EREMOTE)) {
-	RETURN ( __mkSmallInteger(EREMOTE) );
+        RETURN ( __mkSmallInteger(EREMOTE) );
     }
 #endif
 
@@ -3304,162 +3319,162 @@
      */
 #ifdef EINPROGRESS
     if (sym == @symbol(EINPROGRESS)) {
-	RETURN ( __mkSmallInteger(EINPROGRESS) );
+        RETURN ( __mkSmallInteger(EINPROGRESS) );
     }
 #endif
 
 #ifdef EALREADY
     if (sym == @symbol(EALREADY)) {
-	RETURN ( __mkSmallInteger(EALREADY) );
+        RETURN ( __mkSmallInteger(EALREADY) );
     }
 #endif
 
 #ifdef ENOTSOCK
     if (sym == @symbol(ENOTSOCK)) {
-	RETURN ( __mkSmallInteger(ENOTSOCK) );
+        RETURN ( __mkSmallInteger(ENOTSOCK) );
     }
 #endif
 
 #ifdef EDESTADDRREQ
     if (sym == @symbol(EDESTADDRREQ)) {
-	RETURN ( __mkSmallInteger(EDESTADDRREQ) );
+        RETURN ( __mkSmallInteger(EDESTADDRREQ) );
     }
 #endif
 
 #ifdef EMSGSIZE
     if (sym == @symbol(EMSGSIZE)) {
-	RETURN ( __mkSmallInteger(EMSGSIZE) );
+        RETURN ( __mkSmallInteger(EMSGSIZE) );
     }
 #endif
 
 #ifdef EPROTOTYPE
     if (sym == @symbol(EPROTOTYPE)) {
-	RETURN ( __mkSmallInteger(EPROTOTYPE) );
+        RETURN ( __mkSmallInteger(EPROTOTYPE) );
     }
 #endif
 
 #ifdef ENOPROTOOPT
     if (sym == @symbol(ENOPROTOOPT)) {
-	RETURN ( __mkSmallInteger(ENOPROTOOPT) );
+        RETURN ( __mkSmallInteger(ENOPROTOOPT) );
     }
 #endif
 
 #ifdef EPROTONOSUPPORT
     if (sym == @symbol(EPROTONOSUPPORT)) {
-	RETURN ( __mkSmallInteger(EPROTONOSUPPORT) );
+        RETURN ( __mkSmallInteger(EPROTONOSUPPORT) );
     }
 #endif
 
 #ifdef ESOCKTNOSUPPORT
     if (sym == @symbol(ESOCKTNOSUPPORT)) {
-	RETURN ( __mkSmallInteger(ESOCKTNOSUPPORT) );
+        RETURN ( __mkSmallInteger(ESOCKTNOSUPPORT) );
     }
 #endif
 
 #ifdef EOPNOTSUPP
     if (sym == @symbol(EOPNOTSUPP)) {
-	RETURN ( __mkSmallInteger(EOPNOTSUPP) );
+        RETURN ( __mkSmallInteger(EOPNOTSUPP) );
     }
 #endif
 
 #ifdef EPFNOSUPPORT
     if (sym == @symbol(EPFNOSUPPORT)) {
-	RETURN ( __mkSmallInteger(EPFNOSUPPORT) );
+        RETURN ( __mkSmallInteger(EPFNOSUPPORT) );
     }
 #endif
 
 #ifdef EAFNOSUPPORT
     if (sym == @symbol(EAFNOSUPPORT)) {
-	RETURN ( __mkSmallInteger(EAFNOSUPPORT) );
+        RETURN ( __mkSmallInteger(EAFNOSUPPORT) );
     }
 #endif
 
 #ifdef EADDRINUSE
     if (sym == @symbol(EADDRINUSE)) {
-	RETURN ( __mkSmallInteger(EADDRINUSE) );
+        RETURN ( __mkSmallInteger(EADDRINUSE) );
     }
 #endif
 
 #ifdef EADDRNOTAVAIL
     if (sym == @symbol(EADDRNOTAVAIL)) {
-	RETURN ( __mkSmallInteger(EADDRNOTAVAIL) );
+        RETURN ( __mkSmallInteger(EADDRNOTAVAIL) );
     }
 #endif
 
 #ifdef ETIMEDOUT
     if (sym == @symbol(ETIMEDOUT)) {
-	RETURN ( __mkSmallInteger(ETIMEDOUT) );
+        RETURN ( __mkSmallInteger(ETIMEDOUT) );
     }
 #endif
 #ifdef WSAETIMEDOUT
     if (sym == @symbol(ETIMEDOUT)) {
-	RETURN ( __mkSmallInteger(WSAETIMEDOUT) );
+        RETURN ( __mkSmallInteger(WSAETIMEDOUT) );
     }
 #endif
 
 #ifdef ECONNREFUSED
     if (sym == @symbol(ECONNREFUSED)) {
-	RETURN ( __mkSmallInteger(ECONNREFUSED) );
+        RETURN ( __mkSmallInteger(ECONNREFUSED) );
     }
 #endif
 
 #ifdef ENETDOWN
     if (sym == @symbol(ENETDOWN)) {
-	RETURN ( __mkSmallInteger(ENETDOWN) );
+        RETURN ( __mkSmallInteger(ENETDOWN) );
     }
 #endif
 
 #ifdef ENETUNREACH
     if (sym == @symbol(ENETUNREACH)) {
-	RETURN ( __mkSmallInteger(ENETUNREACH) );
+        RETURN ( __mkSmallInteger(ENETUNREACH) );
     }
 #endif
 
 #ifdef ENETRESET
     if (sym == @symbol(ENETRESET)) {
-	RETURN ( __mkSmallInteger(ENETRESET) );
+        RETURN ( __mkSmallInteger(ENETRESET) );
     }
 #endif
 
 #ifdef ECONNABORTED
     if (sym == @symbol(ECONNABORTED)) {
-	RETURN ( __mkSmallInteger(ECONNABORTED) );
+        RETURN ( __mkSmallInteger(ECONNABORTED) );
     }
 #endif
 
 #ifdef ECONNRESET
     if (sym == @symbol(ECONNRESET)) {
-	RETURN ( __mkSmallInteger(ECONNRESET) );
+        RETURN ( __mkSmallInteger(ECONNRESET) );
     }
 #endif
 
 #ifdef EISCONN
     if (sym == @symbol(EISCONN)) {
-	RETURN ( __mkSmallInteger(EISCONN) );
+        RETURN ( __mkSmallInteger(EISCONN) );
     }
 #endif
 
 #ifdef ENOTCONN
     if (sym == @symbol(ENOTCONN)) {
-	RETURN ( __mkSmallInteger(ENOTCONN) );
+        RETURN ( __mkSmallInteger(ENOTCONN) );
     }
 #endif
 
 #ifdef ESHUTDOWN
     if (sym == @symbol(ESHUTDOWN)) {
-	RETURN ( __mkSmallInteger(ESHUTDOWN) );
+        RETURN ( __mkSmallInteger(ESHUTDOWN) );
     }
 #endif
 
 #ifdef EHOSTDOWN
     if (sym == @symbol(EHOSTDOWN)) {
-	RETURN ( __mkSmallInteger(EHOSTDOWN) );
+        RETURN ( __mkSmallInteger(EHOSTDOWN) );
     }
 #endif
 
 #ifdef EHOSTUNREACH
     if (sym == @symbol(EHOSTUNREACH)) {
-	RETURN ( __mkSmallInteger(EHOSTUNREACH) );
+        RETURN ( __mkSmallInteger(EHOSTUNREACH) );
     }
 #endif
     /*
@@ -3467,92 +3482,92 @@
      */
 #ifdef WSAEINTR
     if (sym == @symbol(WSAEINTR)) {
-	RETURN ( __mkSmallInteger(WSAEINTR) );
+        RETURN ( __mkSmallInteger(WSAEINTR) );
     }
 #endif
 #ifdef WSAEBADF
     if (sym == @symbol(WSAEBADF)) {
-	RETURN ( __mkSmallInteger(WSAEBADF) );
+        RETURN ( __mkSmallInteger(WSAEBADF) );
     }
 #endif
 #ifdef WSAEACCESS
     if (sym == @symbol(WSAEACCESS)) {
-	RETURN ( __mkSmallInteger(WSAEACCESS) );
+        RETURN ( __mkSmallInteger(WSAEACCESS) );
     }
 #endif
 #ifdef WSAEFAULT
     if (sym == @symbol(WSAEFAULT)) {
-	RETURN ( __mkSmallInteger(WSAEFAULT) );
+        RETURN ( __mkSmallInteger(WSAEFAULT) );
     }
 #endif
 #ifdef WSAEINVAL
     if (sym == @symbol(WSAEINVAL)) {
-	RETURN ( __mkSmallInteger(WSAEINVAL) );
+        RETURN ( __mkSmallInteger(WSAEINVAL) );
     }
 #endif
 #ifdef WSAEMFILE
     if (sym == @symbol(WSAEMFILE)) {
-	RETURN ( __mkSmallInteger(WSAEMFILE) );
+        RETURN ( __mkSmallInteger(WSAEMFILE) );
     }
 #endif
 #ifdef WSAEWOULDBLOCK
     if (sym == @symbol(WSAEWOULDBLOCK)) {
-	RETURN ( __mkSmallInteger(WSAEWOULDBLOCK) );
+        RETURN ( __mkSmallInteger(WSAEWOULDBLOCK) );
     }
 #endif
 #ifdef WSAEINPROGRESS
     if (sym == @symbol(WSAEINPROGRESS)) {
-	RETURN ( __mkSmallInteger(WSAEINPROGRESS) );
+        RETURN ( __mkSmallInteger(WSAEINPROGRESS) );
     }
 #endif
 #ifdef WSAEALREADY
     if (sym == @symbol(WSAEALREADY)) {
-	RETURN ( __mkSmallInteger(WSAEALREADY) );
+        RETURN ( __mkSmallInteger(WSAEALREADY) );
     }
 #endif
 #ifdef WSAENOTSOCK
     if (sym == @symbol(WSAENOTSOCK)) {
-	RETURN ( __mkSmallInteger(WSAENOTSOCK) );
+        RETURN ( __mkSmallInteger(WSAENOTSOCK) );
     }
 #endif
 #ifdef WSAEPROTONOSUPPORT
     if (sym == @symbol(WSAEPROTONOSUPPORT)) {
-	RETURN ( __mkSmallInteger(WSAEPROTONOSUPPORT) );
+        RETURN ( __mkSmallInteger(WSAEPROTONOSUPPORT) );
     }
 #endif
 #ifdef WSAESOCKTNOSUPPORT
     if (sym == @symbol(WSAESOCKTNOSUPPORT)) {
-	RETURN ( __mkSmallInteger(WSAESOCKTNOSUPPORT) );
+        RETURN ( __mkSmallInteger(WSAESOCKTNOSUPPORT) );
     }
 #endif
 #ifdef E_NOINTERFACE
     if (sym == @symbol(E_NOINTERFACE)) {
-	RETURN ( __MKUINT(E_NOINTERFACE) );
+        RETURN ( __MKUINT(E_NOINTERFACE) );
     }
 #endif
 #ifdef CO_E_NOTINITIALIZED
     if (sym == @symbol(CO_E_NOTINITIALIZED)) {
-	RETURN ( __MKUINT(CO_E_NOTINITIALIZED) );
+        RETURN ( __MKUINT(CO_E_NOTINITIALIZED) );
     }
 #endif
 #ifdef REGDB_E_CLASSNOTREG
     if (sym == @symbol(REGDB_E_CLASSNOTREG)) {
-	RETURN ( __MKUINT(REGDB_E_CLASSNOTREG) );
+        RETURN ( __MKUINT(REGDB_E_CLASSNOTREG) );
     }
 #endif
 #ifdef CLASS_E_NOAGGREGATION
     if (sym == @symbol(CLASS_E_NOAGGREGATION)) {
-	RETURN ( __MKUINT(CLASS_E_NOAGGREGATION) );
+        RETURN ( __MKUINT(CLASS_E_NOAGGREGATION) );
     }
 #endif
 #ifdef DISP_E_UNKNOWNNAME
     if (sym == @symbol(DISP_E_UNKNOWNNAME)) {
-	RETURN ( __MKUINT(DISP_E_UNKNOWNNAME) );
+        RETURN ( __MKUINT(DISP_E_UNKNOWNNAME) );
     }
 #endif
 #ifdef OLEOBJ_E_NOVERBS
     if (sym == @symbol(OLEOBJ_E_NOVERBS)) {
-	RETURN ( __MKUINT(OLEOBJ_E_NOVERBS) );
+        RETURN ( __MKUINT(OLEOBJ_E_NOVERBS) );
     }
 #endif
 
@@ -11074,17 +11089,30 @@
      Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap.
 
      BAD DESIGN:
-	This should be changed to return some instance of RelativeTime,
-	and these computations moved there.
+        This should be changed to return some instance of RelativeTime,
+        and these computations moved there.
 
      Don't use this method in application code since it is an internal (private)
      interface. For compatibility with ST-80, use Time millisecondClockValue.
     "
 
 %{  /* NOCONTEXT */
-
-    RETURN ( __mkSmallInteger(GetTickCount() & 0x1FFFFFFF) );
-%}
+#if POINTERSIZE == 8
+    RETURN ( __mkSmallInteger(GetTickCount64() & (_MAX_INT >> 1)) );
+#else
+    RETURN ( __mkSmallInteger(GetTickCount() & (_MAX_INT >> 1)) );
+#endif
+%}
+
+    "
+        self getMillisecondTime
+
+        |t1 t2|
+        t1 := self getMillisecondTime.
+        Delay waitForSeconds:1.
+        t2 := self getMillisecondTime.
+        t2 - t1.
+    "
 !
 
 getOSTime
@@ -12007,10 +12035,7 @@
 //#define SELECTDEBUGWIN32
 //#define SELECT3DEBUGWIN32
 #define MAXHANDLE 128
-    int i, idx;
-    INT t;
-    int numHandles;
-    DWORD res;
+    int i;
     HANDLE hArray[MAXHANDLE+1];
     int retArray[MAXHANDLE];
     int readCount, writeCount, exceptCount;
@@ -12020,315 +12045,324 @@
     fd_set readFds;
     fd_set writeFds;
     fd_set exceptFds;
-    int hasSockets;
-    int hasPipes;
+    int numHandles, numSockets, numPipes;
     int pass = 1;       // perform up to 2 passes
 
     if (readableResultFdArray != nil) {
-	if (! __isArrayLike(readableResultFdArray)) {
-	    goto fail;
-	}
-	resultSizeReadable = __arraySize(readableResultFdArray);
+        if (! __isArrayLike(readableResultFdArray)) {
+            goto fail;
+        }
+        resultSizeReadable = __arraySize(readableResultFdArray);
     }
     if (writableResultFdArray != nil) {
-	if (! __isArrayLike(writableResultFdArray)) {
-	    goto fail;
-	}
-	resultSizeWritable = __arraySize(writableResultFdArray);
-	if (readableResultFdArray == writableResultFdArray) {
-	    // allow common result set for read/write/except
-	    pcntW = &cntR;
-	}
+        if (! __isArrayLike(writableResultFdArray)) {
+            goto fail;
+        }
+        resultSizeWritable = __arraySize(writableResultFdArray);
+        if (readableResultFdArray == writableResultFdArray) {
+            // allow common result set for read/write/except
+            pcntW = &cntR;
+        }
     }
     if (exceptionResultFdArray != nil) {
-	if (! __isArrayLike(exceptionResultFdArray)) {
-	    goto fail;
-	}
-	resultSizeException = __arraySize(exceptionResultFdArray);
-	if (exceptionResultFdArray == readableResultFdArray) {
-	    // allow common result set for read/write/except
-	    pcntE = &cntR;
-	} else if (exceptionResultFdArray == writableResultFdArray) {
-	    pcntE = &cntW;
-	}
+        if (! __isArrayLike(exceptionResultFdArray)) {
+            goto fail;
+        }
+        resultSizeException = __arraySize(exceptionResultFdArray);
+        if (exceptionResultFdArray == readableResultFdArray) {
+            // allow common result set for read/write/except
+            pcntE = &cntR;
+        } else if (exceptionResultFdArray == writableResultFdArray) {
+            pcntE = &cntW;
+        }
     }
 
     if (__isNonNilObject(readFdArray)) {
-	if (! __isArrayLike(readFdArray)) goto fail;
-	readCount = __arraySize(readFdArray);
+        if (! __isArrayLike(readFdArray)) goto fail;
+        readCount = __arraySize(readFdArray);
     } else {
-	readCount = 0;
+        readCount = 0;
     }
 
     if (__isNonNilObject(writeFdArray)) {
-	if (! __isArrayLike(writeFdArray)) goto fail;
-	writeCount = __arraySize(writeFdArray);
+        if (! __isArrayLike(writeFdArray)) goto fail;
+        writeCount = __arraySize(writeFdArray);
     } else {
-	writeCount = 0;
+        writeCount = 0;
     }
 
     if (__isNonNilObject(exceptFdArray)) {
-	if (! __isArrayLike(exceptFdArray)) goto fail;
-	exceptCount = __arraySize(exceptFdArray);
+        if (! __isArrayLike(exceptFdArray)) goto fail;
+        exceptCount = __arraySize(exceptFdArray);
     } else {
-	exceptCount = 0;
+        exceptCount = 0;
     }
 
 pollAgain:
     FD_ZERO(&readFds);
     FD_ZERO(&writeFds);
     FD_ZERO(&exceptFds);
-    numHandles = hasSockets = hasPipes = 0;
+    numHandles = numSockets = numPipes = 0;
 
     for (i = 0; (i < readCount) && (numHandles < MAXHANDLE); i++) {
-	OBJ fd = __arrayVal(readFdArray)[i];
-
-	if (fd != nil) {
-	    if (__Class(fd) == @global(Win32SocketHandle)) {
-		FD_SET (_HANDLEVal(fd), &readFds);
-		hasSockets++;
-	    } else if (__isSmallInteger(fd)) {
-		DWORD canRead;
-		if (PeekNamedPipe(_get_osfhandle(__intVal(fd)), 0, 0, 0, &canRead, 0)) {
-		    if (canRead > 0) {
-			if (*pcntR < resultSizeReadable) {
-			    __arrayVal(readableResultFdArray)[*pcntR] = fd;
-			}
-			(*pcntR)++; cntAll++;
-		    }
-		} else {
-		    @global(LastErrorNumber) = __mkSmallInteger(EBADF);
-		    RETURN (__mkSmallInteger(-1));
-		}
-		hasPipes++;
-	    } else {
-		hArray  [numHandles] = _HANDLEVal(fd);
-		retArray[numHandles] = i;
-		++numHandles;
-	    }
-	}
+        OBJ fd = __arrayVal(readFdArray)[i];
+
+        if (fd != nil) {
+            if (__Class(fd) == @global(Win32SocketHandle)) {
+                FD_SET (_HANDLEVal(fd), &readFds);
+                numSockets++;
+            } else if (__isSmallInteger(fd)) {
+                DWORD canRead;
+                if (PeekNamedPipe(_get_osfhandle(__intVal(fd)), 0, 0, 0, &canRead, 0)) {
+                    if (canRead > 0) {
+                        if (*pcntR < resultSizeReadable) {
+                            __arrayVal(readableResultFdArray)[*pcntR] = fd;
+                        }
+                        (*pcntR)++; cntAll++;
+                    }
+                } else {
+                    @global(LastErrorNumber) = __mkSmallInteger(EBADF);
+                    RETURN (__mkSmallInteger(-1));
+                }
+                numPipes++;
+            } else {
+                hArray  [numHandles] = _HANDLEVal(fd);
+                retArray[numHandles] = i;
+                ++numHandles;
+            }
+        }
     }
 
     for (i = 0; (i < writeCount) && (numHandles < MAXHANDLE); i++) {
-	OBJ fd = __arrayVal(writeFdArray)[i];
-
-	if (fd != nil) {
-	    if (__Class(fd) == @global(Win32SocketHandle)) {
-		FD_SET (_HANDLEVal(fd), &writeFds);
-		hasSockets++;
-	    } else if (__isSmallInteger(fd)) {
-		// kludge: assume that pipes can alway be written
-	       if (*pcntW < resultSizeWritable) {
-		    __arrayVal(writableResultFdArray)[*pcntW] = fd;
-		}
-		(*pcntW)++; cntAll++;
-		// there is no pipe to check
-	    } else {
-		hArray  [numHandles] = _HANDLEVal(fd);
-		retArray[numHandles] = i + 10000;
-		++numHandles;
-	    }
-	}
+        OBJ fd = __arrayVal(writeFdArray)[i];
+
+        if (fd != nil) {
+            if (__Class(fd) == @global(Win32SocketHandle)) {
+                FD_SET (_HANDLEVal(fd), &writeFds);
+                numSockets++;
+            } else if (__isSmallInteger(fd)) {
+                // kludge: assume that pipes can alway be written
+               if (*pcntW < resultSizeWritable) {
+                    __arrayVal(writableResultFdArray)[*pcntW] = fd;
+                }
+                (*pcntW)++; cntAll++;
+                // there is no pipe to check
+            } else {
+                hArray  [numHandles] = _HANDLEVal(fd);
+                retArray[numHandles] = i + 10000;
+                ++numHandles;
+            }
+        }
     }
 
     for (i = 0; (i < exceptCount) && (numHandles < MAXHANDLE); i++) {
-	OBJ fdOrPid = __arrayVal(exceptFdArray)[i];
-
-	if (fdOrPid != nil) {
-	    if (__Class(fdOrPid) == @global(Win32SocketHandle)) {
-		FD_SET (_HANDLEVal(fdOrPid), &exceptFds);
-		hasSockets++;
-	    } else if (__isExternalAddressLike(fdOrPid)) {
-		// a PID
-		hArray  [numHandles] = _HANDLEVal(fdOrPid);
-		retArray[numHandles] = i + 20000;
-		++numHandles;
-	    }
-	}
-    }
-
-    if (hasSockets) {
-	struct timeval tv = {0, 0};
-	int nReady;
-
-#ifdef SELECT3DEBUGWIN32
-	console_printf("select hasSockets = %d\n", hasSockets);
-#endif
-	nReady = select(1 , &readFds, &writeFds, &exceptFds, &tv);  // first parameter to select is ignored in windows
-	if (nReady < 0) {
-#ifdef SELECTDEBUGWIN32
-	    console_printf("error in select %d %d\n", nReady, GetLastError());
-#endif
-	    @global(LastErrorNumber) = __mkSmallInteger(EBADF);
-	    RETURN (__mkSmallInteger(-1));
-	}
-	if (nReady > 0) {
-#ifdef SELECT3DEBUGWIN32
-	    console_printf("select nReady %d of %d\n", nReady, hasSockets);
-#endif
-	    for (i = 0; i < readCount; i++) {
-		OBJ fd = __arrayVal(readFdArray)[i];
-		if ((__Class(fd) == @global(Win32SocketHandle)) && FD_ISSET(_HANDLEVal(fd), &readFds)) {
-		    if (*pcntR < resultSizeReadable) {
-			__arrayVal(readableResultFdArray)[*pcntR] = fd;
-			__STORE(readableResultFdArray, fd);
-		    }
-		    (*pcntR)++; cntAll++;
-		}
-	    }
-	    for (i = 0; i < writeCount; i++) {
-		OBJ fd = __arrayVal(writeFdArray)[i];
-		if ((__Class(fd) == @global(Win32SocketHandle)) && FD_ISSET(_HANDLEVal(fd), &writeFds)) {
-		    if (*pcntW < resultSizeWritable) {
-			__arrayVal(writableResultFdArray)[*pcntW] = fd;
-			__STORE(writableResultFdArray, fd);
-		    }
-		    (*pcntW)++; cntAll++;
-		}
-	    }
-	    for (i = 0; i < exceptCount; i++) {
-		OBJ fd = __arrayVal(exceptFdArray)[i];
-		if ((__Class(fd) == @global(Win32SocketHandle)) && FD_ISSET(_HANDLEVal(fd), &exceptFds)) {
-		    if (*pcntE < resultSizeException) {
-			__arrayVal(exceptionResultFdArray)[*pcntE] = fd;
-			__STORE(exceptionResultFdArray, fd);
-		    }
-		    (*pcntE)++; cntAll++;
-		}
-	    }
-
-	}
-    }
-    if (pass > 1)       // perform maximum 2 passes
-	goto done;
-
-    if (cntAll) {
-	// check for other handles and return immediately, no timeout
-	t = 0;
-    } else {
-	if (__isSmallInteger(millis)) {
-	    t = __intVal(millis);
-
-	    if (t <= 0 && numHandles == 0) {
-		RETURN (__mkSmallInteger(0));
-	    }
-	} else {
-	    t = INFINITE;
-	}
-    }
-
-    if (numHandles == 0 && t == 0) {
-	// nothing to do and no wait
-	goto done;
-    }
+        OBJ fdOrPid = __arrayVal(exceptFdArray)[i];
+
+        if (fdOrPid != nil) {
+            if (__Class(fdOrPid) == @global(Win32SocketHandle)) {
+                FD_SET (_HANDLEVal(fdOrPid), &exceptFds);
+                numSockets++;
+            } else if (__isExternalAddressLike(fdOrPid)) {
+                // a PID
+                hArray  [numHandles] = _HANDLEVal(fdOrPid);
+                retArray[numHandles] = i + 20000;
+                ++numHandles;
+            }
+        }
+    }
+
+    // +++++ checking for Windows Handles +++++++++++++++++++++++++++++++++++++++++
+    if (numHandles != 0) {
+        DWORD res;          
+        int idx;
+        INT t;
+
+        if (numSockets || pass > 1) {
+            // do not wait - wait when checking for sockets
+            t = 0;
+        } else if (__isSmallInteger(millis)) {
+            t = __intVal(millis);
+        } else {
+            t = INFINITE;
+        }
 
 #ifdef SELECT3DEBUGWIN32
-    console_printf("wait numhandles = %d timeout = %d\n", numHandles, t);
-#endif
-
-    res = __vmWait(numHandles, hArray, MAXHANDLE, t);
-
-    if (res == WAIT_TIMEOUT) {
+        console_printf("wait numhandles = %d timeout = %d\n", numHandles, t);
+#endif
+
+        res = __vmWait(numHandles, hArray, MAXHANDLE, (int)t);
+
+        if (res == WAIT_TIMEOUT) {
 #ifdef SELECT3DEBUGWIN32
-	console_printf("- timeOut; ret nil\n" );
-#endif
-	if (t != 0 && (hasSockets || hasPipes)) {
-	    // if not a single handle is ready, poll sockets an pipes again
-	    pass = 2;
-	    goto pollAgain;
-	}
-	goto done;
-    }
-
-    if (res == WAIT_FAILED) {
+            console_printf("- timeOut" );
+#endif
+            goto checkSockets;
+        }
+        if (res == __WAIT_INTERRUPTED) {
+#ifdef SELECT3DEBUGWIN32
+            console_printf("- interrupted\n" );
+#endif
+            goto done;
+        }
+
+        if (res == WAIT_FAILED) {
 #ifdef SELECT2DEBUGWIN32
-	console_printf("- error %d (last %d); ret -1\n", __threadErrno, GetLastError());
-#endif
-	if (__threadErrno == EINTR) {
-	    @global(LastErrorNumber) = nil;
-	    RETURN (__mkSmallInteger(0));
-	} else {
-	    if (@global(InfoPrinting) == true) {
-//                console_fprintf(stderr, "Win32OS [info]: select errno = %d (last %d)\n", __threadErrno, GetLastError());
-		console_printf("Win32OS [info]: select errno = %d (last %d)\n", __threadErrno, GetLastError());
-	    }
-	    @global(LastErrorNumber) = __mkSmallInteger(EBADF);
-	    RETURN (__mkSmallInteger(-1));
-	}
-    }
-
-    if (numHandles) {
-	if (res == numHandles) {
-	    // vmwait() added an IRQ event to the handles, and this one has been triggered
-	    if (1 /* @global(InfoPrinting) == true */) {
-		console_fprintf(stderr, "Win32OS [info]: plugIn event has been handled\n");
-	    }
-	    goto done;
-	}
-	if ((res < 0) || (res >= numHandles)) {
-	    console_printf("- res=%d error1 %d\n", res, GetLastError());
-	    goto done;
-	}
-
-	idx = retArray[res];
-	cntAll++;
+            console_printf("- error %d (last %d); ret -1\n", __threadErrno, GetLastError());
+#endif
+            if (__threadErrno == EINTR) {
+                @global(LastErrorNumber) = nil;
+                RETURN (__mkSmallInteger(0));
+            } else {
+                if (@global(InfoPrinting) == true) {
+//                    console_fprintf(stderr, "Win32OS [info]: select errno = %d (last %d)\n", __threadErrno, GetLastError());
+                    console_printf("Win32OS [info]: select errno = %d (last %d)\n", __threadErrno, GetLastError());
+                }
+                @global(LastErrorNumber) = __mkSmallInteger(EBADF);
+                RETURN (__mkSmallInteger(-1));
+            }
+        }
+
+        if (res == numHandles) {
+            // vmwait() added an IRQ event to the handles, and this one has been triggered
+            if (1 /* @global(InfoPrinting) == true */) {
+                console_fprintf(stderr, "Win32OS [info]: plugIn event has been handled\n");
+            }
+            goto done;
+        }
+        if ((res < 0) || (res >= numHandles)) {
+            console_printf("- res=%d error1 %d\n", res, GetLastError());
+            goto done;
+        }
+
+        idx = retArray[res];
+        cntAll++;
 
 #ifdef SELECTDEBUGWIN32
-	console_printf("wait Handles res %d idx %d numHandles %d --- ", res, idx, numHandles);
-#endif
-	if (idx < 10000) {
-	    if (*pcntR < resultSizeReadable) {
-		OBJ temp = __arrayVal(readFdArray)[idx];
-		__arrayVal(readableResultFdArray)[*pcntR] = temp;
-		__STORE(readableResultFdArray, temp);
+        console_printf("wait Handles res %d idx %d numHandles %d --- ", res, idx, numHandles);
+#endif
+        if (idx < 10000) {
+            if (*pcntR < resultSizeReadable) {
+                OBJ temp = __arrayVal(readFdArray)[idx];
+                __arrayVal(readableResultFdArray)[*pcntR] = temp;
+                __STORE(readableResultFdArray, temp);
 #ifdef SELECTDEBUGWIN32
-		console_printf("read ready: %x\n", __externalAddressVal(temp));
-#endif
-		(*pcntR)++;
-	    }
-	} else if (idx < 20000) {
-	    if (*pcntW < resultSizeWritable) {
-		OBJ temp = __arrayVal(writeFdArray)[idx-10000];
-		__arrayVal(writableResultFdArray)[*pcntW] = temp;
-		__STORE(writableResultFdArray, temp);
+                console_printf("read ready: %x\n", __externalAddressVal(temp));
+#endif
+                (*pcntR)++;
+            }
+        } else if (idx < 20000) {
+            if (*pcntW < resultSizeWritable) {
+                OBJ temp = __arrayVal(writeFdArray)[idx-10000];
+                __arrayVal(writableResultFdArray)[*pcntW] = temp;
+                __STORE(writableResultFdArray, temp);
+#ifdef SELECTDEBUGWIN32
+                console_printf("write ready: %x\n", temp);
+#endif
+                (*pcntW)++;
+            }
+        } else {
+            if (*pcntE < resultSizeException) {
+                OBJ temp = __arrayVal(exceptFdArray)[idx-20000];
+                __arrayVal(exceptionResultFdArray)[*pcntE] = temp;
+                __STORE(exceptionResultFdArray, temp);
+#ifdef SELECTDEBUGWIN32
+                console_printf("except ready: %x\n", temp);
+#endif
+                (*pcntE)++;
+            }
 #ifdef SELECTDEBUGWIN32
-		console_printf("write ready: %x\n", temp);
-#endif
-		(*pcntW)++;
-	    }
-	} else {
-	    if (*pcntE < resultSizeException) {
-		OBJ temp = __arrayVal(exceptFdArray)[idx-20000];
-		__arrayVal(exceptionResultFdArray)[*pcntE] = temp;
-		__STORE(exceptionResultFdArray, temp);
+            else
+                console_printf("cntE: %d, resultSizeException: %d\n", *pcntE, resultSizeException);
+#endif
+        }
+    }
+
+
+// ++++++++++ Check Sockets +++++++++++++++++++++++++++++++++++
+checkSockets:
+    if (pass > 1)       // perform maximum 2 passes
+        goto done;
+
+    if (numSockets) {
+        struct timeval tv = {0, 0};
+        struct timeval *tvp = &tv;
+        int nReady;
+
+        // do not wait, if there are threads that can be resumed
+        if (!__vmTestIfAnyThreadMustBeResumed() && cntAll == 0) {
+            // no ready handles found yet - do wait
+            if (__isSmallInteger(millis)) {
+                tv.tv_usec = __intVal(millis) * 1000;
+            } else {
+                // no timeout
+                tvp = 0;
+            }
+        }
+
+#ifdef SELECT3DEBUGWIN32
+        console_printf("select numSockets = %d\n", numSockets);
+#endif
+        nReady = select(1 , &readFds, &writeFds, &exceptFds, tvp);  // first parameter to select is ignored in windows
+        if (nReady < 0) {
 #ifdef SELECTDEBUGWIN32
-		console_printf("except ready: %x\n", temp);
-#endif
-		(*pcntE)++;
-	    }
-#ifdef SELECTDEBUGWIN32
-	    else
-		console_printf("cntE: %d, resultSizeException: %d\n", *pcntE, resultSizeException);
-#endif
-	}
-    }
-    if (t != 0 && (hasSockets || hasPipes)) {
-	// back after timeout, maybe some sockets or pipes did wake up
-	// in the meantime?
-	pass = 2;
-	goto pollAgain;
+            console_printf("error in select %d %d\n", nReady, GetLastError());
+#endif
+            @global(LastErrorNumber) = __mkSmallInteger(EBADF);
+            RETURN (__mkSmallInteger(-1));
+        }
+        if (nReady > 0) {
+#ifdef SELECT3DEBUGWIN32
+            console_printf("select nReady %d of %d\n", nReady, numSockets);
+#endif
+            for (i = 0; i < readCount; i++) {
+                OBJ fd = __arrayVal(readFdArray)[i];
+                if ((__Class(fd) == @global(Win32SocketHandle)) && FD_ISSET(_HANDLEVal(fd), &readFds)) {
+                    if (*pcntR < resultSizeReadable) {
+                        __arrayVal(readableResultFdArray)[*pcntR] = fd;
+                        __STORE(readableResultFdArray, fd);
+                    }
+                    (*pcntR)++; cntAll++;
+                }
+            }
+            for (i = 0; i < writeCount; i++) {
+                OBJ fd = __arrayVal(writeFdArray)[i];
+                if ((__Class(fd) == @global(Win32SocketHandle)) && FD_ISSET(_HANDLEVal(fd), &writeFds)) {
+                    if (*pcntW < resultSizeWritable) {
+                        __arrayVal(writableResultFdArray)[*pcntW] = fd;
+                        __STORE(writableResultFdArray, fd);
+                    }
+                    (*pcntW)++; cntAll++;
+                }
+            }
+            for (i = 0; i < exceptCount; i++) {
+                OBJ fd = __arrayVal(exceptFdArray)[i];
+                if ((__Class(fd) == @global(Win32SocketHandle)) && FD_ISSET(_HANDLEVal(fd), &exceptFds)) {
+                    if (*pcntE < resultSizeException) {
+                        __arrayVal(exceptionResultFdArray)[*pcntE] = fd;
+                        __STORE(exceptionResultFdArray, fd);
+                    }
+                    (*pcntE)++; cntAll++;
+                }
+            }
+        }
+        if (tvp && tv.tv_usec != 0 && (numHandles != 0 || numPipes != 0)) {
+            // back after timeout, maybe some handles or pipes did wake up
+            // in the meantime?
+            pass = 2;
+            goto pollAgain;
+        }
     }
 
 done:
     /* add a delimiter */
     if (*pcntR < resultSizeReadable) {
-	__arrayVal(readableResultFdArray)[*pcntR] = nil;
+        __arrayVal(readableResultFdArray)[*pcntR] = nil;
     }
     if (*pcntW < resultSizeWritable) {
-	__arrayVal(writableResultFdArray)[*pcntW] = nil;
+        __arrayVal(writableResultFdArray)[*pcntW] = nil;
     }
     if (*pcntE < resultSizeException) {
-	__arrayVal(exceptionResultFdArray)[*pcntE] = nil;
+        __arrayVal(exceptionResultFdArray)[*pcntE] = nil;
     }
 
     @global(LastErrorNumber) = nil;
--- a/WriteStream.st	Tue Dec 06 07:06:38 2016 +0100
+++ b/WriteStream.st	Sun Dec 18 11:19:27 2016 +0000
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
@@ -256,6 +254,29 @@
 
 !WriteStream methodsFor:'queries'!
 
+endsWith:aCollection
+    "Answer true, if the contents of the stream ends with aCollection.
+     Speedup for upToAll:, throughAll etc."
+
+    |sz start "{ Class: SmallInteger }"|
+
+    collection isNil ifTrue:[
+        "only supported for internal streams"
+        self shouldNotImplement.
+    ].
+
+    sz := aCollection size.
+    start := position + 1 - sz.
+    ^ start > 0 and:[(collection copyFrom:position+1-sz to:position) endsWith:aCollection].
+
+    "
+        (WriteStream with:'abcdef') endsWith:'def'
+        (WriteStream with:'def') endsWith:'def'
+        (WriteStream with:'abc') endsWith:'def'
+        (WriteStream with:'ef') endsWith:'def'
+false    "
+!
+
 size
     "return the current size"