~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to lib/kernel/src/file_io_server.erl

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-08-05 20:54:29 UTC
  • mfrom: (6.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090805205429-pm4pnwew8axraosl
Tags: 1:13.b.1-dfsg-5
* Fixed parentheses in Emacs mode (closes: #536891).
* Removed unnecessary conflicts with erlang-manpages package.
* Added workaround for #475459: disabled threads on sparc architecture.
  This breaks wxErlang, so it's only a temporary solution.

Show diffs side-by-side

added added

removed removed

Lines of Context:
468
468
                   #state{handle=Handle,read_mode=ReadMode,buf = B}=State) ->
469
469
    case ?PRIM_FILE:read(Handle, read_size(ReadMode)) of
470
470
        {ok,Bin} ->
471
 
            get_chars_apply(Mod, Func, XtraArg, S, OutEnc, State, list_to_binary([Bin,B]));
 
471
            get_chars_apply(Mod, Func, XtraArg, S, OutEnc, State, list_to_binary([B,Bin]));
472
472
        eof ->
473
473
            case B of
474
474
                <<>> ->
503
503
                                  case unicode:characters_to_list(Data0,InEnc) of
504
504
                                      {Tag,Decoded,Rest} when Decoded =/= [], Tag =:= error; Decoded =/= [], Tag =:= incomplete ->
505
505
                                          {Decoded,erlang:iolist_to_binary(Rest)};
506
 
                                      {Tag, [], _} when Tag =:= error; Tag =:= incomplete -> 
 
506
                                      {error, [], _}  -> 
507
507
                                          exit(invalid_unicode);
 
508
                                      {incomplete, [], R}  -> 
 
509
                                          {[],R};
508
510
                                      List when is_list(List) ->
509
511
                                          {List,<<>>}
510
512
                                  end;
512
514
                                  case unicode:characters_to_binary(Data0,InEnc,OutEnc) of
513
515
                                      {Tag2,Decoded2,Rest2} when Decoded2 =/= <<>>, Tag2 =:= error; Decoded2 =/= <<>>, Tag2 =:= incomplete ->
514
516
                                          {Decoded2,erlang:iolist_to_binary(Rest2)};
515
 
                                      {Tag2, <<>>, _} when Tag2 =:= error; Tag2 =:= incomplete ->
 
517
                                      {error, <<>>, _} ->
516
518
                                          exit(invalid_unicode);
 
519
                                      {incomplete, <<>>, R} ->
 
520
                                          {<<>>,R};
517
521
                                      Binary when is_binary(Binary) ->
518
522
                                          {Binary,<<>>}
519
523
                                  end;
524
528
            {stop,Result,Buf} ->
525
529
                {reply,Result,State#state{buf = (if
526
530
                                                     is_binary(Buf) ->
527
 
                                                         unicode:characters_to_binary(Buf,OutEnc,InEnc);
 
531
                                                         list_to_binary([unicode:characters_to_binary(Buf,OutEnc,InEnc),NewBuff]);
528
532
                                                     is_list(Buf) ->
529
 
                                                         unicode:characters_to_binary(Buf,unicode,InEnc);
 
533
                                                         list_to_binary([unicode:characters_to_binary(Buf,unicode,InEnc),NewBuff]);
530
534
                                                     true ->
531
 
                                                         <<>>
 
535
                                                         NewBuff
532
536
                                                end)}};
533
537
            {'EXIT',Reason} ->
534
538
                {stop,Reason,{error,err_func(Mod, Func, XtraArg)},State};
708
712
cafu(_Other,0,Count,ByteCount,_,_) -> % Non Unicode character, 
709
713
                                     % but found our point, OK this time
710
714
    {Count,ByteCount};
711
 
cafu(Other,_N,Count,0,_SavePos,Enc) -> % Not enough, but valid chomped unicode
 
715
cafu(Other,_N,Count,0,SavePos,Enc) -> % Not enough, but valid chomped unicode
712
716
                                       % at end.
713
717
    case cbv(Enc,Other) of
714
718
        false ->
715
719
            exit(invalid_unicode);
716
720
        _ ->
717
 
            {Count,none}
 
721
            {Count,SavePos}
718
722
    end;
719
723
cafu(Other,_N,Count,ByteCount,none,Enc) -> % Return what we'we got this far
720
724
                                           % although not complete,