diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/stdlib/src/io_lib_fread.erl | 8 | ||||
-rw-r--r-- | lib/stdlib/test/io_SUITE.erl | 6 |
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/stdlib/src/io_lib_fread.erl b/lib/stdlib/src/io_lib_fread.erl index 137759bbab..411d293876 100644 --- a/lib/stdlib/src/io_lib_fread.erl +++ b/lib/stdlib/src/io_lib_fread.erl @@ -123,8 +123,8 @@ fread([_F|_Format], [_C|_Line], _N, _Results) -> fread_error(input); fread([_|_]=Format, [], N, Results) -> {more,Format,N,Results}; -fread([_|_], eof, _N, []) -> - %% This is at start of format string so no error. +fread([_|_], eof, 0, []) -> + %% This is at start of input so no error. eof; fread([_|_], eof, _N, _Results) -> %% This is an error as there is no more input. @@ -175,8 +175,8 @@ fread1([$l|Format], _F, Sup, _U, Line, N, Res, _AllFormat) -> fread1(_Format, _F, _Sup, _U, [], N, Res, AllFormat) -> %% Need more input here. {more,[$~|AllFormat],N,Res}; -fread1(_Format, _F, _Sup, _U, eof, _N, [], _AllFormat) -> - %% This is at start of format string so no error. +fread1(_Format, _F, _Sup, _U, eof, 0, [], _AllFormat) -> + %% This is at start of input so no error. eof; fread1(_Format, _F, _Sup, _U, eof, _N, _Res, _AllFormat) -> %% This is an error as there is no more input. diff --git a/lib/stdlib/test/io_SUITE.erl b/lib/stdlib/test/io_SUITE.erl index 03dc655426..bb02a879c2 100644 --- a/lib/stdlib/test/io_SUITE.erl +++ b/lib/stdlib/test/io_SUITE.erl @@ -2011,7 +2011,13 @@ io_lib_fread_literal(Suite) when is_list(Suite) -> %% ?line {done,eof,_} = io_lib:fread([], eof, "~d"), ?line {done,eof,_} = io_lib:fread([], eof, " ~d"), + ?line {more,C1} = io_lib:fread([], " \n", " ~d"), + ?line {done,{error,{fread,input}},_} = io_lib:fread(C1, eof, " ~d"), + ?line {done,{ok,[18]},""} = io_lib:fread(C1, "18\n", " ~d"), %% ?line {done,eof,_} = io_lib:fread([], eof, "d"), ?line {done,eof,_} = io_lib:fread([], eof, " d"), + ?line {more,C2} = io_lib:fread([], " \n", " d"), + ?line {done,{error,{fread,input}},_} = io_lib:fread(C2, eof, " d"), + ?line {done,{ok,[]},[]} = io_lib:fread(C2, "d\n", " d"), ok. |