--- a/ExternalBytes.st Tue Dec 11 19:55:07 2001 +0100
+++ b/ExternalBytes.st Tue Dec 11 21:03:08 2001 +0100
@@ -745,23 +745,34 @@
int idx;
OBJ sz;
- if (cp && __bothSmallInteger(index, value)) {
- idx = __intVal(index);
- if (idx > 0) {
- if (((sz = __INST(size)) == nil)
- || (__intVal(sz) >= idx)) {
- val = __intVal(value);
- if ((val & ~0xFF) == 0) /* i.e. (val >= 0) && (val <= 255) */ {
- cp[idx-1] = val;
- RETURN ( value );
- }
- }
- }
+ if (__isSmallInteger(value)) {
+ val = __smallIntegerVal(value);
+ } else if (__isCharacter(value)) {
+ val = __smallIntegerVal(_characterVal(value));
+ } else
+ goto badArg;
+
+ if (cp && __isSmallInteger(index)) {
+ idx = __intVal(index);
+ if (idx > 0) {
+ if (((sz = __INST(size)) == nil)
+ || (__intVal(sz) >= idx)) {
+ if ((val & ~0xFF) == 0) /* i.e. (val >= 0) && (val <= 255) */ {
+ cp[idx-1] = val;
+ RETURN ( value );
+ }
+ }
+ }
}
+
+badArg: ;
%}.
(size notNil and:[self address notNil]) ifTrue:[
- ^ self subscriptBoundsError:index
+ (index between:1 and:size) ifTrue:[
+ ^ ElementOutOfBoundsSignal raise
+ ].
+ ^ self subscriptBoundsError:index
].
"
invalid index, invalid value or unallocated
@@ -919,6 +930,6 @@
!ExternalBytes class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.32 2001-11-27 18:17:11 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.33 2001-12-11 20:03:08 cg Exp $'
! !
ExternalBytes initialize!