mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-24 17:29:28 +01:00
Add missed jlib:term_to_expr and jlib:expr_to_term functions
This commit is contained in:
parent
0ea0ba3004
commit
b2ffa1db96
11
src/jlib.erl
11
src/jlib.erl
@ -54,7 +54,8 @@
|
||||
binary_to_integer/1, binary_to_integer/2,
|
||||
integer_to_binary/1, integer_to_binary/2,
|
||||
atom_to_binary/1, binary_to_atom/1, tuple_to_binary/1,
|
||||
l2i/1, i2l/1, i2l/2, queue_drop_while/2]).
|
||||
l2i/1, i2l/1, i2l/2, queue_drop_while/2,
|
||||
expr_to_term/1, term_to_expr/1]).
|
||||
|
||||
%% The following functions are deprecated and will be removed soon
|
||||
%% Use corresponding functions from jid.erl instead
|
||||
@ -890,6 +891,14 @@ tuple_to_binary(T) ->
|
||||
atom_to_binary(A) ->
|
||||
erlang:atom_to_binary(A, utf8).
|
||||
|
||||
expr_to_term(Expr) ->
|
||||
Str = binary_to_list(<<Expr/binary, ".">>),
|
||||
{ok, Tokens, _} = erl_scan:string(Str),
|
||||
{ok, Term} = erl_parse:parse_term(Tokens),
|
||||
Term.
|
||||
|
||||
term_to_expr(Term) ->
|
||||
list_to_binary(io_lib:print(Term)).
|
||||
|
||||
l2i(I) when is_integer(I) -> I;
|
||||
l2i(L) when is_binary(L) -> binary_to_integer(L).
|
||||
|
Loading…
Reference in New Issue
Block a user