aboutsummaryrefslogtreecommitdiffstats
path: root/libasn1compiler
diff options
context:
space:
mode:
authorLev Walkin <vlm@lionet.info>2006-09-21 01:50:13 +0000
committerLev Walkin <vlm@lionet.info>2006-09-21 01:50:13 +0000
commit729eb86bb0e169f4e0cf7715ef5242aea69e8c42 (patch)
tree4823787f4c45c56822c837b8b19b431bc0de0582 /libasn1compiler
parentf714ecdf5b4f528196a47ed43406d7ceb5ec9e70 (diff)
generate PER code tables for known-multiplier strings
Diffstat (limited to 'libasn1compiler')
-rw-r--r--libasn1compiler/asn1c_C.c7
-rw-r--r--libasn1compiler/asn1c_constraint.c27
2 files changed, 29 insertions, 5 deletions
diff --git a/libasn1compiler/asn1c_C.c b/libasn1compiler/asn1c_C.c
index 18879d18..2acb5ea3 100644
--- a/libasn1compiler/asn1c_C.c
+++ b/libasn1compiler/asn1c_C.c
@@ -1905,6 +1905,13 @@ emit_single_member_PER_constraints(arg_t *arg, asn1p_expr_t *expr) {
tmprng.right.value = eidx < 0 ? 0 : eidx;
if(emit_single_member_PER_constraint(arg, &tmprng, 0))
return -1;
+ } else if(etype & ASN_STRING_KM_MASK) {
+ range = asn1constraint_compute_PER_range(etype,
+ expr->combined_constraints, ACT_CT_FROM,
+ 0, 0, 0);
+ if(emit_single_member_PER_constraint(arg, range, 0))
+ return -1;
+ asn1constraint_range_free(range);
} else {
range = asn1constraint_compute_PER_range(etype,
expr->combined_constraints, ACT_EL_RANGE,
diff --git a/libasn1compiler/asn1c_constraint.c b/libasn1compiler/asn1c_constraint.c
index 74bbb7af..da54f440 100644
--- a/libasn1compiler/asn1c_constraint.c
+++ b/libasn1compiler/asn1c_constraint.c
@@ -31,7 +31,7 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
etype = _find_terminal_type(arg);
r_value=asn1constraint_compute_PER_range(etype, ct, ACT_EL_RANGE,0,0,0);
- r_size = asn1constraint_compute_PER_range(etype, ct, ACT_CT_SIZE,0,0,0);
+ r_size =asn1constraint_compute_PER_range(etype, ct, ACT_CT_SIZE, 0,0,0);
if(r_value) {
if(r_value->incompatible
|| r_value->empty_constraint
@@ -133,7 +133,7 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
INDENT(+1);
/*
- * Here is an if() {} else {} constaint checking code.
+ * Here is an if() {} else {} consrtaint checking code.
*/
OUT("\n");
OUT("if(");
@@ -251,7 +251,7 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
if(range->el_count == 0) {
/*
* It's better to have a short if() check
- * than waste 4k of table space
+ * than waste 1k of table space
*/
use_table = 0;
}
@@ -265,6 +265,7 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
}
if(use_table) {
+ int cardinal = 0;
int i, n = 0;
int untl;
memset(table, 0, sizeof(table));
@@ -289,10 +290,11 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
OUT("static int permitted_alphabet_table_%d[%d] = {\n",
arg->expr->_type_unique_index, max_table_size);
for(n = 0; n < untl; n++) {
- OUT("%d,", table[n]?1:0);
+ cardinal += table[n] ? 1 : 0;
+ OUT("%2d,", table[n]);
if(!((n+1) % 16)) {
int c;
- if(!n) {
+ if(!n || (n-15) + range_start >= 0x80) {
OUT("\n");
continue;
}
@@ -313,6 +315,21 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
}
}
OUT("};\n");
+
+ if((arg->flags & A1C_GEN_PER)) {
+ int c;
+ OUT("static int permitted_alphabet_code2value_%d[%d] = {\n",
+ arg->expr->_type_unique_index, cardinal);
+ for(n = c = 0; c < max_table_size; c++) {
+ if(table[c]) {
+ OUT("%d,", c);
+ if(!((++n) % 16)) OUT("\n");
+ }
+ }
+ OUT("};\n");
+ OUT("\n");
+ }
+
OUT("\n");
} else if(etype == ASN_STRING_UTF8String) {
/*