aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1ct_gen_per_rt2ct.erl
diff options
context:
space:
mode:
authorGustav Simonsson <[email protected]>2012-07-10 15:12:00 +0200
committerGustav Simonsson <[email protected]>2012-07-10 15:18:41 +0200
commitcc665e1ccb2cfc14a1ac8afefdc7af715ef5dee4 (patch)
tree390245189006dba0c791667133a9e6886596db60 /lib/asn1/src/asn1ct_gen_per_rt2ct.erl
parent6ddf21fafe0846f3df0391ec785a91aaa4062bd5 (diff)
downloadotp-cc665e1ccb2cfc14a1ac8afefdc7af715ef5dee4.tar.gz
otp-cc665e1ccb2cfc14a1ac8afefdc7af715ef5dee4.tar.bz2
otp-cc665e1ccb2cfc14a1ac8afefdc7af715ef5dee4.zip
In generation of encoding functions for enumeration types,
the values used for generating the range check in case of a value range should be sorted and have duplicates removed. For per with optimization (per_rt2ct), sorting has been added. For both optimized and regular per, the sorting and duplicate removal code has been simplified. In case of value range, 'MIN' and 'MAX' is now also checked. The sorting of constraint values in the check phase remains.
Diffstat (limited to 'lib/asn1/src/asn1ct_gen_per_rt2ct.erl')
-rw-r--r--lib/asn1/src/asn1ct_gen_per_rt2ct.erl15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/asn1/src/asn1ct_gen_per_rt2ct.erl b/lib/asn1/src/asn1ct_gen_per_rt2ct.erl
index eda0faad3c..16eec92847 100644
--- a/lib/asn1/src/asn1ct_gen_per_rt2ct.erl
+++ b/lib/asn1/src/asn1ct_gen_per_rt2ct.erl
@@ -670,18 +670,13 @@ effective_constr(_,[]) ->
[];
effective_constr('SingleValue',List) ->
SVList = lists:flatten(lists:map(fun(X)->element(2,X)end,List)),
- % sort and remove duplicates
- RemoveDup = fun([],_) ->[];
- ([H],_) -> [H];
- ([H,H|T],F) -> F([H|T],F);
- ([H|T],F) -> [H|F(T,F)]
- end,
-
- case RemoveDup(SVList,RemoveDup) of
+ %% Sort and remove duplicates before generating SingleValue or ValueRange
+ %% In case of ValueRange, also check for 'MIN and 'MAX'
+ case lists:usort(SVList) of
[N] ->
[{'SingleValue',N}];
- L when is_list(L) ->
- [{'ValueRange',{hd(L),lists:last(L)}}]
+ L when is_list(L) ->
+ [{'ValueRange',{least_Lb(L),greatest_Ub(L)}}]
end;
effective_constr('ValueRange',List) ->
LBs = lists:map(fun({_,{Lb,_}})-> Lb end,List),