ObjectSets
diff --git a/libasn1fix/asn1fix_constraint.c b/libasn1fix/asn1fix_constraint.c
index 23709a4..7477d72 100644
--- a/libasn1fix/asn1fix_constraint.c
+++ b/libasn1fix/asn1fix_constraint.c
@@ -195,7 +195,6 @@
* Resolve all possible references, wherever they occur.
*/
if(ct->containedSubtype) {
- assert(ct->containedSubtype->type == ATV_REFERENCED);
ret = constraint_type_resolve(arg, ct);
RET2RVAL(ret, rvalue);
}
@@ -250,60 +249,68 @@
static int
constraint_type_resolve(arg_t *arg, asn1p_constraint_t *ct) {
- asn1p_expr_t *rtype;
- arg_t tmparg;
+ asn1p_constraint_t *ct_expr;
int ret;
DEBUG("(\"%s\")", asn1f_printable_value(ct->containedSubtype));
- assert(ct->containedSubtype->type == ATV_REFERENCED);
+ if(ct->containedSubtype->type == ATV_VALUESET) {
+ ct_expr = ct->containedSubtype->value.constraint;
+ DEBUG("Found %s in constraints", "ValueSet");
+ } else if(ct->containedSubtype->type == ATV_REFERENCED) {
+ asn1p_expr_t *rtype;
+ arg_t tmparg;
- rtype = asn1f_lookup_symbol(arg, arg->expr->module,
- arg->expr->rhs_pspecs,
- ct->containedSubtype->value.reference);
- if(!rtype) {
- FATAL("Cannot find type \"%s\" in constraints at line %d",
- asn1f_printable_value(ct->containedSubtype),
- ct->_lineno);
+ rtype = asn1f_lookup_symbol(arg, arg->expr->module,
+ arg->expr->rhs_pspecs,
+ ct->containedSubtype->value.reference);
+ if(!rtype) {
+ FATAL("Cannot find type \"%s\" in constraints "
+ "at line %d",
+ asn1f_printable_value(ct->containedSubtype),
+ ct->_lineno);
+ return -1;
+ }
+
+ tmparg = *arg;
+ tmparg.expr = rtype;
+ tmparg.mod = rtype->module;
+ ret = asn1constraint_pullup(&tmparg);
+ if(ret) return ret;
+
+ ct_expr = rtype->combined_constraints;
+ if(!ct_expr) return 0;
+ } else {
+ FATAL("Unsupported feature at line %d", ct->_lineno);
return -1;
}
+ ct_expr = asn1p_constraint_clone(ct_expr);
+ assert(ct_expr);
- tmparg = *arg;
- tmparg.expr = rtype;
- tmparg.mod = rtype->module;
- ret = asn1constraint_pullup(&tmparg);
- if(ret) return ret;
+ _remove_extensions(arg, ct_expr);
- if(rtype->combined_constraints) {
- asn1p_constraint_t *ct_expr;
- ct_expr = asn1p_constraint_clone(rtype->combined_constraints);
- assert(ct_expr);
-
- _remove_extensions(arg, ct_expr);
-
- if(ct_expr->type == ACT_CA_SET) {
- unsigned int i;
- for(i = 0; i < ct_expr->el_count; i++) {
- if(asn1p_constraint_insert(
- ct, ct_expr->elements[i])) {
- asn1p_constraint_free(ct_expr);
- return -1;
- } else {
- ct_expr->elements[i] = 0;
- }
+ if(ct_expr->type == ACT_CA_SET) {
+ unsigned int i;
+ for(i = 0; i < ct_expr->el_count; i++) {
+ if(asn1p_constraint_insert(
+ ct, ct_expr->elements[i])) {
+ asn1p_constraint_free(ct_expr);
+ return -1;
+ } else {
+ ct_expr->elements[i] = 0;
}
- asn1p_constraint_free(ct_expr);
- } else {
- ret = asn1p_constraint_insert(ct, ct_expr);
- assert(ret == 0);
}
-
- ct->type = ACT_CA_SET;
- asn1p_value_free(ct->containedSubtype);
- ct->containedSubtype = NULL;
+ asn1p_constraint_free(ct_expr);
+ } else {
+ ret = asn1p_constraint_insert(ct, ct_expr);
+ assert(ret == 0);
}
+ ct->type = ACT_CA_SET;
+ asn1p_value_free(ct->containedSubtype);
+ ct->containedSubtype = NULL;
+
return 0;
}
diff --git a/libasn1fix/asn1fix_misc.c b/libasn1fix/asn1fix_misc.c
index 5728bd4..72317aa 100644
--- a/libasn1fix/asn1fix_misc.c
+++ b/libasn1fix/asn1fix_misc.c
@@ -160,6 +160,8 @@
assert(reflen == (size_t)(ptr - managedptr));
return managedptr;
}
+ case ATV_VALUESET:
+ return "<ValueSet>";
case ATV_CHOICE_IDENTIFIER:
{
char *cid = v->value.choice_identifier.identifier;
diff --git a/libasn1fix/asn1fix_param.c b/libasn1fix/asn1fix_param.c
index 4c87afc..6b3a629 100644
--- a/libasn1fix/asn1fix_param.c
+++ b/libasn1fix/asn1fix_param.c
@@ -133,9 +133,11 @@
return NULL;
}
- DEBUG("Found target %s", expr->Identifier);
+ DEBUG("Found target %s (%d/%x)",
+ expr->Identifier, expr->meta_type, expr->expr_type);
if(expr->meta_type == AMT_TYPE
- || expr->meta_type == AMT_VALUE) {
+ || expr->meta_type == AMT_VALUE
+ || expr->meta_type == AMT_VALUESET) {
DEBUG("Target is a simple type %s",
ASN_EXPR_TYPE2STR(expr->expr_type));
nex = asn1p_expr_clone(expr, 0);
@@ -144,8 +146,10 @@
? strdup(expr_to_resolve->Identifier) : 0;
return nex;
} else {
- FATAL("Feature not implemented for %s",
- rarg->original_expr->Identifier);
+ FATAL("Feature not implemented for %s (%d/%x), "
+ "please contact the asn1c author",
+ rarg->original_expr->Identifier,
+ expr->meta_type, expr->expr_type);
errno = EPERM;
return NULL;
}