[erlang-questions] bug: file:read in R12B-0

Raimo Niskanen <>
Thu Dec 6 10:13:00 CET 2007


Oops, that would be a bug.

If you build from source, try the following patch:
*** lib/kernel/src/file.erl     Mon Nov 26 13:29:40 2007
--- lib/kernel/src/file.erl-NEW Thu Dec  6 10:10:58 2007
***************
*** 395,401 ****
  
  
  read(File, Sz) when is_pid(File), is_integer(Sz), Sz >= 0 ->
!     case io:request(File, {get_chars, "", Sz}) of
        Data when is_list(Data); is_binary(Data) ->
            {ok, Data};
        Other ->
--- 395,401 ----
  
  
  read(File, Sz) when is_pid(File), is_integer(Sz), Sz >= 0 ->
!     case io:request(File, {get_chars, '', Sz}) of
        Data when is_list(Data); is_binary(Data) ->
            {ok, Data};
        Other ->
***************
*** 1004,1010 ****
      consult_stream(Fd, 1, []).
  
  consult_stream(Fd, Line, Acc) ->
!     case io:read(Fd, "", Line) of
        {ok,Term,EndLine} ->
            consult_stream(Fd, EndLine, [Term|Acc]);
        {error,Error,_Line} ->
--- 1004,1010 ----
      consult_stream(Fd, 1, []).
  
  consult_stream(Fd, Line, Acc) ->
!     case io:read(Fd, '', Line) of
        {ok,Term,EndLine} ->
            consult_stream(Fd, EndLine, [Term|Acc]);
        {error,Error,_Line} ->



On Thu, Dec 06, 2007 at 03:57:57PM +1100, Peter Wang wrote:
> Hi,
> 
> I'm not sure if it's allowed to explicitly pass group_leader() as the
> io_device, but R12B-0 behaves differently here:
> 
>     > file:read(group_leader(), 1).
>     []
>     {ok,"\n"}
> 
> That is, it prints out "[]" as the prompt, whereas R11B doesn't.
> 
> Peter
> 
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list