Skip to content

Commit 6a6ba9f

Browse files
author
José Valim
committed
Remove deprecated code
1 parent 1e31355 commit 6a6ba9f

File tree

11 files changed

+37
-318
lines changed

11 files changed

+37
-318
lines changed

lib/elixir/lib/inspect/algebra.ex

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,7 @@ defmodule Inspect.Algebra do
432432
"""
433433
@spec surround_many(binary, [any], binary, integer | :infinity, (term -> t), binary) :: t
434434
def surround_many(left, docs, right, opts, fun, separator \\ @surround_separator) do
435-
if is_integer(opts) do
436-
IO.write :stderr, "Inspect.Algebra.surround_many/6 with an integer limit is deprecated, " <>
437-
"please pass Inspect.Opts instead\n#{Exception.format_stacktrace}"
438-
old_surround_many(left, docs, right, opts, fun, separator)
439-
else
440-
do_surround_many(left, docs, right, opts.limit, opts, fun, separator)
441-
end
435+
do_surround_many(left, docs, right, opts.limit, opts, fun, separator)
442436
end
443437

444438
def do_surround_many(left, [], right, _, _opts, _fun, _) do
@@ -473,36 +467,6 @@ defmodule Inspect.Algebra do
473467
)
474468
end
475469

476-
def old_surround_many(left, [], right, _, _fun, _) do
477-
concat(left, right)
478-
end
479-
480-
def old_surround_many(left, docs, right, limit, fun, sep) do
481-
surround(left, old_surround_many(docs, limit, fun, sep), right)
482-
end
483-
484-
defp old_surround_many(_, 0, _fun, _sep) do
485-
"..."
486-
end
487-
488-
defp old_surround_many([h], _limit, fun, _sep) do
489-
fun.(h)
490-
end
491-
492-
defp old_surround_many([h|t], limit, fun, sep) when is_list(t) do
493-
glue(
494-
concat(fun.(h), sep),
495-
old_surround_many(t, decrement(limit), fun, sep)
496-
)
497-
end
498-
499-
defp old_surround_many([h|t], _limit, fun, _sep) do
500-
glue(
501-
concat(fun.(h), @tail_separator),
502-
fun.(t)
503-
)
504-
end
505-
506470
defp decrement(:infinity), do: :infinity
507471
defp decrement(counter), do: counter - 1
508472

@@ -518,11 +482,6 @@ defmodule Inspect.Algebra do
518482
format(w, 0, [{0, default_mode(w), doc_group(d)}])
519483
end
520484

521-
@doc false
522-
def pretty(d, w) do
523-
format(d, w) |> IO.iodata_to_binary
524-
end
525-
526485
defp default_mode(:infinity), do: :flat
527486
defp default_mode(_), do: :break
528487

lib/elixir/lib/io/ansi.ex

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ defmodule IO.ANSI.Sequence do
77
"\e[#{unquote(code)}#{unquote(terminator)}"
88
end
99

10-
defp escape_sequence(unquote(Atom.to_char_list(name))) do
11-
unquote(name)()
12-
end
13-
1410
defp format_sequence(unquote(name)) do
1511
unquote(name)()
1612
end
@@ -32,12 +28,6 @@ defmodule IO.ANSI do
3228
@typep ansilist :: maybe_improper_list(char() | ansicode() | binary() | ansilist(), binary() | ansicode() | [])
3329
@type ansidata :: ansilist() | ansicode() | binary()
3430

35-
@doc false
36-
def terminal?(device \\ :erlang.group_leader) do
37-
!match?({:win32, _}, :os.type()) and
38-
match?({:ok, _}, :io.columns(device))
39-
end
40-
4131
@doc """
4232
Checks if ANSI coloring is supported and enabled on this machine.
4333
@@ -144,10 +134,6 @@ defmodule IO.ANSI do
144134
@doc "Clear screen"
145135
defsequence :clear, "2", "J"
146136

147-
defp escape_sequence(other) do
148-
raise ArgumentError, "invalid ANSI sequence specification: #{other}"
149-
end
150-
151137
defp format_sequence(other) do
152138
raise ArgumentError, "invalid ANSI sequence specification: #{other}"
153139
end
@@ -222,56 +208,4 @@ defmodule IO.ANSI do
222208
defp do_format([], [], acc, _emit, _append_reset) do
223209
acc
224210
end
225-
226-
@doc false
227-
def escape(string, emit \\ terminal?) when is_binary(string) and is_boolean(emit) do
228-
{rendered, emitted} = do_escape(string, emit, false, nil, [])
229-
if emitted do
230-
rendered <> reset
231-
else
232-
rendered
233-
end
234-
end
235-
236-
@doc false
237-
def escape_fragment(string, emit \\ terminal?) when is_binary(string) and is_boolean(emit) do
238-
{escaped, _emitted} = do_escape(string, emit, false, nil, [])
239-
escaped
240-
end
241-
242-
defp do_escape(<<?}, t :: binary>>, emit, emitted, buffer, acc) when is_list(buffer) do
243-
sequences =
244-
buffer
245-
|> Enum.reverse()
246-
|> :string.tokens(',')
247-
|> Enum.map(&(&1 |> :string.strip |> escape_sequence))
248-
|> Enum.reverse()
249-
250-
if emit and sequences != [] do
251-
do_escape(t, emit, true, nil, sequences ++ acc)
252-
else
253-
do_escape(t, emit, emitted, nil, acc)
254-
end
255-
end
256-
257-
defp do_escape(<<h, t :: binary>>, emit, emitted, buffer, acc) when is_list(buffer) do
258-
do_escape(t, emit, emitted, [h|buffer], acc)
259-
end
260-
261-
defp do_escape(<<>>, _emit, _emitted, buffer, _acc) when is_list(buffer) do
262-
buffer = IO.iodata_to_binary Enum.reverse(buffer)
263-
raise ArgumentError, "missing } for escape fragment #{buffer}"
264-
end
265-
266-
defp do_escape(<<?%, ?{, t :: binary>>, emit, emitted, nil, acc) do
267-
do_escape(t, emit, emitted, [], acc)
268-
end
269-
270-
defp do_escape(<<h, t :: binary>>, emit, emitted, nil, acc) do
271-
do_escape(t, emit, emitted, nil, [h|acc])
272-
end
273-
274-
defp do_escape(<<>>, _emit, emitted, nil, acc) do
275-
{IO.iodata_to_binary(Enum.reverse(acc)), emitted}
276-
end
277211
end

lib/elixir/lib/io/ansi/docs.ex

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,6 @@ defmodule IO.ANSI.Docs do
479479

480480
defp color(style, colors) do
481481
color = colors[style]
482-
if is_binary(color) do
483-
IO.puts :stderr, "warning: ANSI colors as strings is deprecated, " <>
484-
"they now must be a list of atoms, got #{inspect color} for #{inspect style}"
485-
color = String.split(color, ",") |> Enum.map(&String.to_atom/1)
486-
end
487482
IO.ANSI.format_fragment(color, colors[:enabled])
488483
end
489484

lib/elixir/lib/system.ex

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,6 @@ defmodule System do
218218
:elixir_code_server.cast {:at_exit, fun}
219219
end
220220

221-
@doc false
222-
def cmd(command) when is_list(command) do
223-
:os.cmd(command)
224-
end
225-
226-
def cmd(command) when is_binary(command) do
227-
List.to_string :os.cmd(String.to_char_list(command))
228-
end
229-
230221
@doc """
231222
Locates an executable on the system.
232223

lib/elixir/src/elixir.erl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,17 @@ config_change(_Changed, _New, _Remove) ->
5454

5555
start_cli() ->
5656
{ok, _} = application:ensure_all_started(?MODULE),
57+
5758
%% We start the Logger so tools that depend on Elixir
5859
%% always have the Logger directly accessible. However
5960
%% Logger is not a dependency of the Elixir application,
6061
%% which means releases that want to use Logger must
6162
%% always list it as part of its applications.
62-
_ = application:start(logger),
63+
_ = case code:ensure_loaded('Elixir.Logger') of
64+
{module, _} -> application:start(logger);
65+
{error, _} -> ok
66+
end,
67+
6368
'Elixir.Kernel.CLI':main(init:get_plain_arguments()).
6469

6570
%% EVAL HOOKS

lib/elixir/src/elixir_bitstring.erl

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ expand_bitstr(Fun, [H|T], Acc, E) ->
3636
%% Expand bit info
3737

3838
expand_bit_info(Meta, Info, E) ->
39-
expand_bit_info(Meta, unpack_bit_info(Meta, Info, E), default, [], E).
39+
expand_bit_info(Meta, unpack_bit_info(Info, []), default, [], E).
4040

4141
expand_bit_info(Meta, [{size, _, [_]=Args}|T], Size, Types, E) ->
4242
case Size of
@@ -111,18 +111,9 @@ handle_unknown_bit_info(Meta, Expr, T, Size, Types, E) ->
111111
elixir_errors:compile_error(Meta, ?m(E, file),
112112
"unknown bitstring specifier ~ts", ['Elixir.Macro':to_string(Expr)]);
113113
Info ->
114-
expand_bit_info(Meta, unpack_bit_info(Meta, Info, E) ++ T, Size, Types, E)
114+
expand_bit_info(Meta, unpack_bit_info(Info, []) ++ T, Size, Types, E)
115115
end.
116116

117-
%% We can remove unpack_bit_info/3 once deprecated.
118-
unpack_bit_info(Meta, [H|T], E) ->
119-
elixir_errors:warn(?line(Meta), ?m(E, file), "passing a list of bitstring modifiers is deprecated, "
120-
"please separate them with - instead"),
121-
Dashed = lists:foldl(fun(I, Acc) -> {'-', Meta, [Acc, I]} end, H, T),
122-
unpack_bit_info(Dashed, []);
123-
unpack_bit_info(_Meta, Expr, _E) ->
124-
unpack_bit_info(Expr, []).
125-
126117
unpack_bit_info({'-', _, [H, T]}, Acc) ->
127118
unpack_bit_info(H, unpack_bit_info(T, Acc));
128119
unpack_bit_info({'*', _, [{'_', _, Atom}, Unit]}, Acc) when is_atom(Atom) and is_integer(Unit) ->

lib/elixir/src/elixir_dispatch.erl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -519,15 +519,5 @@ deprecation_message(Warning, Message) ->
519519
Message -> Warning ++ ", " ++ Message
520520
end.
521521

522-
deprecation('Elixir.System', 'cmd', 1) ->
523-
"use System.cmd/3 instead";
524-
deprecation('Elixir.Inspect.Algebra', 'pretty', 2) ->
525-
"use Inspect.Algebra.format/2 instead";
526-
deprecation('Elixir.IO.ANSI', 'escape', _) ->
527-
"use the new API in IO.ANSI.format/2 instead";
528-
deprecation('Elixir.IO.ANSI', 'escape_fragment', _) ->
529-
"use the new API in IO.ANSI.format_fragment/2 instead";
530-
deprecation('Elixir.IO.ANSI', 'terminal?', _) ->
531-
"use IO.ANSI.enabled?/0 instead";
532522
deprecation(_, _, _) ->
533523
false.

lib/elixir/src/elixir_interpolation.erl

Lines changed: 26 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -74,104 +74,51 @@ unescape_chars(String) ->
7474
unescape_chars(String, fun unescape_map/1).
7575

7676
unescape_chars(String, Map) ->
77-
Octals = Map($0) /= false,
78-
Hex = Map($x) == true,
79-
unescape_chars(String, Map, Octals, Hex, <<>>).
77+
unescape_chars(String, Map, Map($x) == true, <<>>).
8078

81-
%% Deprecated
79+
unescape_chars(<<$\\,$x,A,B,Rest/binary>>, Map, true, Acc) when ?is_hex(A), ?is_hex(B) ->
80+
append_escaped(Rest, Map, [A,B], true, Acc, 16);
8281

83-
unescape_chars(<<$\\,A,B,C,Rest/binary>>, Map, true, Hex, Acc) when ?is_octal(A), A =< $3, ?is_octal(B), ?is_octal(C) ->
84-
io:format(standard_error, "warning: octals inside strings/sigils/chars are deprecated, got: \\~ts~n", [<<A, B, C>>]),
85-
append_escaped(Rest, Map, [A,B,C], true, Hex, Acc, 8);
82+
unescape_chars(<<$\\,$x,A,Rest/binary>>, Map, true, Acc) when ?is_hex(A) ->
83+
append_escaped(Rest, Map, [A], true, Acc, 16);
8684

87-
unescape_chars(<<$\\,A,B,Rest/binary>>, Map, true, Hex, Acc) when ?is_octal(A), ?is_octal(B) ->
88-
io:format(standard_error, "warning: octals inside strings/sigils/chars are deprecated, got: \\~ts~n", [<<A, B>>]),
89-
append_escaped(Rest, Map, [A,B], true, Hex, Acc, 8);
85+
unescape_chars(<<$\\,$x,${,A,$},Rest/binary>>, Map, true, Acc) when ?is_hex(A) ->
86+
append_escaped(Rest, Map, [A], true, Acc, 16);
9087

91-
unescape_chars(<<$\\,$0,Rest/binary>>, Map, true, Hex, Acc) ->
92-
append_escaped(Rest, Map, [$0], true, Hex, Acc, 8);
88+
unescape_chars(<<$\\,$x,${,A,B,$},Rest/binary>>, Map, true, Acc) when ?is_hex(A), ?is_hex(B) ->
89+
append_escaped(Rest, Map, [A,B], true, Acc, 16);
9390

94-
unescape_chars(<<$\\,A,Rest/binary>>, Map, true, Hex, Acc) when ?is_octal(A) ->
95-
io:format(standard_error, "warning: octals inside strings/sigils/chars are deprecated, got: \\~ts~n", [<<A>>]),
96-
append_escaped(Rest, Map, [A], true, Hex, Acc, 8);
91+
unescape_chars(<<$\\,$x,${,A,B,C,$},Rest/binary>>, Map, true, Acc) when ?is_hex(A), ?is_hex(B), ?is_hex(C) ->
92+
append_escaped(Rest, Map, [A,B,C], true, Acc, 16);
9793

98-
unescape_chars(<<$\\,$X,A,B,Rest/binary>>, Map, Octal, true, Acc) when ?is_hex(A), ?is_hex(B) ->
99-
io:format(standard_error, "warning: \\X inside strings/sigils/chars is deprecated, please use \\x instead~n", []),
100-
append_escaped(Rest, Map, [A,B], Octal, true, Acc, 16);
94+
unescape_chars(<<$\\,$x,${,A,B,C,D,$},Rest/binary>>, Map, true, Acc) when ?is_hex(A), ?is_hex(B), ?is_hex(C), ?is_hex(D) ->
95+
append_escaped(Rest, Map, [A,B,C,D], true, Acc, 16);
10196

102-
unescape_chars(<<$\\,$X,A,Rest/binary>>, Map, Octal, true, Acc) when ?is_hex(A) ->
103-
io:format(standard_error, "warning: \\X inside strings/sigils/chars is deprecated, please use \\x instead~n", []),
104-
append_escaped(Rest, Map, [A], Octal, true, Acc, 16);
97+
unescape_chars(<<$\\,$x,${,A,B,C,D,E,$},Rest/binary>>, Map, true, Acc) when ?is_hex(A), ?is_hex(B), ?is_hex(C), ?is_hex(D), ?is_hex(E) ->
98+
append_escaped(Rest, Map, [A,B,C,D,E], true, Acc, 16);
10599

106-
unescape_chars(<<$\\,$X,${,A,$},Rest/binary>>, Map, Octal, true, Acc) when ?is_hex(A) ->
107-
io:format(standard_error, "warning: \\X inside strings/sigils/chars is deprecated, please use \\x instead~n", []),
108-
append_escaped(Rest, Map, [A], Octal, true, Acc, 16);
100+
unescape_chars(<<$\\,$x,${,A,B,C,D,E,F,$},Rest/binary>>, Map, true, Acc) when ?is_hex(A), ?is_hex(B), ?is_hex(C), ?is_hex(D), ?is_hex(E), ?is_hex(F) ->
101+
append_escaped(Rest, Map, [A,B,C,D,E,F], true, Acc, 16);
109102

110-
unescape_chars(<<$\\,$X,${,A,B,$},Rest/binary>>, Map, Octal, true, Acc) when ?is_hex(A), ?is_hex(B) ->
111-
io:format(standard_error, "warning: \\X inside strings/sigils/chars is deprecated, please use \\x instead~n", []),
112-
append_escaped(Rest, Map, [A,B], Octal, true, Acc, 16);
113-
114-
unescape_chars(<<$\\,$X,${,A,B,C,$},Rest/binary>>, Map, Octal, true, Acc) when ?is_hex(A), ?is_hex(B), ?is_hex(C) ->
115-
io:format(standard_error, "warning: \\X inside strings/sigils/chars is deprecated, please use \\x instead~n", []),
116-
append_escaped(Rest, Map, [A,B,C], Octal, true, Acc, 16);
117-
118-
unescape_chars(<<$\\,$X,${,A,B,C,D,$},Rest/binary>>, Map, Octal, true, Acc) when ?is_hex(A), ?is_hex(B), ?is_hex(C), ?is_hex(D) ->
119-
io:format(standard_error, "warning: \\X inside strings/sigils/chars is deprecated, please use \\x instead~n", []),
120-
append_escaped(Rest, Map, [A,B,C,D], Octal, true, Acc, 16);
121-
122-
unescape_chars(<<$\\,$X,${,A,B,C,D,E,$},Rest/binary>>, Map, Octal, true, Acc) when ?is_hex(A), ?is_hex(B), ?is_hex(C), ?is_hex(D), ?is_hex(E) ->
123-
io:format(standard_error, "warning: \\X inside strings/sigils/chars is deprecated, please use \\x instead~n", []),
124-
append_escaped(Rest, Map, [A,B,C,D,E], Octal, true, Acc, 16);
125-
126-
unescape_chars(<<$\\,$X,${,A,B,C,D,E,F,$},Rest/binary>>, Map, Octal, true, Acc) when ?is_hex(A), ?is_hex(B), ?is_hex(C), ?is_hex(D), ?is_hex(E), ?is_hex(F) ->
127-
io:format(standard_error, "warning: \\X inside strings/sigils/chars is deprecated, please use \\x instead~n", []),
128-
append_escaped(Rest, Map, [A,B,C,D,E,F], Octal, true, Acc, 16);
129-
130-
%% End of deprecated
131-
132-
unescape_chars(<<$\\,$x,A,B,Rest/binary>>, Map, Octal, true, Acc) when ?is_hex(A), ?is_hex(B) ->
133-
append_escaped(Rest, Map, [A,B], Octal, true, Acc, 16);
134-
135-
unescape_chars(<<$\\,$x,A,Rest/binary>>, Map, Octal, true, Acc) when ?is_hex(A) ->
136-
append_escaped(Rest, Map, [A], Octal, true, Acc, 16);
137-
138-
unescape_chars(<<$\\,$x,${,A,$},Rest/binary>>, Map, Octal, true, Acc) when ?is_hex(A) ->
139-
append_escaped(Rest, Map, [A], Octal, true, Acc, 16);
140-
141-
unescape_chars(<<$\\,$x,${,A,B,$},Rest/binary>>, Map, Octal, true, Acc) when ?is_hex(A), ?is_hex(B) ->
142-
append_escaped(Rest, Map, [A,B], Octal, true, Acc, 16);
143-
144-
unescape_chars(<<$\\,$x,${,A,B,C,$},Rest/binary>>, Map, Octal, true, Acc) when ?is_hex(A), ?is_hex(B), ?is_hex(C) ->
145-
append_escaped(Rest, Map, [A,B,C], Octal, true, Acc, 16);
146-
147-
unescape_chars(<<$\\,$x,${,A,B,C,D,$},Rest/binary>>, Map, Octal, true, Acc) when ?is_hex(A), ?is_hex(B), ?is_hex(C), ?is_hex(D) ->
148-
append_escaped(Rest, Map, [A,B,C,D], Octal, true, Acc, 16);
149-
150-
unescape_chars(<<$\\,$x,${,A,B,C,D,E,$},Rest/binary>>, Map, Octal, true, Acc) when ?is_hex(A), ?is_hex(B), ?is_hex(C), ?is_hex(D), ?is_hex(E) ->
151-
append_escaped(Rest, Map, [A,B,C,D,E], Octal, true, Acc, 16);
152-
153-
unescape_chars(<<$\\,$x,${,A,B,C,D,E,F,$},Rest/binary>>, Map, Octal, true, Acc) when ?is_hex(A), ?is_hex(B), ?is_hex(C), ?is_hex(D), ?is_hex(E), ?is_hex(F) ->
154-
append_escaped(Rest, Map, [A,B,C,D,E,F], Octal, true, Acc, 16);
155-
156-
unescape_chars(<<$\\,$x,_/binary>>, _Map, _Octal, true, _Acc) ->
103+
unescape_chars(<<$\\,$x,_/binary>>, _Map, true, _Acc) ->
157104
Msg = <<"missing hex sequence after \\x">>,
158105
error('Elixir.ArgumentError':exception([{message,Msg}]));
159106

160-
unescape_chars(<<$\\,Escaped,Rest/binary>>, Map, Octals, Hex, Acc) ->
107+
unescape_chars(<<$\\,Escaped,Rest/binary>>, Map, Hex, Acc) ->
161108
case Map(Escaped) of
162-
false -> unescape_chars(Rest, Map, Octals, Hex, <<Acc/binary, $\\, Escaped>>);
163-
Other -> unescape_chars(Rest, Map, Octals, Hex, <<Acc/binary, Other>>)
109+
false -> unescape_chars(Rest, Map, Hex, <<Acc/binary, $\\, Escaped>>);
110+
Other -> unescape_chars(Rest, Map, Hex, <<Acc/binary, Other>>)
164111
end;
165112

166-
unescape_chars(<<Char, Rest/binary>>, Map, Octals, Hex, Acc) ->
167-
unescape_chars(Rest, Map, Octals, Hex, <<Acc/binary, Char>>);
113+
unescape_chars(<<Char, Rest/binary>>, Map, Hex, Acc) ->
114+
unescape_chars(Rest, Map, Hex, <<Acc/binary, Char>>);
168115

169-
unescape_chars(<<>>, _Map, _Octals, _Hex, Acc) -> Acc.
116+
unescape_chars(<<>>, _Map, _Hex, Acc) -> Acc.
170117

171-
append_escaped(Rest, Map, List, Octal, Hex, Acc, Base) ->
118+
append_escaped(Rest, Map, List, Hex, Acc, Base) ->
172119
Codepoint = list_to_integer(List, Base),
173120
try <<Acc/binary, Codepoint/utf8>> of
174-
Binary -> unescape_chars(Rest, Map, Octal, Hex, Binary)
121+
Binary -> unescape_chars(Rest, Map, Hex, Binary)
175122
catch
176123
error:badarg ->
177124
Msg = <<"invalid or reserved unicode codepoint ", (integer_to_binary(Codepoint))/binary>>,

0 commit comments

Comments
 (0)