diff options
author | Lev Walkin <vlm@lionet.info> | 2004-09-08 00:28:57 +0000 |
---|---|---|
committer | Lev Walkin <vlm@lionet.info> | 2004-09-08 00:28:57 +0000 |
commit | 5a8219a11e25be15c47b61362ecd5742143fadcf (patch) | |
tree | 922723a36d37ff14ac69de13cbd9e1c2ff7c0299 /libasn1compiler/asn1c_misc.c | |
parent | 61c7069bd61751d286be99234a29a178c125af56 (diff) |
better handling of recursive definitions
Diffstat (limited to 'libasn1compiler/asn1c_misc.c')
-rw-r--r-- | libasn1compiler/asn1c_misc.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/libasn1compiler/asn1c_misc.c b/libasn1compiler/asn1c_misc.c index 14a3649e..2bdbd7c8 100644 --- a/libasn1compiler/asn1c_misc.c +++ b/libasn1compiler/asn1c_misc.c @@ -85,8 +85,14 @@ asn1c_make_identifier(int unsafe_only_spaces, char *arg1, ...) { char * asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) { + asn1p_expr_t *top_parent; char *typename; + /* Rewind to the topmost parent expression */ + if((top_parent = expr->parent_expr)) + while(top_parent->parent_expr) + top_parent = top_parent->parent_expr; + switch(expr->expr_type) { case A1TC_REFERENCE: typename = expr->reference->components[ @@ -104,7 +110,9 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) { tmp.mod = tmp.expr->module; return asn1c_type_name(&tmp, tmp.expr, _format); - } else if(_format == TNF_RSAFE) { + } + + if(_format == TNF_RSAFE || _format == TNF_CTYPE) { /* * The recursion-safe format is requested. * The problem here is that only constructed types @@ -115,10 +123,13 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) { asn1p_expr_t *terminal; terminal = asn1f_find_terminal_type_ex( arg->asn, arg->mod, arg->expr); - if(terminal - && (terminal->expr_type - & (ASN_BASIC_MASK | ASN_STRING_MASK))) - _format = TNF_CTYPE; + if(terminal) { + if(terminal->expr_type + & (ASN_BASIC_MASK | ASN_STRING_MASK)) + _format = TNF_CTYPE; + if(terminal == top_parent) + _format = TNF_RSAFE; + } } break; #if 0 |