aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-05-27 13:41:42 +0200
committerBjörn Gustavsson <[email protected]>2013-06-07 17:42:57 +0200
commit69f02872020636d3efbbecf4bd3de7196040f6a9 (patch)
treefc78261c25833a50c379dbc84f4d29d2cb89eed4 /lib/asn1/src
parentf7295b48627fb84bceef61044b6f2d0cbee10c2b (diff)
downloadotp-69f02872020636d3efbbecf4bd3de7196040f6a9.tar.gz
otp-69f02872020636d3efbbecf4bd3de7196040f6a9.tar.bz2
otp-69f02872020636d3efbbecf4bd3de7196040f6a9.zip
PER, UPER: Fix record name mismatch between HRL file and decoding code
When a SEQUENCE was defined inline inside extension addition group like this: InlinedSeq ::= SEQUENCE { ..., [[ s SEQUENCE { a INTEGER, b BOOLEAN } ]] } the decoding code would return the contents of the SEQUENCE in a record named 'InlinedSeq_ExtAddGroup1_s', while the record definition in the generated HRL file would be 'InlinedSeq_s'. Since there is no reason to use the longer record name (no risk for ambiguity), correct the name in the decoding code.
Diffstat (limited to 'lib/asn1/src')
-rw-r--r--lib/asn1/src/asn1ct_constructed_per.erl26
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/asn1/src/asn1ct_constructed_per.erl b/lib/asn1/src/asn1ct_constructed_per.erl
index efb55cf015..d279e9697f 100644
--- a/lib/asn1/src/asn1ct_constructed_per.erl
+++ b/lib/asn1/src/asn1ct_constructed_per.erl
@@ -354,8 +354,7 @@ gen_dec_constructed_imm_2(Typename, CompList,
%% we don't return named lists any more Cnames = mkcnamelist(CompList),
demit({"Result = "}), %dbg
%% return value as record
- RecordName = lists:concat([get_record_name_prefix(),
- asn1ct_gen:list2rname(Typename)]),
+ RecordName = record_name(Typename),
case Typename of
['EXTERNAL'] ->
emit({" OldFormat={'",RecordName,
@@ -377,6 +376,29 @@ gen_dec_constructed_imm_2(Typename, CompList,
end,
emit({{curr,bytes},"}"}).
+%% record_name([TypeName]) -> RecordNameString
+%% Construct a record name for the constructed type, ignoring any
+%% fake sequences that are used to represent an extension addition
+%% group. Such fake sequences never appear as a top type, and their
+%% name always start with "ExtAddGroup".
+
+record_name(Typename0) ->
+ [TopType|Typename1] = lists:reverse(Typename0),
+ Typename = filter_ext_add_groups(Typename1, [TopType]),
+ lists:concat([get_record_name_prefix(),
+ asn1ct_gen:list2rname(Typename)]).
+
+filter_ext_add_groups([H|T], Acc) when is_atom(H) ->
+ case atom_to_list(H) of
+ "ExtAddGroup"++_ ->
+ filter_ext_add_groups(T, Acc);
+ _ ->
+ filter_ext_add_groups(T, [H|Acc])
+ end;
+filter_ext_add_groups([H|T], Acc) ->
+ filter_ext_add_groups(T, [H|Acc]);
+filter_ext_add_groups([], Acc) -> Acc.
+
textual_order([#'ComponentType'{textual_order=undefined}|_],TermList) ->
TermList;
textual_order(CompList,TermList) when is_list(CompList) ->