File 2383-ssh-Make-an-internal-option-delete-function.patch of Package erlang
From ccef9f6e379a2cee828a9b914a49a4ebc831f936 Mon Sep 17 00:00:00 2001
From: Hans Nilsson <hans@erlang.org>
Date: Thu, 2 Mar 2017 20:02:50 +0100
Subject: [PATCH 03/13] ssh: Make an internal option delete function
---
lib/ssh/src/ssh.hrl | 4 ++++
lib/ssh/src/ssh_options.erl | 16 ++++++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/lib/ssh/src/ssh.hrl b/lib/ssh/src/ssh.hrl
index c1ba58ed4..63eeb0bd0 100644
--- a/lib/ssh/src/ssh.hrl
+++ b/lib/ssh/src/ssh.hrl
@@ -89,6 +89,10 @@
-define(PUT_INTERNAL_OPT(KeyVal,Opts), ?do_put_opt(internal_options,KeyVal,Opts) ).
-define(PUT_SOCKET_OPT(KeyVal,Opts), ?do_put_opt(socket_options, KeyVal,Opts) ).
+-define(do_del_opt(C,K,O), ssh_options:delete_key(C,K,O, ?MODULE,?LINE)).
+-define(DELETE_INTERNAL_OPT(Key,Opts), ?do_del_opt(internal_options,Key,Opts) ).
+
+
%% Types
-type role() :: client | server .
-type ok_error(SuccessType) :: {ok, SuccessType} | {error, any()} .
diff --git a/lib/ssh/src/ssh_options.erl b/lib/ssh/src/ssh_options.erl
index 55f9c6bdc..512aefa76 100644
--- a/lib/ssh/src/ssh_options.erl
+++ b/lib/ssh/src/ssh_options.erl
@@ -28,6 +28,7 @@
-export([default/1,
get_value/5, get_value/6,
put_value/5,
+ delete_key/5,
handle_options/2
]).
@@ -75,7 +76,6 @@ get_value(Class, Key, Opts, _CallerMod, _CallerLine) when is_map(Opts) ->
user_options -> maps:get(Key, Opts)
end;
get_value(Class, Key, Opts, _CallerMod, _CallerLine) ->
- io:format("*** Bad Opts GET OPT ~p ~p:~p Key=~p,~n Opts=~p~n",[Class,_CallerMod,_CallerLine,Key,Opts]),
error({bad_options,Class, Key, Opts, _CallerMod, _CallerLine}).
@@ -90,7 +90,6 @@ get_value(Class, Key, Opts, Def, CallerMod, CallerLine) when is_map(Opts) ->
error:{badkey,Key} -> Def
end;
get_value(Class, Key, Opts, _Def, _CallerMod, _CallerLine) ->
- io:format("*** Bad Opts GET OPT ~p ~p:~p Key=~p,~n Opts=~p~n",[Class,_CallerMod,_CallerLine,Key,Opts]),
error({bad_options,Class, Key, Opts, _CallerMod, _CallerLine}).
@@ -136,6 +135,19 @@ put_socket_value(A, SockOpts) when is_atom(A) ->
%%%================================================================
%%%
+%%% Delete an option
+%%%
+
+-spec delete_key(option_class(), option_key(), options(),
+ atom(), non_neg_integer()) -> options().
+
+delete_key(internal_options, Key, Opts, _CallerMod, _CallerLine) when is_map(Opts) ->
+ InternalOpts = maps:get(internal_options,Opts),
+ Opts#{internal_options := maps:remove(Key, InternalOpts)}.
+
+
+%%%================================================================
+%%%
%%% Initialize the options
%%%
--
2.12.2