aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLev Walkin <vlm@lionet.info>2005-03-04 23:23:50 +0000
committerLev Walkin <vlm@lionet.info>2005-03-04 23:23:50 +0000
commit6938d0446baeb98875472055077f143e385756f4 (patch)
treed35a6703d9056fc7437071424ee5e61f53986cc0
parentfe7f6ecdddf550f56e7fc20a3e53d420796448e7 (diff)
refactoring
-rw-r--r--asn1c/tests/check-50.c23
-rw-r--r--libasn1compiler/asn1c_C.c4
-rw-r--r--libasn1compiler/asn1c_constraint.c25
-rw-r--r--libasn1parser/asn1p_constr.h1
4 files changed, 37 insertions, 16 deletions
diff --git a/asn1c/tests/check-50.c b/asn1c/tests/check-50.c
new file mode 100644
index 00000000..cfdd6006
--- /dev/null
+++ b/asn1c/tests/check-50.c
@@ -0,0 +1,23 @@
+#undef NDEBUG
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <string.h>
+#include <assert.h>
+
+#include <Int5.h>
+#include <Str4.h>
+#include <Utf8-4.h>
+#include <VisibleIdentifier.h>
+
+int
+main(int ac, char **av) {
+ (void)ac; /* Unused argument */
+ (void)av; /* Unused argument */
+
+ /*
+ * No plans to fill it up: just checking whether it compiles or not.
+ */
+
+ return 0;
+}
diff --git a/libasn1compiler/asn1c_C.c b/libasn1compiler/asn1c_C.c
index df02e95b..1440ef5a 100644
--- a/libasn1compiler/asn1c_C.c
+++ b/libasn1compiler/asn1c_C.c
@@ -967,7 +967,9 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
}
if((!expr->constraints || (arg->flags & A1C_NO_CONSTRAINTS))
&& (arg->embed || expr->tag.tag_class == TC_NOCLASS)
- && etd_spec == ETD_NO_SPECIFICS) {
+ && etd_spec == ETD_NO_SPECIFICS
+ && 0 /* This shortcut is incompatible with XER */
+ ) {
char *type_name;
REDIR(OT_FUNC_DECLS);
type_name = asn1c_type_name(arg, expr, TNF_SAFE);
diff --git a/libasn1compiler/asn1c_constraint.c b/libasn1compiler/asn1c_constraint.c
index 67b45bfc..0729d08e 100644
--- a/libasn1compiler/asn1c_constraint.c
+++ b/libasn1compiler/asn1c_constraint.c
@@ -13,8 +13,6 @@ static int emit_size_determination_code(arg_t *arg, asn1p_expr_type_e etype);
static asn1p_expr_type_e _find_terminal_type(arg_t *arg);
static int emit_range_comparison_code(arg_t *arg, asn1cnst_range_t *range, const char *varname, asn1c_integer_t natural_start, asn1c_integer_t natural_stop);
-static int global_compile_mark;
-
int
asn1c_emit_constraint_checking_code(arg_t *arg) {
asn1cnst_range_t *r_size;
@@ -23,6 +21,7 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
asn1p_expr_type_e etype;
asn1p_constraint_t *ct;
int got_something = 0;
+ int alphabet_table_compiled;
int produce_st = 0;
ct = expr->combined_constraints;
@@ -125,7 +124,8 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
INDENT(-1);
REDIR(OT_CTABLES);
/* Emit FROM() tables */
- asn1c_emit_constraint_tables(arg, r_size?1:0);
+ alphabet_table_compiled =
+ (asn1c_emit_constraint_tables(arg, r_size?1:0) == 1);
REDIR(OT_CODE);
INDENT(+1);
@@ -152,10 +152,11 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
"value", -1, -1);
OUT(")");
}
- if(ct->_compile_mark) {
+ if(alphabet_table_compiled) {
if(got_something++) { OUT("\n"); OUT(" && "); }
- OUT("!check_permitted_alphabet_%d(sptr)",
- ct->_compile_mark);
+ OUT("!check_permitted_alphabet_%d(%s)",
+ arg->expr->_type_unique_index,
+ produce_st ? "st" : "sptr");
}
if(!got_something) {
OUT("1 /* No applicable constraints whatsoever */");
@@ -252,9 +253,6 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
max_table_size = 128;
}
- if(!ct->_compile_mark)
- ct->_compile_mark = ++global_compile_mark;
-
if(use_table) {
int i, n = 0;
int untl;
@@ -278,7 +276,7 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
untl = (range_stop - range_start) + 1;
untl += (untl % 16)?16 - (untl % 16):0;
OUT("static int permitted_alphabet_table_%d[%d] = {\n",
- ct->_compile_mark, max_table_size);
+ arg->expr->_type_unique_index, max_table_size);
for(n = 0; n < untl; n++) {
OUT("%d,", table[n]?1:0);
if(!((n+1) % 16)) {
@@ -316,7 +314,6 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
* for the syntax validity, so we don't have
* to repeat this process twice.
*/
- ct->_compile_mark = 0; /* Don't generate code */
asn1constraint_range_free(range);
return 0;
} else {
@@ -332,7 +329,7 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
}
OUT("static int check_permitted_alphabet_%d(const void *sptr) {\n",
- ct->_compile_mark);
+ arg->expr->_type_unique_index);
INDENT(+1);
if(utf8_full_alphabet_check) {
OUT("if(UTF8String_length((const UTF8String_t *)sptr) < 0)\n");
@@ -341,7 +338,7 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
} else {
if(use_table) {
OUT("int *table = permitted_alphabet_table_%d;\n",
- ct->_compile_mark);
+ arg->expr->_type_unique_index);
emit_alphabet_check_loop(arg, 0);
} else {
emit_alphabet_check_loop(arg, range);
@@ -354,7 +351,7 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
asn1constraint_range_free(range);
- return 0;
+ return 1;
}
static int
diff --git a/libasn1parser/asn1p_constr.h b/libasn1parser/asn1p_constr.h
index 7c425b45..27369fdd 100644
--- a/libasn1parser/asn1p_constr.h
+++ b/libasn1parser/asn1p_constr.h
@@ -57,7 +57,6 @@ typedef struct asn1p_constraint_s {
unsigned int el_size; /* Size of the allocated (elements) */
int _lineno; /* Position in a source file */
- int _compile_mark; /* Marker used by the compiler */
} asn1p_constraint_t;
/* Human-readable constraint type description */