aboutsummaryrefslogtreecommitdiffstats
path: root/libasn1fix
diff options
context:
space:
mode:
authorLev Walkin <vlm@lionet.info>2006-08-28 02:45:44 +0000
committerLev Walkin <vlm@lionet.info>2006-08-28 02:45:44 +0000
commitfbfc7bcb2fbf3e377d387396ff4c656b981917ec (patch)
treea274f3e0e4c490161f433b4634a5b7ef721832b2 /libasn1fix
parent62e48d3deab81f18a1e3e94214a478040d9ef58e (diff)
declashing
Diffstat (limited to 'libasn1fix')
-rw-r--r--libasn1fix/asn1fix.c2
-rw-r--r--libasn1fix/asn1fix_bitstring.c16
-rw-r--r--libasn1fix/asn1fix_enum.c2
-rw-r--r--libasn1fix/asn1fix_integer.c5
-rw-r--r--libasn1fix/asn1fix_misc.c25
-rw-r--r--libasn1fix/asn1fix_misc.h10
6 files changed, 31 insertions, 29 deletions
diff --git a/libasn1fix/asn1fix.c b/libasn1fix/asn1fix.c
index 05118682..8d2317f4 100644
--- a/libasn1fix/asn1fix.c
+++ b/libasn1fix/asn1fix.c
@@ -385,7 +385,7 @@ asn1f_fix_constructed(arg_t *arg) {
}
/* Check identifier distinctness */
- ret = asn1f_check_unique_expr(arg, NULL);
+ ret = asn1f_check_unique_expr(arg);
RET2RVAL(ret, rvalue);
/* Fix extensibility */
diff --git a/libasn1fix/asn1fix_bitstring.c b/libasn1fix/asn1fix_bitstring.c
index f3d5ad73..5f30ea4f 100644
--- a/libasn1fix/asn1fix_bitstring.c
+++ b/libasn1fix/asn1fix_bitstring.c
@@ -32,6 +32,10 @@ asn1f_fix_bit_string(arg_t *arg) {
return r_value;
}
+static int _compare_value(asn1p_expr_t *expr1, asn1p_expr_t *expr2) {
+ return expr2->value->value.v_integer - expr1->value->value.v_integer;
+}
+
static int
asn1f_fix_bit_string_type(arg_t *arg) {
asn1p_expr_t *expr = arg->expr;
@@ -40,10 +44,6 @@ asn1f_fix_bit_string_type(arg_t *arg) {
int ret;
TQ_FOR(v, &(expr->members), next) {
- /* Check identifier uniqueness as per 21.4 */
- ret = asn1f_check_unique_expr_child(arg, v, 0);
- RET2RVAL(ret, r_value);
-
if(v->expr_type == A1TC_EXTENSIBLE) {
FATAL("Extension marker (...) is not allowed "
"as a BIT STRING NamedBit at line %d ",
@@ -74,6 +74,14 @@ asn1f_fix_bit_string_type(arg_t *arg) {
v->_lineno);
return -1;
}
+
+ /* Check value uniqueness as per 21.4 */
+ ret = asn1f_check_unique_expr_child(arg, v,
+ _compare_value, "value");
+ RET2RVAL(ret, r_value);
+ /* Check identifier uniqueness as per 21.5 */
+ ret = asn1f_check_unique_expr_child(arg, v, 0, "identifier");
+ RET2RVAL(ret, r_value);
}
return r_value;
diff --git a/libasn1fix/asn1fix_enum.c b/libasn1fix/asn1fix_enum.c
index cf03914f..570d23ae 100644
--- a/libasn1fix/asn1fix_enum.c
+++ b/libasn1fix/asn1fix_enum.c
@@ -119,7 +119,7 @@ asn1f_fix_enum(arg_t *arg) {
* 1.4 Check that all identifiers before the current one
* differs from it.
*/
- ret = asn1f_check_unique_expr_child(arg, ev, NULL);
+ ret = asn1f_check_unique_expr_child(arg, ev, 0, "identifier");
RET2RVAL(ret, rvalue);
}
diff --git a/libasn1fix/asn1fix_integer.c b/libasn1fix/asn1fix_integer.c
index 0302acd2..a5d0b6e7 100644
--- a/libasn1fix/asn1fix_integer.c
+++ b/libasn1fix/asn1fix_integer.c
@@ -92,12 +92,13 @@ asn1f_fix_integer(arg_t *arg) {
/*
* Check that all identifiers are distinct.
*/
- ret = asn1f_check_unique_expr_child(arg, iv, NULL);
+ ret = asn1f_check_unique_expr_child(arg, iv, 0, "identifier");
RET2RVAL(ret, rvalue);
/*
* Check that all values are distinct.
*/
- ret = asn1f_check_unique_expr_child(arg, iv, _compare_value);
+ ret = asn1f_check_unique_expr_child(arg, iv,
+ _compare_value, "value");
RET2RVAL(ret, rvalue);
}
diff --git a/libasn1fix/asn1fix_misc.c b/libasn1fix/asn1fix_misc.c
index 9e8cc07f..4af0fd8c 100644
--- a/libasn1fix/asn1fix_misc.c
+++ b/libasn1fix/asn1fix_misc.c
@@ -236,15 +236,14 @@ asn1f_recurse_expr(arg_t *arg, int (*callback)(arg_t *arg)) {
* Check that every child of a given expr has unique name or does not have any.
*/
int
-asn1f_check_unique_expr(arg_t *arg,
- int (*opt_compare)(asn1p_expr_t *a, asn1p_expr_t *b)) {
+asn1f_check_unique_expr(arg_t *arg) {
asn1p_expr_t *expr;
int rvalue = 0;
TQ_FOR(expr, &(arg->expr->members), next) {
if(expr->Identifier) {
int ret = asn1f_check_unique_expr_child(arg, expr,
- opt_compare);
+ 0, "identifier");
if(ret) rvalue = -1;
} else {
/*
@@ -263,9 +262,11 @@ asn1f_check_unique_expr(arg_t *arg,
*/
int
asn1f_check_unique_expr_child(arg_t *arg, asn1p_expr_t *child,
- int (*opt_compare)(asn1p_expr_t *a, asn1p_expr_t *b)) {
+ int (*opt_compare)(asn1p_expr_t *a, asn1p_expr_t *b),
+ const char *opt_property_name) {
asn1p_expr_t *expr;
- int rvalue = 0;
+
+ if(!opt_property_name) opt_property_name = "property";
assert(child);
assert(opt_compare || child->Identifier);
@@ -290,26 +291,20 @@ asn1f_check_unique_expr_child(arg_t *arg, asn1p_expr_t *child,
}
if(ret == 0) {
- char *msg;
- msg = opt_compare
- ?"Expressions clash"
- :"Identifiers name clash";
- FATAL("%s: "
+ FATAL("Clash detected: "
"\"%s\" at line %d has similar %s with "
"\"%s\" at line %d",
- msg,
expr->Identifier,
expr->_lineno,
- opt_compare?"property":"name",
+ opt_property_name,
child->Identifier,
child->_lineno
);
-
- rvalue = -1;
+ return -1;
}
}
- return rvalue;
+ return 0;
}
int
diff --git a/libasn1fix/asn1fix_misc.h b/libasn1fix/asn1fix_misc.h
index a90c5bed..6dcd220d 100644
--- a/libasn1fix/asn1fix_misc.h
+++ b/libasn1fix/asn1fix_misc.h
@@ -11,12 +11,9 @@
int asn1f_recurse_expr(arg_t *arg, int (*f)(arg_t *arg));
/*
- * Check that every child of a given expr has unique name or does not have any.
- * If opt_compare == NULL, the default comparison of the argument's
- * names (identifiers) will be performed.
+ * Check that every child of a given expr has unique identifier.
*/
-int asn1f_check_unique_expr(arg_t *arg,
- int (*opt_compare)(asn1p_expr_t *a, asn1p_expr_t *b));
+int asn1f_check_unique_expr(arg_t *arg);
/*
* Check that every preceeding child of the given expr is not
@@ -25,7 +22,8 @@ int asn1f_check_unique_expr(arg_t *arg,
* names (identifiers) will be performed.
*/
int asn1f_check_unique_expr_child(arg_t *arg, asn1p_expr_t *child,
- int (*opt_compare)(asn1p_expr_t *a, asn1p_expr_t *b));
+ int (*opt_compare)(asn1p_expr_t *a, asn1p_expr_t *b),
+ const char *opt_property_name);
/*
* Return number of children.