add rebar.config.script for checking support maps and binary_to_{integer,float}/1
This commit is contained in:
parent
fef001479f
commit
446f674f27
3 changed files with 12 additions and 4 deletions
|
@ -1,7 +1,5 @@
|
|||
{erl_opts, [
|
||||
% uncomment to always decode to maps
|
||||
% {d, maps_always},
|
||||
{platform_define, "R14|R15", 'no_binary_to_whatever'},
|
||||
{platform_define, "^((?!R1[456]).)*$", 'maps_support'}
|
||||
]}.
|
||||
{edoc_opts, [{preprocess, true}]}.
|
11
rebar.config.script
Normal file
11
rebar.config.script
Normal file
|
@ -0,0 +1,11 @@
|
|||
Def0 = case erlang:is_builtin(erlang, binary_to_integer, 1) andalso
|
||||
erlang:is_builtin(erlang, binary_to_float, 1) of
|
||||
true -> [];
|
||||
false -> [{d, no_binary_to_whatever}]
|
||||
end,
|
||||
Defs = case erlang:is_builtin(erlang, is_map, 1) of
|
||||
true -> [{d, maps_support}|Def0];
|
||||
false -> Def0
|
||||
end,
|
||||
lists:keystore(erl_opts, 1, CONFIG,
|
||||
{erl_opts, proplists:get_value(erl_opts, CONFIG, []) ++ Defs}).
|
|
@ -1010,8 +1010,7 @@ finish_number(Rest, Handler, Acc, Stack, Config) ->
|
|||
-ifndef(no_binary_to_whatever).
|
||||
format_number({integer, Acc}) -> {integer, binary_to_integer(Acc)};
|
||||
format_number({float, Acc}) -> {float, binary_to_float(Acc)}.
|
||||
-endif.
|
||||
-ifdef(no_binary_to_whatever).
|
||||
-else.
|
||||
format_number({integer, Acc}) -> {integer, list_to_integer(unicode:characters_to_list(Acc))};
|
||||
format_number({float, Acc}) -> {float, list_to_float(unicode:characters_to_list(Acc))}.
|
||||
-endif.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue