ignore junk at the end of the bitmap (comments etc)
authorClaus Gittinger <cg@exept.de>
Thu, 13 Sep 2001 11:01:37 +0200
changeset 1506 60e56746dce6
parent 1505 c7cd2082381b
child 1507 9bae072abf64
ignore junk at the end of the bitmap (comments etc)
XBMReader.st
--- a/XBMReader.st	Wed Sep 12 17:33:16 2001 +0200
+++ b/XBMReader.st	Thu Sep 13 11:01:37 2001 +0200
@@ -229,18 +229,24 @@
     ].
 
     [lineString notNil] whileTrue:[
-        index := 1.
-        [index ~~ 0] whileTrue:[
-            index := lineString indexOf:$x startingAt:index.
-            (index ~~ 0) ifTrue:[
-                index := index + 1.
-                hi := (lineString at:index) digitValue.
-                index := index + 1.
-                lo := (lineString at:index) digitValue.
-                val := (hi bitShift:4) bitOr:lo.
-                data at:dstIndex put:(reverseBits at:(val + 1)).
-                dstIndex := dstIndex + 1
-            ]
+        dstIndex <= data size ifTrue:[
+            index := 1.
+            [index ~~ 0] whileTrue:[
+                dstIndex <= data size ifTrue:[
+                    index := lineString indexOf:$x startingAt:index.
+                    (index ~~ 0) ifTrue:[
+                        index := index + 1.
+                        hi := (lineString at:index) digitValue.
+                        index := index + 1.
+                        lo := (lineString at:index) digitValue.
+                        val := (hi bitShift:4) bitOr:lo.
+                        data at:dstIndex put:(reverseBits at:(val + 1)).
+                        dstIndex := dstIndex + 1
+                    ]
+                ] ifFalse:[
+                    index := 0. "/ break loop
+                ] 
+            ].
         ].
         lineString := aStream nextLine.
         [lineString notNil and:[lineString isEmpty]] whileTrue:[
@@ -345,6 +351,6 @@
 !XBMReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/XBMReader.st,v 1.42 2001-08-22 16:38:44 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/XBMReader.st,v 1.43 2001-09-13 09:01:37 cg Exp $'
 ! !
 XBMReader initialize!