--- a/ZipStream.st Tue Jun 30 17:32:14 2009 +0200
+++ b/ZipStream.st Tue Jun 30 18:07:33 2009 +0200
@@ -245,32 +245,6 @@
!ZipStream class methodsFor:'ZipInterface compatibility - crc'!
-crc32Add:aCharacterOrByte crc:crc
- "Update a running crc waCharacterOrByte
- and return the updated crc "
-%{
- if( (__isInteger(crc))) {
- char __byte;
- uLong __crc;
-
- if (__isCharacter(aCharacterOrByte)) {
- __byte = __characterVal(aCharacterOrByte);
- } else if (__isSmallInteger(aCharacterOrByte)) {
- __byte = __intVal(aCharacterOrByte);
- } else{
- goto err;
- }
-
- __crc = __longIntVal( crc );
- __crc = crc32(__crc, (Byte *) &__byte, 1 );
- RETURN( __MKUINT(__crc) );
- }
-err:;
-%}.
-
- ^ self error:'invalid argument'
-!
-
crc32BytesIn:bytesIn
"compute crc with the bytes buf[1.. bytesIn size]
and return the crc
@@ -308,38 +282,42 @@
crc32BytesIn:bytesIn from:start to:stop crc:crc
"Update a running crc with the bytes buf[start.. stop]
- and return the updated crc"
+ and return the updated
+ "
+ |size|
+
+ size := stop - start + 1.
+ ( (start between:1 and:stop)
+ and:[size > 0
+ and:[bytesIn size >= stop]]
+ ) ifFalse:[
+ ^ self error:'invalid argument size'
+ ].
%{
- if (__isInteger(crc) && __isSmallInteger(start) && __isSmallInteger(stop)) {
- char * __bytes = 0;
- unsigned int __size;
+ if( (__isInteger(crc)) && (__isSmallInteger(start)) && (__isSmallInteger(size)) )
+ {
+ char * __bytes = 0;
- if (__isBytes(bytesIn)) {
- __bytes = __byteArrayVal(bytesIn);
- __size = __byteArraySize(bytesIn);
- } else if (__isString(bytesIn)) {
- __bytes = __stringVal(bytesIn);
- __size = __stringSize(bytesIn);
- } else {
- goto err;
- }
+ if (__isBytes(bytesIn)) {
+ __bytes = __ByteArrayInstPtr(bytesIn)->ba_element;
+ } else {
+ if (__isString(bytesIn)) {
+ __bytes = __stringVal( bytesIn );
+ }
+ }
- uLong __crc = __longIntVal( crc );
- uInt __start = __intVal( start );
- uInt __stop = __intVal( stop );
-
- if (__start < 1 || __start > __size) goto err;
- if (__stop < 1 || __stop > __size) goto err;
+ if( __bytes )
+ {
+ uLong __crc = __longIntVal( crc );
+ uInt __size = __intVal( size );
- __size = __stop - __start + 1;
+ __bytes += (__intVal( start)) - 1;
+ __crc = crc32(__crc, (Byte *) __bytes, __size );
- __bytes += __start - 1;
- __crc = crc32(__crc, (Byte *) __bytes, __size );
-
- RETURN( __MKUINT(__crc) );
+ RETURN( __MKUINT(__crc) );
+ }
}
-err:;
%}.
^ self error:'invalid argument size'
@@ -774,7 +752,7 @@
!ZipStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/ZipStream.st,v 1.31 2009-06-30 15:28:52 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/ZipStream.st,v 1.32 2009-06-30 16:07:33 stefan Exp $'
! !
ZipStream initialize!