From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 9013FBC57 for ; Sat, 20 Mar 2010 09:29:17 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Am4CAKIkpEvRVdvhkGdsb2JhbACDCY4ZihQIFQEBAQEJCQwHEwMfqmU3gWOFKC6ISwEBAwWBJ4JnagQ X-IronPort-AV: E=Sophos;i="4.51,278,1267398000"; d="scan'208";a="47485133" Received: from mail-ew0-f225.google.com ([209.85.219.225]) by mail2-smtp-roc.national.inria.fr with ESMTP; 20 Mar 2010 09:29:17 +0100 Received: by ewy25 with SMTP id 25so1082958ewy.7 for ; Sat, 20 Mar 2010 01:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=walWcoozqMFpxUv7Gy2LPeDSzhqMnie13P5Gc0VlTUI=; b=Y3z1jq8dNZblTkx9h6Zpf2Qjeo4sckcFqkkgUX6haRHbegt4cn9PR+sIzi7m8EKpim Bw5BMqvBp3OoH98WmwYt97p5CdX1JdqP3j/uMyzr3TAOl8mAVyJd6N6NRRq6fQOq8FQy vuJ5hjPcN4B3gGp34QYvQ0+5uqgtfUaDDy06s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=LriQEMiSy/JFE0kaB62jg0JvFa0OzkF0MWPxagsy34aTA4s6RZN9MAO0YYc+Fj/Xfq NqNiHjXF7bgyPuZDPv9BD7C1gmBlKvC1mTjAMUTRfPR1qiEi0dX8nydNt4MWR4Rjozz3 VZ9WAl1qd6TT2FsGVQppm7+rmC3j0ZWiM3BgY= MIME-Version: 1.0 Received: by 10.213.25.69 with SMTP id y5mr3389641ebb.7.1269073756802; Sat, 20 Mar 2010 01:29:16 -0700 (PDT) In-Reply-To: <36ae71be1003181052p2085e55ak525001db16b3aca0@mail.gmail.com> References: <36ae71be1003171327h3dfe72f5t74d43ebc88035e3d@mail.gmail.com> <36ae71be1003181052p2085e55ak525001db16b3aca0@mail.gmail.com> Date: Sat, 20 Mar 2010 10:29:16 +0200 Message-ID: <36ae71be1003200129vc6060a1ib75aa038b0ee0ddb@mail.gmail.com> Subject: Re: Buffer.add_channel hangs From: Stas Miasnikou To: caml-list@yquem.inria.fr Content-Type: text/plain; charset=UTF-8 X-Spam: no; 0.00; buffer:01 ocaml:01 buffer:01 ocaml:01 10,:98 10,:98 char:01 char:01 wrote:01 wrote:01 int:01 int:01 bin:01 bin:01 behaviour:01 On 3/18/10, Stas Miasnikou wrote: > On 3/17/10, Stas Miasnikou wrote: >> OCaml 3.11.1, OpenBSD 4.6, i386. >> >> I am trying to read whole file by doing: >> >> let read_file_bin name = >> let ic = open_in_bin name in >> let b = Buffer.create 1024 in >> (try Buffer.add_channel b ic max_int with _ -> ()); (* <-- HERE *) >> close_in ic; >> Array.init (Buffer.length b) (fun i -> int_of_char (Buffer.nth b i)) >> >> but it hangs on the line marked. Am I doing something wrong? > > More on this, when doing: > > let read_file_bin name = > let ic = open_in_bin name in > let b = Buffer.create 1024 in > (try Buffer.add_channel b ic (n + 100) with _ -> ()); > close_in ic; > print_int (Buffer.length b); print_newline (); > Array.init (Buffer.length b) (fun i -> int_of_char (Buffer.nth b i)) > > With file length equal to n (65536) I get nothing read, i.e. after > reading Buffer.length b returns 0. Can anyone check this, so I know > whether this is OCaml or my OpenBSD 4.6 port of it issue? Aha, this behaviour is documented, mea culpa. Stas