Remove HAVE_URI_STRING
This commit is contained in:
@@ -11,7 +11,6 @@ include_dirs:
|
||||
- "_build/default/lib/*/include"
|
||||
- "include"
|
||||
macros:
|
||||
- name: HAVE_URI_STRING
|
||||
- name: OTP_BELOW_27
|
||||
- name: SIP
|
||||
- name: STUN
|
||||
|
||||
@@ -63,14 +63,6 @@ defmodule Ejabberd.MixProject do
|
||||
]
|
||||
end
|
||||
|
||||
defp if_version_above(ver, okResult) do
|
||||
if :erlang.system_info(:otp_release) > ver do
|
||||
okResult
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
defp if_version_below(ver, okResult) do
|
||||
if :erlang.system_info(:otp_release) < ver do
|
||||
okResult
|
||||
@@ -85,7 +77,6 @@ defmodule Ejabberd.MixProject do
|
||||
result = [{:d, :ELIXIR_ENABLED}] ++
|
||||
cond_options() ++
|
||||
Enum.map(includes, fn (path) -> {:i, path} end) ++
|
||||
if_version_above(~c"20", [{:d, :HAVE_URI_STRING}]) ++
|
||||
if_version_below(~c"21", [{:d, :USE_OLD_HTTP_URI}]) ++
|
||||
if_version_below(~c"22", [{:d, :LAGER}]) ++
|
||||
if_version_below(~c"21", [{:d, :NO_CUSTOMIZE_HOSTNAME_CHECK}]) ++
|
||||
|
||||
@@ -112,7 +112,6 @@
|
||||
|
||||
{erl_opts, [nowarn_deprecated_function,
|
||||
{i, "include"},
|
||||
{if_version_above, "20", {d, 'HAVE_URI_STRING'}},
|
||||
{if_version_below, "21", {d, 'USE_OLD_HTTP_URI'}},
|
||||
{if_version_below, "22", {d, 'LAGER'}},
|
||||
{if_version_below, "21", {d, 'NO_CUSTOMIZE_HOSTNAME_CHECK'}},
|
||||
|
||||
+5
-35
@@ -893,7 +893,7 @@ maybe_write_commit_json(Url, RepDir) ->
|
||||
end.
|
||||
|
||||
write_commit_json(Url, RepDir) ->
|
||||
Url2 = string_replace(Url, "https://github.com", "https://api.github.com/repos"),
|
||||
Url2 = string:replace(Url, "https://github.com", "https://api.github.com/repos"),
|
||||
BranchUrl = lists:flatten(Url2 ++ "/branches/master"),
|
||||
case geturl(BranchUrl) of
|
||||
{ok, _Headers, Body} ->
|
||||
@@ -906,8 +906,8 @@ write_commit_json(Url, RepDir) ->
|
||||
|
||||
find_commit_json(Attrs) ->
|
||||
FromPath = get_module_path(Attrs),
|
||||
case {find_commit_json_path(FromPath),
|
||||
find_commit_json_path(filename:join(FromPath, ".."))}
|
||||
case {filelib:find_file("COMMIT.json", FromPath),
|
||||
filelib:find_file("COMMIT.json", filename:join(FromPath, ".."))}
|
||||
of
|
||||
{{ok, FromFile}, _} ->
|
||||
FromFile;
|
||||
@@ -917,28 +917,6 @@ find_commit_json(Attrs) ->
|
||||
not_found
|
||||
end.
|
||||
|
||||
-ifdef(HAVE_URI_STRING). %% Erlang/OTP 20 or higher can use this:
|
||||
string_replace(Subject, Pattern, Replacement) ->
|
||||
string:replace(Subject, Pattern, Replacement).
|
||||
|
||||
find_commit_json_path(Path) ->
|
||||
filelib:find_file("COMMIT.json", Path).
|
||||
-else. % Workaround for Erlang/OTP older than 20:
|
||||
string_replace(Subject, Pattern, Replacement) ->
|
||||
B = binary:replace(list_to_binary(Subject),
|
||||
list_to_binary(Pattern),
|
||||
list_to_binary(Replacement)),
|
||||
binary_to_list(B).
|
||||
|
||||
find_commit_json_path(Path) ->
|
||||
case filelib:wildcard("COMMIT.json", Path) of
|
||||
[] ->
|
||||
{error, commit_json_not_found};
|
||||
["COMMIT.json"] = File ->
|
||||
{ok, filename:join(Path, File)}
|
||||
end.
|
||||
-endif.
|
||||
|
||||
copy_commit_json(Package, Attrs) ->
|
||||
DestPath = module_lib_dir(Package),
|
||||
case find_commit_json(Attrs) of
|
||||
@@ -1186,7 +1164,7 @@ get_installed_module_el({ModAtom, Attrs}, Lang) ->
|
||||
Summary = list_to_binary(get_module_summary(Attrs)),
|
||||
Author = list_to_binary(get_module_author(Attrs)),
|
||||
FromPath = get_module_path(Attrs),
|
||||
FromFile = case find_commit_json_path(FromPath) of
|
||||
FromFile = case filelib:find_file("COMMIT.json", FromPath) of
|
||||
{ok, FF} -> FF;
|
||||
{error, _} -> "dummypath"
|
||||
end,
|
||||
@@ -1287,19 +1265,11 @@ elixir_module_name(ModAtom) ->
|
||||
elixir_module_name([], Res) ->
|
||||
lists:reverse(Res);
|
||||
elixir_module_name([$_, Char | Remaining], Res) ->
|
||||
[Upper] = uppercase([Char]),
|
||||
[Upper] = string:uppercase([Char]),
|
||||
elixir_module_name(Remaining, [Upper | Res]);
|
||||
elixir_module_name([Char | Remaining], Res) ->
|
||||
elixir_module_name(Remaining, [Char | Res]).
|
||||
|
||||
-ifdef(HAVE_URI_STRING).
|
||||
uppercase(String) ->
|
||||
string:uppercase(String). % OTP 20 or higher
|
||||
-else.
|
||||
uppercase(String) ->
|
||||
string:to_upper(String). % OTP older than 20
|
||||
-endif.
|
||||
|
||||
get_available_module_el({ModAtom, Attrs}) ->
|
||||
Installed = installed(),
|
||||
Mod = misc:atom_to_binary(ModAtom),
|
||||
|
||||
+1
-14
@@ -210,26 +210,13 @@ base_url(Server, Path) ->
|
||||
_ -> Url
|
||||
end.
|
||||
|
||||
-ifdef(HAVE_URI_STRING).
|
||||
uri_hack(Str) ->
|
||||
case uri_string:normalize("%25") of
|
||||
"%" -> % This hack around bug in httpc >21 <23.2
|
||||
binary:replace(Str, <<"%25">>, <<"%2525">>, [global]);
|
||||
_ -> Str
|
||||
end.
|
||||
-else.
|
||||
uri_hack(Str) ->
|
||||
Str.
|
||||
-endif.
|
||||
|
||||
url(Url, []) ->
|
||||
Url;
|
||||
url(Url, Params) ->
|
||||
L = [<<"&", (iolist_to_binary(Key))/binary, "=",
|
||||
(misc:url_encode(Value))/binary>>
|
||||
|| {Key, Value} <- Params],
|
||||
<<$&, Encoded0/binary>> = iolist_to_binary(L),
|
||||
Encoded = uri_hack(Encoded0),
|
||||
<<$&, Encoded/binary>> = iolist_to_binary(L),
|
||||
<<Url/binary, $?, Encoded/binary>>.
|
||||
url(Server, Path, Params) ->
|
||||
case binary:split(base_url(Server, Path), <<"?">>) of
|
||||
|
||||
Reference in New Issue
Block a user