Skip to content

Commit

Permalink
Add port support to io_lib.erl
Browse files Browse the repository at this point in the history
Add support for io_lib (and io, etc...) to format ports.

Adds port_to_list/1 to erlang module exports to keep dialyzer happy.

Signed-off-by: Winford <[email protected]>
  • Loading branch information
UncleGrumpy committed Jan 15, 2025
1 parent 15bf93d commit 0764fb0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions libs/estdlib/src/erlang.erl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
integer_to_list/2,
fun_to_list/1,
pid_to_list/1,
port_to_list/1,
ref_to_list/1,
register/2,
unregister/1,
Expand Down Expand Up @@ -839,6 +840,16 @@ fun_to_list(_Fun) ->
pid_to_list(_Pid) ->
erlang:nif_error(undefined).

%%-----------------------------------------------------------------------------
%% @param Port port to convert to a string
%% @returns a string representation of the port
%% @doc Create a string representing a port.
%% @end
%%-----------------------------------------------------------------------------
-spec port_to_list(Port :: port()) -> string().
port_to_list(_Port) ->
erlang:nif_error(undefined).

%%-----------------------------------------------------------------------------
%% @param Ref reference to convert to a string
%% @returns a string representation of the reference
Expand Down
2 changes: 2 additions & 0 deletions libs/estdlib/src/io_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ format_spw(_Format, T) when is_float(T) ->
erlang:float_to_list(T);
format_spw(_Format, T) when is_pid(T) ->
erlang:pid_to_list(T);
format_spw(_Format, T) when is_port(T) ->
erlang:port_to_list(T);
format_spw(_Format, T) when is_reference(T) ->
erlang:ref_to_list(T);
format_spw(_Format, T) when is_function(T) ->
Expand Down

0 comments on commit 0764fb0

Please sign in to comment.