Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
1447-stdlib-Fix-io_lib-get_until-to-return-bina...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1447-stdlib-Fix-io_lib-get_until-to-return-binaries-at-eo.patch of Package erlang
From 038a7bf1320c095540c28cdd81c1fc56ab69127f Mon Sep 17 00:00:00 2001 From: Lukas Larsson <lukas@erlang.org> Date: Tue, 2 Jan 2024 16:43:48 +0100 Subject: [PATCH 1/2] stdlib: Fix io_lib:get_until to return binaries at eof Before this fix if a get_until function would return data when eof is seen, the result would not be correctly converted to a binary when returned. closes #4992 --- lib/stdlib/src/io_lib.erl | 16 ++++--- lib/stdlib/test/io_proto_SUITE.erl | 77 +++++++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 8 deletions(-) diff --git a/lib/stdlib/src/io_lib.erl b/lib/stdlib/src/io_lib.erl index 87010361c0..4f42950069 100644 --- a/lib/stdlib/src/io_lib.erl +++ b/lib/stdlib/src/io_lib.erl @@ -960,8 +960,12 @@ get_until(Any,Data,Arg) -> %% Now we are aware of encoding... get_until(start, Data, Encoding, XtraArg) -> - get_until([], Data, Encoding, XtraArg); -get_until(Cont, Data, Encoding, {Mod, Func, XtraArgs}) -> + %% We use the type of the initial data as an indicator of what + %% the final result should be cast to. We cannot use the final + %% data as that might be eof and then we have no idea what to + %% convert to. + get_until({is_binary(Data), []}, Data, Encoding, XtraArg); +get_until({IsDataBinary, Cont}, Data, Encoding, {Mod, Func, XtraArgs}) -> Chars = if is_binary(Data), Encoding =:= unicode -> unicode:characters_to_list(Data,utf8); is_binary(Data) -> @@ -971,14 +975,14 @@ get_until(Cont, Data, Encoding, {Mod, Func, XtraArgs}) -> end, case apply(Mod, Func, [Cont,Chars|XtraArgs]) of {done,Result,Buf} -> - {stop,if is_binary(Data), + {stop,if IsDataBinary, is_list(Result), Encoding =:= unicode -> unicode:characters_to_binary(Result,unicode,unicode); - is_binary(Data), + IsDataBinary, is_list(Result) -> erlang:iolist_to_binary(Result); -%% is_list(Data), +%% IsDataBinary, %% is_list(Result), %% Encoding =:= latin1 -> %% % Should check for only latin1, but skip that for @@ -990,7 +994,7 @@ get_until(Cont, Data, Encoding, {Mod, Func, XtraArgs}) -> end, Buf}; {more,NewCont} -> - NewCont + {IsDataBinary, NewCont} end. binrev(L) -> -- 2.35.3
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