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

david wallin david.wallin@REDACTED
Mon Oct 13 14:11:57 CEST 2003


On Monday, October 13, 2003, at 08:23 AM, Raimo Niskanen wrote:

> Erlang (BEAM) emulator version 5.3 [hipe] [threads:0]
>
> Eshell V5.3  (abort with ^G)
> 1> io:fread('adhoc> ', "~d~f~f~d~f").
> adhoc> 1 2.0 3.0 4 5.0
> {ok,[1,2.00000,3.00000,4,5.00000]}
> 2>
>

I have a file with alot of entries like that, and the function below is 
supposed to be called until all of them are read, i.e, it should return 
the eof from io:fread/3. The behaviour of 'io:fread/3' has clearly 
changed between R9B-1 and R9C-0.

--david.


> Works fine. Please give more info about from where you read input and 
> how you expect the end of file in the input to appear.
>
> -- 
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
>
>
> david wallin wrote:
>> Subject says it all really. With release R9C-0 io:fread/3 doesn't 
>> return 'eof' but an error.
>> The following function worked fine with R9B-1 but now I get an 
>> '{error, Error}' instead of 'eof'.
>> get_best_fitness(Io) ->
>>     case io:fread(Io, 'adhoc> ', "~d~f~f~d~f") of
>>     {ok, [Generation, BestFitness, AvgFitness, ValidSol, Entropy]} ->
>>         {Generation, BestFitness} ;
>>     {error, Error} ->
>>         io:format("~p.get_best_fitness: unexpected format '~p'\n", 
>> [?MODULE, Error]),
>>         error ;
>>     eof -> eof
>>     end.
>> cheers,
>> --david.




More information about the erlang-questions mailing list