Skip to content

Commit

Permalink
asn1: Fix feature interaction with +undec_rest and +asn1config
Browse files Browse the repository at this point in the history
  • Loading branch information
vances committed Sep 10, 2024
1 parent 2283097 commit f97dc07
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions lib/asn1/src/asn1ct_gen.erl
Original file line number Diff line number Diff line change
Expand Up @@ -941,24 +941,33 @@ gen_info_functions(Gen) ->
"legacy_erlang_types() -> ",
{asis,asn1ct:use_legacy_types()},".",nl,nl]).

gen_decode_partial_incomplete(#gen{erule=ber}, NoOkWrapper) ->
gen_decode_partial_incomplete(#gen{erule=ber, options=Options}, NoOkWrapper) ->
case {asn1ct:read_config_data(partial_incomplete_decode),
asn1ct:get_gen_state_field(inc_type_pattern)} of
{undefined,_} ->
ok;
{_,undefined} ->
ok;
_ ->
emit(["decode_partial_incomplete(Type, Data0, Pattern) ->",nl,
" {Data,_RestBin} =",nl,
" ",{call,ber,decode_primitive_incomplete,
["Pattern","Data0"]},com,nl]),
case NoOkWrapper of
true ->
emit([" decode_partial_inc_disp(Type, Data)",nl]);
false ->
emit([" try {ok,decode_partial_inc_disp(Type, Data)}",nl,
try_catch()])
emit(["decode_partial_incomplete(Type, Data0, Pattern) ->",nl]),
case {NoOkWrapper, lists:member(undec_rest, Options)} of
{true, _} ->
emit([" {Data,_RestBin} =",nl,
" ",{call,ber,decode_primitive_incomplete,
["Pattern","Data0"]},com,nl,
" decode_partial_inc_disp(Type, Data)",nl]);
{false, true} ->
emit([" {Data,RestBin} =",nl,
" ",{call,ber,decode_primitive_incomplete,
["Pattern","Data0"]},com,nl,
" try {ok,decode_partial_inc_disp(Type, Data),RestBin}",
nl,try_catch()]);
{false, false} ->
emit([" {Data,RestBin} =",nl,
" ",{call,ber,decode_primitive_incomplete,
["Pattern","Data0"]},com,nl,
" try {ok,decode_partial_inc_disp(Type, Data)}",
nl,try_catch()])
end,
emit([".",nl,nl]),

Expand Down

0 comments on commit f97dc07

Please sign in to comment.