caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Stas Miasnikou <stas.miasnikou@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Re: Buffer.add_channel hangs
Date: Sat, 20 Mar 2010 10:29:16 +0200	[thread overview]
Message-ID: <36ae71be1003200129vc6060a1ib75aa038b0ee0ddb@mail.gmail.com> (raw)
In-Reply-To: <36ae71be1003181052p2085e55ak525001db16b3aca0@mail.gmail.com>

On 3/18/10, Stas Miasnikou <stas.miasnikou@gmail.com> wrote:
> On 3/17/10, Stas Miasnikou <stas.miasnikou@gmail.com> 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


      reply	other threads:[~2010-03-20  8:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-17 20:27 Stas Miasnikou
2010-03-17 23:20 ` [Caml-list] " Martin Jambon
2010-03-18  6:47   ` Stas Miasnikou
2010-03-18  9:09     ` Fabrice Le Fessant
2010-03-18  2:53 ` Goswin von Brederlow
2010-03-18 17:52 ` Stas Miasnikou
2010-03-20  8:29   ` Stas Miasnikou [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=36ae71be1003200129vc6060a1ib75aa038b0ee0ddb@mail.gmail.com \
    --to=stas.miasnikou@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).