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

Documentation of Pervasives.input #2338

Closed
vicuna opened this issue Dec 20, 1999 · 1 comment
Closed

Documentation of Pervasives.input #2338

vicuna opened this issue Dec 20, 1999 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Dec 20, 1999

Original bug ID: 10
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Norman Ramsey
Version:
OS:
Submission from: estephe.inria.fr (128.93.11.95)
Submitted by: xleroy

The documentation for input needs to be improved.
The existing documentation reads as follows:

val input : in_channel -> string -> int -> int -> int

 input chan buff ofs len attempts to read len characters from
 channel chan, storing them in string buff, starting at character
 number ofs. It returns the actual number of characters read,
 between 0 and len (inclusive). A return value of 0 means that the
 end of file was reached. A return value between 0 and len
 exclusive means that no more characters were available at that
 time; input must be called again to read the remaining
 characters, if desired. Exception Invalid_argument "input" is
 raised if ofs and len do not designate a valid substring of buff.

The key phrase is ``no more characters were available at that time.''
I interpreted this to mean if I read from an ordinary disk file, I
would be guaranteed to get as many characters as were available.
Boy, was I wrong. If I try to read 31 characters at offset 4092 from
a 120696-character file, I get only 4 characters. What a surprise!

I would prefer the following wording:

 input chan buff ofs len reads up to len characters from channel
 chan, storing them in string buff, starting at character number
 ofs.  It returns the actual number of characters read, between 0
 and len (inclusive). A return value of 0 means that the end of
 file was reached. A return value between 0 and len exclusive
 means that the implementation did not find it convenient to
 return len characters; input must be called again to read the
 remaining characters, if desired. Exception Invalid_argument
 "input" is raised if ofs and len do not designate a valid
 substring of buff.

I would have used really_input, except I didn't find a way to figure
out how many characters were read before the end of file.

@vicuna
Copy link
Author

vicuna commented Feb 7, 2000

Comment author: administrator

Fixed in 3.00

@vicuna vicuna closed this as completed Feb 7, 2000
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant