aboutsummaryrefslogtreecommitdiffstats
path: root/priv
diff options
context:
space:
mode:
authorFred Hebert <[email protected]>2017-11-01 15:40:09 -0400
committerFred Hebert <[email protected]>2017-11-01 15:40:09 -0400
commit7e78c133c7a373384411d9fd0e1366b14e4c31d8 (patch)
treeb15f294821ce2bcddf14f97cbae0e50beabebb57 /priv
parentfb91587091ad8a9da7c22598e962d0f21dcc17ee (diff)
downloadrelx-7e78c133c7a373384411d9fd0e1366b14e4c31d8.tar.gz
relx-7e78c133c7a373384411d9fd0e1366b14e4c31d8.tar.bz2
relx-7e78c133c7a373384411d9fd0e1366b14e4c31d8.zip
Support OTP-20 Unicode functions
Use either optional compilation or version-safe variants of the string functions. Prevents warnings when the switch to OTP-21 will happen.
Diffstat (limited to 'priv')
-rwxr-xr-xpriv/templates/extended_bin2
-rw-r--r--priv/templates/nodetool18
2 files changed, 15 insertions, 5 deletions
diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin
index 19d9d29..baa239c 100755
--- a/priv/templates/extended_bin
+++ b/priv/templates/extended_bin
@@ -151,7 +151,7 @@ relx_get_nodename() {
id="longname$(relx_gen_id)-${NAME}"
"$BINDIR/erl" -boot start_clean \
-boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
- -eval '[H]=tl(string:tokens(atom_to_list(node()),"@")), io:format("~s~n",[H]), halt()' \
+ -eval '[_,H]=re:split(atom_to_list(node()),"@",[unicode,{return,list}]), io:format("~s~n",[H]), halt()' \
-noshell ${NAME_TYPE} $id
}
diff --git a/priv/templates/nodetool b/priv/templates/nodetool
index 1f409f5..816be9c 100644
--- a/priv/templates/nodetool
+++ b/priv/templates/nodetool
@@ -57,7 +57,7 @@ main(Args) ->
% spaces, so this converts all of that to a single string to parse
String = binary_to_list(
list_to_binary(
- string:join(ListOfArgs," ")
+ join(ListOfArgs," ")
)
),
@@ -126,16 +126,16 @@ epmd_path() ->
nodename(Name) ->
- case string:tokens(Name, "@") of
+ case re:split(Name, "@", [{return, list}, unicode]) of
[_Node, _Host] ->
list_to_atom(Name);
[Node] ->
- [_, Host] = string:tokens(atom_to_list(node()), "@"),
+ [_, Host] = re:split(atom_to_list(node()), "@", [{return, list}, unicode]),
list_to_atom(lists:concat([Node, "@", Host]))
end.
append_node_suffix(Name, Suffix) ->
- case string:tokens(Name, "@") of
+ case re:split(Name, "@", [{return, list}, unicode]) of
[Node, Host] ->
list_to_atom(lists:concat([Node, Suffix, os:getpid(), "@", Host]));
[Node] ->
@@ -165,3 +165,13 @@ consult(Cont, Str, Acc) ->
{more, Cont1} ->
consult(Cont1, eof, Acc)
end.
+
+%% string:join/2 copy; string:join/2 is getting obsoleted
+%% and replaced by lists:join/2, but lists:join/2 is too new
+%% for version support (only appeared in 19.0) so it cannot be
+%% used. Instead we just adopt join/2 locally and hope it works
+%% for most unicode use cases anyway.
+join([], Sep) when is_list(Sep) ->
+ [];
+join([H|T], Sep) ->
+ H ++ lists:append([Sep ++ X || X <- T]).