Document the issue with pos_{in,out} and files opened in text mode

Add changes for 9872
master
Xavier Leroy 2020-09-02 11:16:12 +02:00
parent 09f2b9dd57
commit 83c762974b
2 changed files with 19 additions and 3 deletions

View File

@ -393,7 +393,6 @@ Working version
cancause link-time errors with link-time optimization (LTO).
(Xavier Leroy, report by Richard Jones, review by Nicolás Ojeda Bär)
- #9753: fix build for Android
(Github user @EduardoRFS, review by Xavier Leroy)
@ -403,6 +402,11 @@ Working version
- #9860: wrong range constraint for subtract immediate on zSystems / s390x
(Xavier Leroy, review by Stephen Dolan)
- #9868, #9872: bugs in {in,out}_channel_length and seek_in
for files opened in text mode under Windows
(Xavier Leroy, report by Alain Frisch, review by Nicolás Ojeda Bär
and Alain Frisch)
OCaml 4.11
----------

View File

@ -998,7 +998,13 @@ val seek_out : out_channel -> int -> unit
val pos_out : out_channel -> int
(** Return the current writing position for the given channel. Does
not work on channels opened with the [Open_append] flag (returns
unspecified results). *)
unspecified results).
For files opened in text mode under Windows, the returned position
is approximate (owing to end-of-line conversion); in particular,
saving the current position with [pos_out], then going back to
this position using [seek_out] will not work. For this
programming idiom to work reliably and portably, the file must be
opened in binary mode. *)
val out_channel_length : out_channel -> int
(** Return the size (number of characters) of the regular file
@ -1113,7 +1119,13 @@ val seek_in : in_channel -> int -> unit
files of other kinds, the behavior is unspecified. *)
val pos_in : in_channel -> int
(** Return the current reading position for the given channel. *)
(** Return the current reading position for the given channel. For
files opened in text mode under Windows, the returned position is
approximate (owing to end-of-line conversion); in particular,
saving the current position with [pos_in], then going back to this
position using [seek_in] will not work. For this programming
idiom to work reliably and portably, the file must be opened in
binary mode. *)
val in_channel_length : in_channel -> int
(** Return the size (number of characters) of the regular file