aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/src/ssh_cli.erl
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2017-02-17 14:08:15 +0100
committerHans Nilsson <[email protected]>2017-02-17 14:08:15 +0100
commitde437e3639912a0570541fa10c473ac0f0372806 (patch)
tree88fec67d7712527e810e569b8695179c81960846 /lib/ssh/src/ssh_cli.erl
parent818989e624cebf061c1fc6311080350a95cb1e66 (diff)
downloadotp-de437e3639912a0570541fa10c473ac0f0372806.tar.gz
otp-de437e3639912a0570541fa10c473ac0f0372806.tar.bz2
otp-de437e3639912a0570541fa10c473ac0f0372806.zip
ssh: replace byte-only function with element-size agnostic
An error report on ssh_cli pointed to a usage of erlang:iolist_size/1. It is replaced by a specialized function.
Diffstat (limited to 'lib/ssh/src/ssh_cli.erl')
-rw-r--r--lib/ssh/src/ssh_cli.erl18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/ssh/src/ssh_cli.erl b/lib/ssh/src/ssh_cli.erl
index 8af0ecc5f9..6f8c050486 100644
--- a/lib/ssh/src/ssh_cli.erl
+++ b/lib/ssh/src/ssh_cli.erl
@@ -453,14 +453,20 @@ move_cursor(From, To, #ssh_pty{width=Width, term=Type}) ->
%% %%% make sure that there is data to send
%% %%% before calling ssh_connection:send
write_chars(ConnectionHandler, ChannelId, Chars) ->
- case erlang:iolist_size(Chars) of
- 0 ->
- ok;
- _ ->
- ssh_connection:send(ConnectionHandler, ChannelId,
- ?SSH_EXTENDED_DATA_DEFAULT, Chars)
+ case has_chars(Chars) of
+ false -> ok;
+ true -> ssh_connection:send(ConnectionHandler,
+ ChannelId,
+ ?SSH_EXTENDED_DATA_DEFAULT,
+ Chars)
end.
+has_chars([C|_]) when is_integer(C) -> true;
+has_chars([H|T]) when is_list(H) ; is_binary(H) -> has_chars(H) orelse has_chars(T);
+has_chars(<<_:8,_/binary>>) -> true;
+has_chars(_) -> false.
+
+
%%% tail, works with empty lists
tl1([_|A]) -> A;
tl1(_) -> [].