aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2018-03-02 10:18:11 +0100
committerLukas Larsson <[email protected]>2018-03-02 10:18:11 +0100
commitfb218aaf3ef9da8f21a95f7e5a96e0210812d04b (patch)
tree129a01c9aac8670cfe7c6a6485a818bfa1425366 /lib
parentd17ef36e2f0c81540dfc71e77cce91a4ff604f0c (diff)
parent8bf5e7b1d38faf9c495c34b2eff6044d700993ff (diff)
downloadotp-fb218aaf3ef9da8f21a95f7e5a96e0210812d04b.tar.gz
otp-fb218aaf3ef9da8f21a95f7e5a96e0210812d04b.tar.bz2
otp-fb218aaf3ef9da8f21a95f7e5a96e0210812d04b.zip
Merge branch 'lukas/kernel/fix_os_cmd_max_size_win32/OTP-14940' into maint
* lukas/kernel/fix_os_cmd_max_size_win32/OTP-14940: stdlib: Fix doc link in timer kernel: Fix handling of os:cmd option max_size in win
Diffstat (limited to 'lib')
-rw-r--r--lib/kernel/src/os.erl8
-rw-r--r--lib/kernel/test/os_SUITE.erl4
-rw-r--r--lib/stdlib/doc/src/timer.xml2
3 files changed, 7 insertions, 7 deletions
diff --git a/lib/kernel/src/os.erl b/lib/kernel/src/os.erl
index ae188ae932..a4b4f798f9 100644
--- a/lib/kernel/src/os.erl
+++ b/lib/kernel/src/os.erl
@@ -319,16 +319,16 @@ get_data(Port, MonRef, Eot, Sofar, Size, Max) ->
iolist_to_binary(Sofar)
end.
-eot(_Bs, <<>>, _Size, _Max) ->
+eot(Bs, <<>>, Size, Max) when Size + byte_size(Bs) < Max ->
more;
+eot(Bs, <<>>, Size, Max) ->
+ binary:part(Bs, {0, Max - Size});
eot(Bs, Eot, Size, Max) ->
case binary:match(Bs, Eot) of
- nomatch when Size + byte_size(Bs) < Max ->
- more;
{Pos, _} when Size + Pos < Max ->
binary:part(Bs,{0, Pos});
_ ->
- binary:part(Bs,{0, Max - Size})
+ eot(Bs, <<>>, Size, Max)
end.
%% When port_close returns we know that all the
diff --git a/lib/kernel/test/os_SUITE.erl b/lib/kernel/test/os_SUITE.erl
index 079b9790f6..a0bcde68db 100644
--- a/lib/kernel/test/os_SUITE.erl
+++ b/lib/kernel/test/os_SUITE.erl
@@ -324,8 +324,8 @@ max_size_command(_Config) ->
Res32768 = os:cmd("cat /dev/zero", #{ max_size => 32768 }),
32768 = length(Res32768),
- ResHello = os:cmd("echo hello", #{ max_size => 20 }),
- 6 = length(ResHello).
+ ResHello = string:trim(os:cmd("echo hello", #{ max_size => 20 })),
+ 5 = length(ResHello).
%% Test that the os:perf_counter api works as expected
perf_counter_api(_Config) ->
diff --git a/lib/stdlib/doc/src/timer.xml b/lib/stdlib/doc/src/timer.xml
index fcaccdb2cb..350847bf7d 100644
--- a/lib/stdlib/doc/src/timer.xml
+++ b/lib/stdlib/doc/src/timer.xml
@@ -270,7 +270,7 @@
<item>
<p>Evaluates <c>apply(<anno>Module</anno>, <anno>Function</anno>,
<anno>Arguments</anno>)</c> and measures the elapsed real time as
- reported by <seealso marker="os:timestamp/0">
+ reported by <seealso marker="kernel:os#timestamp/0">
<c>os:timestamp/0</c></seealso>.</p>
<p>Returns <c>{<anno>Time</anno>, <anno>Value</anno>}</c>, where
<c><anno>Time</anno></c> is the elapsed real time in