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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 0E78FBC57 for ; Thu, 18 Mar 2010 18:52:22 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjACAJYFoktKfU4akGdsb2JhbACDC44PigwIFQEBAQEJCQwHEwMfqW03gWOFMy6ISwEBAwWBJ4JkaQQ X-IronPort-AV: E=Sophos;i="4.51,268,1267398000"; d="scan'208";a="55531383" Received: from ey-out-2122.google.com ([74.125.78.26]) by mail1-smtp-roc.national.inria.fr with ESMTP; 18 Mar 2010 18:52:21 +0100 Received: by ey-out-2122.google.com with SMTP id 4so207824eyf.31 for ; Thu, 18 Mar 2010 10:52:21 -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=6Ica+2C0GWOV3rvdXT4vdclkNc2ldpmATPPcn+EchMI=; b=QE4fTt/MFQZ9dcvfrIQP3UcA8lpEtt6GB6Td9181YGEfiIwpe4l4/x4mptO4qlO2jl 4KT6vsCPaIozdy7oD+6KwUNNDoEz/1K5oBEXDvG2ort/SHCJ66Dr9IoHEJuQxrulxfsI vKE0oW9WuB3SEJv0ngmBS4ni04SDmGnCkHtnw= 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=ntSjgUHH+QEp0F/BsmOY7XM7GApy8V6zU980BfL5rXlEYTPffGuzA1wAa+PfVElEqN 4p75thcyqCvILGUG3lc+e9pAWfeJhGmwwGDP2ffDTgMNbd/sJ38djvuuz1/PdxL4wc39 v++FAnKWD5EazxoJvNLade0yLmlBtnHVk7I44= MIME-Version: 1.0 Received: by 10.213.39.144 with SMTP id g16mr197434ebe.37.1268934741069; Thu, 18 Mar 2010 10:52:21 -0700 (PDT) In-Reply-To: <36ae71be1003171327h3dfe72f5t74d43ebc88035e3d@mail.gmail.com> References: <36ae71be1003171327h3dfe72f5t74d43ebc88035e3d@mail.gmail.com> Date: Thu, 18 Mar 2010 19:52:20 +0200 Message-ID: <36ae71be1003181052p2085e55ak525001db16b3aca0@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 char:01 char:01 wrote:01 int:01 int:01 bin:01 bin:01 hangs:01 hangs:01 newline:02 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? Stas