#BUGFIX by cg
authorClaus Gittinger <cg@exept.de>
Mon, 01 Apr 2019 17:19:04 +0200
changeset 24032 a89bc30b9339
parent 24031 46f45f402974
child 24033 d55b7d2b22fa
#BUGFIX by cg class: WriteStream writeLimit handling comment/format in: #nextPut: changed: #nextPutAll: #nextPutAll:startingAt:to: #nextPutByte:
WriteStream.st
--- a/WriteStream.st	Mon Apr 01 17:18:24 2019 +0200
+++ b/WriteStream.st	Mon Apr 01 17:19:04 2019 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
@@ -518,8 +516,7 @@
     }
 #endif
 %}.
-    (writeLimit isNil
-    or:[(position + 1) <= writeLimit]) ifTrue:[
+    (writeLimit isNil or:[(position + 1) <= writeLimit]) ifTrue:[
         (position >= collection size) ifTrue:[self growCollection].
         collection at:(position + 1) put:anObject.
         position := position + 1.
@@ -553,26 +550,24 @@
     ].
 
     final := position + nMore.
-    (writeLimit notNil
-    and:[final > writeLimit]) ifTrue:[
-        final := writeLimit.
-        nMore := final - position
+    (writeLimit notNil and:[final > writeLimit]) ifTrue:[
+        "/ cg: the code below silently truncated the written string,
+        "/ which is incorrect, as it should report a writeError!!
+        ^ super nextPutAll:aCollection.
+        "/ final := writeLimit.
+        "/ nMore := final - position
     ].
     (final > collection size) ifTrue:[
         self growCollection:final
     ].
-    collection
-        replaceFrom:(position + 1)
-        to:final
-        with:aCollection
-        startingAt:1.
+    collection replaceFrom:(position + 1) to:final with:aCollection startingAt:1.
 
     position := position + nMore.
     (position > readLimit) ifTrue:[readLimit := position].
     "/ ^ aCollection -- self
 
     "Modified: / 04-09-2011 / 20:03:32 / cg"
-    "Modified: / 24-05-2018 / 21:05:56 / Claus Gittinger"
+    "Modified: / 01-04-2019 / 17:05:36 / Claus Gittinger"
 !
 
 nextPutAll:aCollection startingAt:pos1 to:pos2
@@ -588,19 +583,18 @@
 
     nMore := pos2 - pos1 + 1.
     final := position + nMore.
-    (writeLimit notNil
-    and:[final > writeLimit]) ifTrue:[
-        final := writeLimit.
-        nMore := final - position
+    (writeLimit notNil and:[final > writeLimit]) ifTrue:[
+        "/ cg: the code below silently truncated the written string,
+        "/ which is incorrect, as it should report a writeError!!
+        ^ super nextPutAll:aCollection startingAt:pos1 to:pos2.
+        "/ final := writeLimit.
+        "/ nMore := final - position
     ].
     (final > collection size) ifTrue:[
         self growCollection:final
     ].
 
-    collection replaceFrom:position + 1
-                        to:final
-                      with:aCollection
-                startingAt:pos1.
+    collection replaceFrom:(position + 1) to:final with:aCollection startingAt:pos1.
 
     position := position + nMore.
     (position > readLimit) ifTrue:[readLimit := position].
@@ -615,7 +609,8 @@
      s contents
     "
 
-    "Modified: 12.7.1996 / 10:31:36 / cg"
+    "Modified: / 12-07-1996 / 10:31:36 / cg"
+    "Modified: / 01-04-2019 / 17:05:52 / Claus Gittinger"
 !
 
 nextPutAllUnicode:aString
@@ -653,8 +648,8 @@
         INT pos = __intVal(p) + 1;    /* make 1-based and usable for update below */
         unsigned int ch = __intVal(anObject);
 
-        if (ch <= 0xFF &&  /* ch is unsigned */
-            ((wL == nil) || (__isSmallInteger(wL) && (pos <= __intVal(wL))))) {
+        if ((ch <= 0xFF)  /* ch is unsigned */
+         && ((wL == nil) || (__isSmallInteger(wL) && (pos <= __intVal(wL))))) {
             OBJ cls = __qClass(coll);
             OBJ rL = __INST(readLimit);
             INT __readLimit = -1;