--- a/Diff2.st Thu Apr 05 18:53:51 2012 +0100
+++ b/Diff2.st Fri Apr 06 16:56:16 2012 +0100
@@ -382,6 +382,18 @@
extractFrom: aCollection
"Extracts a subcollection from aCollection corresponding to my offset and length."
^ aCollection copyFrom: offset to: offset + length - 1.
+!
+
+extractSafeFrom: aCollection
+ "Extracts a subcollection from aCollection corresponding to my offset and length.
+ Returns nil if extraction fails (out of bounds)"
+ ^((offset <= aCollection size) and:[(offset + length - 1) <= aCollection size]) ifTrue:[
+ aCollection copyFrom: offset to: offset + length - 1
+ ] ifFalse:[
+ nil
+ ].
+
+ "Created: / 06-04-2012 / 12:37:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!Diff2::Chunk methodsFor:'comparing'!
@@ -814,5 +826,5 @@
!Diff2 class methodsFor:'documentation'!
version_SVN
- ^ '$Id: Diff2.st 7936 2012-03-16 22:44:50Z vranyj1 $'
+ ^ '$Id: Diff2.st 7973 2012-04-06 15:56:16Z vranyj1 $'
! !