diff options
author | Xavier Leroy <xavier.leroy@college-de-france.fr> | 2020-09-02 11:16:12 +0200 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@college-de-france.fr> | 2020-09-08 09:51:35 +0200 |
commit | 83c762974bdb32fe4cb80361bfe2a0d35ba71a05 (patch) | |
tree | 817962ef35cdc8e82dcef10d4625a1e2a06e77c2 /stdlib/stdlib.mli | |
parent | 09f2b9dd574d29468807b121e95bc0ac2ac34afc (diff) | |
download | ocaml-83c762974bdb32fe4cb80361bfe2a0d35ba71a05.tar.gz |
Document the issue with pos_{in,out} and files opened in text mode
Add changes for 9872
Diffstat (limited to 'stdlib/stdlib.mli')
-rw-r--r-- | stdlib/stdlib.mli | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/stdlib/stdlib.mli b/stdlib/stdlib.mli index efd5e9a974..e45e362d53 100644 --- a/stdlib/stdlib.mli +++ b/stdlib/stdlib.mli @@ -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 |