- if(ct && ct->range_bits >= 0) {
- if(present < ct->lower_bound
- || present > ct->upper_bound) {
- if(ct->flags & APC_EXTENSIBLE) {
- if(per_put_few_bits(po, 1, 1))
- ASN__ENCODE_FAILED;
- } else {
- ASN__ENCODE_FAILED;
- }
- ct = 0;
- }
+ if(ct && (ct->range_bits >= 0)) {
+ // Value is not within the range of the primary values ?
+ if(present < ct->lower_bound || present > ct->upper_bound) {
+ if(ct->flags & APC_EXTENSIBLE) {
+ ASN_DEBUG("CHOICE member %d (enc %d) is an extension (%ld..%ld)",
+ present, present_enc, ct->lower_bound, ct->upper_bound);
+ // X691/23.5 Extension marker = 1
+ if(per_put_few_bits(po, 1, 1)) {
+ ASN__ENCODE_FAILED;
+ }
+ } else {
+ ASN__ENCODE_FAILED;
+ }
+ // no more need of constraint.
+ ext_ct = ct;
+ ct = NULL;
+ }