BUG: in io:fread/3: doesn't return eof

Raimo Niskanen raimo@REDACTED
Tue Oct 14 12:29:24 CEST 2003


Ok, sorry if I sounded a bit sore.

WARNING! I just tried to fread a file that did not contain a full set of 
fields on the last line, and my patch caused this error behaviour to 
change. I will be back with a better patch!

-- 
/ Raimo Niskanen, Erlang/OTP, Ericsson AB



david wallin wrote:
> 
> Raimo,
> 
> Thanks. I'll try to be more helpful in the future.
> 
> 
> cheers,
> 
> --david.
> 
> On Tuesday, October 14, 2003, at 10:17 AM, Raimo Niskanen wrote:
> 
>> I do not doubt that you have discovered that the behaviour has changed 
>> between R9B-1 and R9C-0, I just wanted your help to pinpoint the bug. 
>> Something like:
>>
>> -------------------
>> This shows the bug:
>> Erlang (BEAM) emulator version 5.3 [hipe] [threads:0]
>>
>> Eshell V5.3  (abort with ^G)
>> 1> file:write_file("kasta.txt","1 2.0 3.0 4 5.0\n").
>> ok
>> 2> {ok,Io} = file:open("kasta.txt", [read]).
>> {ok,<0.32.0>}
>> 3> io:fread(Io, 'adhoc> ', "~d~f~f~d~f").
>> {ok,[1,2.00000,3.00000,4,5.00000]}
>> 4> io:fread(Io, 'adhoc> ', "~d~f~f~d~f").
>> {error,{fread,format}}
>>
>> compared to R9B-1 that returns 'eof' from command 4>
>> -------------------
>>
>>
>>
>> I cracked it anyway, but if I had a small example like above I might 
>> have cracked it yesterday.
>>
>> Here is a "diff -c" that fixes the bug:
>>
>> *** lib/stdlib/src/io_lib_fread.erl@@/OTP_R9C   Mon Jul  7 13:59:36 2003
>> --- lib/stdlib/src/io_lib_fread.erl     Tue Oct 14 08:45:12 2003
>> ***************
>> *** 53,59 ****
>>         {more,RestFormat,N,Inputs} ->
>>             case More of
>>                 eof ->
>> !                   {done,fread_error(format),eof};
>>                 _ ->
>>                     %% Don't forget to count the newline.
>>                     {more,{More,RestFormat,N+1,Inputs}}
>> --- 53,59 ----
>>         {more,RestFormat,N,Inputs} ->
>>             case More of
>>                 eof ->
>> !                   {done,eof,eof};
>>                 _ ->
>>                     %% Don't forget to count the newline.
>>                     {more,{More,RestFormat,N+1,Inputs}}
>>
>> It will be fixed in R9C-1.
>>
>> -- 
>> / Raimo Niskanen, Erlang/OTP, Ericsson AB
>>
>>
> 




More information about the erlang-questions mailing list