File tree Expand file tree Collapse file tree 1 file changed +14
-11
lines changed Expand file tree Collapse file tree 1 file changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -843,19 +843,22 @@ object (self)
843
843
let len = 512 in
844
844
let s = String. create len in
845
845
wrap_conn (fun conn ->
846
- let rec loop r =
847
- let zero = String. index s '\000' in
848
- Buffer. add_substring buf s 0 zero;
849
- match r with
850
- | 0 -> f (Buffer. contents buf); Buffer. clear buf; line ()
851
- | 1 -> loop (Stub. getline conn s 0 len)
852
- | _ -> f (Buffer. contents buf)
853
- and line () =
846
+ let rec loop () =
854
847
let r = Stub. getline conn s 0 len in
855
- if r < 3 || s.[0 ] <> '\\' || s.[1 ] <> '.' || s.[2 ] <> '\000' then
856
- loop r
848
+ if r = 1 then begin (* Buffer full *)
849
+ Buffer. add_substring buf s 0 len;
850
+ loop ()
851
+ end
852
+ else if r = 0 then (* Line read *)
853
+ let zero = String. index s '\000' in
854
+ Buffer. add_substring buf s 0 zero;
855
+ match Buffer. contents buf with
856
+ | "\\ ." -> ()
857
+ | line -> Buffer. clear buf; f line; loop ()
858
+ else if r = - 1 then raise End_of_file
859
+ else assert false (* impossible *)
857
860
in
858
- line () );
861
+ loop () );
859
862
self#endcopy
860
863
861
864
method copy_out_channel oc =
You can’t perform that action at this time.
0 commit comments