aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2014-01-21 13:59:50 +0100
committerHenrik Nord <[email protected]>2014-01-21 14:00:45 +0100
commit203fb6ba7d332d6b5365a411b670a5afd6b5a1cd (patch)
tree1279b35f856e68b9dbf8eba70e29c7c3e9b0a836 /lib
parent9b92301dcae72faecdab9f5fe009a53f6d47b8a1 (diff)
parent2db2f977598dab05dc125acdc478c375cb66ddb8 (diff)
downloadotp-203fb6ba7d332d6b5365a411b670a5afd6b5a1cd.tar.gz
otp-203fb6ba7d332d6b5365a411b670a5afd6b5a1cd.tar.bz2
otp-203fb6ba7d332d6b5365a411b670a5afd6b5a1cd.zip
Merge branch 'josevalim/jv-console-i'
* josevalim/jv-console-i: Handle binary input in console helpers OTP-11589
Diffstat (limited to 'lib')
-rw-r--r--lib/stdlib/src/c.erl7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/stdlib/src/c.erl b/lib/stdlib/src/c.erl
index fb6b8c8661..f23b5d4fe9 100644
--- a/lib/stdlib/src/c.erl
+++ b/lib/stdlib/src/c.erl
@@ -330,13 +330,18 @@ choice(F) ->
end.
get_line(P, Default) ->
- case io:get_line(P) of
+ case line_string(io:get_line(P)) of
"\n" ->
Default;
L ->
L
end.
+%% If the standard input is set to binary mode
+%% convert it to a list so we can properly match.
+line_string(Binary) when is_binary(Binary) -> unicode:characters_to_list(Binary);
+line_string(Other) -> Other.
+
mfa_string(Fun) when is_function(Fun) ->
{module,M} = erlang:fun_info(Fun, module),
{name,F} = erlang:fun_info(Fun, name),