Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer.add_channel discards data #7136

Closed
vicuna opened this issue Feb 5, 2016 · 1 comment
Closed

Buffer.add_channel discards data #7136

vicuna opened this issue Feb 5, 2016 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Feb 5, 2016

Original bug ID: 7136
Reporter: @yallop
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2017-09-24T15:31:48Z)
Resolution: duplicate
Priority: normal
Severity: minor
Fixed in version: 4.03.0+dev / +beta1
Category: standard library
Duplicate of: #6719

Bug description

The documentation for Buffer.add_channel says:

Raise [End_of_file] if the channel contains fewer than [n]
characters. In this case, the characters are still added to
the buffer, so as to avoid loss of data.

However, when End_of_file is raised the characters are not added to the buffer:

$ cat abc.txt
abc
$ ocaml
OCaml version 4.02.3

let buf = Buffer.create 10;;

val buf : Buffer.t =

Buffer.add_channel buf (open_in "abc.txt") 10;;

Exception: End_of_file.

Buffer.contents buf;;

  • : string = ""
@vicuna
Copy link
Author

vicuna commented Feb 5, 2016

Comment author: @gasche

The .mli you observe is only in trunk, it corresponds to the new behavior contributed by Simon Cruanes in

#6719
#129

The 4.03 documentation
http://caml.inria.fr/pub/docs/manual-ocaml/libref/Buffer.html
reads

add_channel b ic n reads exactly n character from the input channel ic and stores them at the end of buffer b. Raise End_of_file if the channel contains fewer than n characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants