Commit 2e9bd5c7 authored by Lev Walkin's avatar Lev Walkin
Browse files

groking obsolete syntax

parent b36317c2
0.9.17: 2005-Aug-11
0.9.17: 2005-Aug-13
* ...
* The obsolete X.208 syntax is handled gracefully now (compound types'
member names are invented on the fly). (Test case 87).
0.9.17: 2005-Aug-07
......
This diff is collapsed.
......@@ -29,8 +29,8 @@ extern int asn1p_lineno;
*/
static struct AssignedIdentifier *saved_aid;
static asn1p_value_t *
_convert_bitstring2binary(char *str, int base);
static asn1p_value_t *_convert_bitstring2binary(char *str, int base);
static void _fixup_anonymous_identifier(asn1p_expr_t *expr);
#define checkmem(ptr) do { \
if(!(ptr)) \
......@@ -901,6 +901,11 @@ ComponentType:
| ExtensionAndException {
$$ = $1;
}
| Type optMarker {
$$ = $1;
$$->marker = $2;
_fixup_anonymous_identifier($$);
}
;
AlternativeTypeLists:
......@@ -924,6 +929,10 @@ AlternativeType:
| ExtensionAndException {
$$ = $1;
}
| Type {
$$ = $1;
_fixup_anonymous_identifier($$);
}
;
ClassDeclaration:
......@@ -2184,6 +2193,48 @@ _convert_bitstring2binary(char *str, int base) {
return val;
}
/*
* For unnamed types (used in old X.208 compliant modules)
* generate some sort of interim names, to not to force human being to fix
* the specification's compliance to modern ASN.1 standards.
*/
static void
_fixup_anonymous_identifier(asn1p_expr_t *expr) {
char *p;
assert(expr->Identifier == 0);
/*
* Try to figure out the type name
* without going too much into details
*/
expr->Identifier = ASN_EXPR_TYPE2STR(expr->expr_type);
if(expr->reference && expr->reference->comp_count > 0)
expr->Identifier = expr->reference->components[0].name;
fprintf(stderr,
"WARNING: Line %d: expected lower-case member identifier, "
"found an unnamed %s.\n"
"WARNING: Obsolete X.208 syntax detected, "
"please give the member a name.\n",
yylineno, expr->Identifier ? expr->Identifier : "type");
if(!expr->Identifier)
expr->Identifier = "unnamed";
expr->Identifier = strdup(expr->Identifier);
assert(expr->Identifier);
/* Make a lowercase identifier from the type name */
for(p = expr->Identifier; *p; p++) {
switch(*p) {
case 'A' ... 'Z': *p += 32; break;
case ' ': *p = '_'; break;
case '-': *p = '_'; break;
}
}
fprintf(stderr, "NOTE: Assigning temporary identifier \"%s\". "
"Name clash may occur later.\n",
expr->Identifier);
}
extern char *asn1p_text;
int
......
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .87
ModuleObsoleteSyntax
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 87 }
DEFINITIONS ::=
BEGIN
Tc ::= CHOICE {
INTEGER,
BOOLEAN
}
Ts ::= SET {
INTEGER,
BOOLEAN,
SEQUENCE {
OBJECT IDENTIFIER,
RELATIVE-OID,
Tc
}
}
END
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment