- MMS: changed handling of variable sized bit strings (now also accepts bit strings of larger size, ignoring the bits that exceed the specified size)

pull/266/head
Michael Zillgith 5 years ago
parent 3f42387ed7
commit a165d1698d

@ -138,11 +138,9 @@ MmsVariableSpecification_isValueOfType(MmsVariableSpecification* self, MmsValue*
if (self->typeSpec.bitString == value->value.bitString.size) if (self->typeSpec.bitString == value->value.bitString.size)
return true; return true;
if (self->typeSpec.bitString < 0) { if (self->typeSpec.bitString < 0)
if (value->value.bitString.size <= (-self->typeSpec.bitString))
return true; return true;
} }
}
else if (self->type == MMS_FLOAT) { else if (self->type == MMS_FLOAT) {
if ((self->typeSpec.floatingpoint.exponentWidth == value->value.floatingPoint.exponentWidth) && if ((self->typeSpec.floatingpoint.exponentWidth == value->value.floatingPoint.exponentWidth) &&
(self->typeSpec.floatingpoint.formatWidth == value->value.floatingPoint.formatWidth)) (self->typeSpec.floatingpoint.formatWidth == value->value.floatingPoint.formatWidth))

@ -259,11 +259,14 @@ MmsValue_update(MmsValue* self, const MmsValue* update)
case MMS_BIT_STRING: case MMS_BIT_STRING:
if (self->value.bitString.size == update->value.bitString.size) if (self->value.bitString.size == update->value.bitString.size)
memcpy(self->value.bitString.buf, update->value.bitString.buf, bitStringByteSize(self)); memcpy(self->value.bitString.buf, update->value.bitString.buf, bitStringByteSize(self));
else if (update->value.bitString.size < self->value.bitString.size) { else if (update->value.bitString.size != self->value.bitString.size) {
int i; int i;
for (i = 0; i < update->value.bitString.size; i++) { for (i = 0; i < update->value.bitString.size; i++) {
if (i < self->value.bitString.size)
MmsValue_setBitStringBit(self, i, MmsValue_getBitStringBit(update, i)); MmsValue_setBitStringBit(self, i, MmsValue_getBitStringBit(update, i));
else
break;
} }
} }
else else

Loading…
Cancel
Save