Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:19
erlang
2530-ssh-Add-delete_options-function-and-macro....
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2530-ssh-Add-delete_options-function-and-macro.patch of Package erlang
From 07e27685ce12e38db14feb0e3adb34e7c1a78903 Mon Sep 17 00:00:00 2001 From: Hans Nilsson <hans@erlang.org> Date: Tue, 11 May 2021 15:30:07 +0200 Subject: [PATCH 1/2] ssh: Add delete_options function and macro --- lib/ssh/src/ssh.hrl | 1 + lib/ssh/src/ssh_options.erl | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/ssh/src/ssh.hrl b/lib/ssh/src/ssh.hrl index 33f6833830..e37a14a156 100644 --- a/lib/ssh/src/ssh.hrl +++ b/lib/ssh/src/ssh.hrl @@ -117,6 +117,7 @@ -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) ). +-define(DELETE_OPT(KeyOrKeys,Opts), ?do_del_opt(user_options,KeyOrKeys,Opts) ). %% Types diff --git a/lib/ssh/src/ssh_options.erl b/lib/ssh/src/ssh_options.erl index b5b0a9d2d8..71d51be7db 100644 --- a/lib/ssh/src/ssh_options.erl +++ b/lib/ssh/src/ssh_options.erl @@ -134,10 +134,26 @@ put_socket_value(A, SockOpts) when is_atom(A) -> -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)}. - +delete_key(user_options, Key, Opts, _CallerMod, _CallerLine) when is_map(Opts) -> + if + is_list(Key) -> + lists:foldl(fun maps:remove/2, Opts, Key); + true -> + maps:remove(Key, Opts) + end; + +delete_key(Class, Key, Opts, _CallerMod, _CallerLine) when is_map(Opts) andalso + (Class == socket_options orelse + Class == internal_options) -> + Opts#{Class := + if + is_list(Key) -> + lists:foldl(fun maps:remove/2, maps:get(Class,Opts), Key); + true -> + maps:remove(Key, maps:get(Class,Opts)) + end + }. + %%%================================================================ %%% -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor