Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 041be05

Browse files
committed
Documented optional bufsize argument to open() and the fact that mode
is now also optional
1 parent 19806f4 commit 041be05

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

Doc/lib/libfuncs.tex

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,9 @@ \section{Built-in Functions}
206206
expression.
207207
\end{funcdesc}
208208

209-
\begin{funcdesc}{open}{filename\, mode}
210-
% XXXJH xrefs here to Built-in types?
209+
\begin{funcdesc}{open}{filename\, mode\, bufsize}
211210
Return a new file object (described earlier under Built-in Types).
212-
The string arguments are the same as for \code{stdio}'s
211+
The first two arguments are the same as for \code{stdio}'s
213212
\code{fopen()}: \var{filename} is the file name to be opened,
214213
\var{mode} indicates how the file is to be opened: \code{'r'} for
215214
reading, \code{'w'} for writing (truncating an existing file), and
@@ -219,6 +218,18 @@ \section{Built-in Functions}
219218
between binary and text files, \code{'b'} appended to the mode opens
220219
the file in binary mode. If the file cannot be opened, \code{IOError}
221220
is raised.
221+
If \var{mode} is omitted, it defaults to \code{'r'}.
222+
The optional \var{bufsize} argument specifies the file's desired
223+
buffer size: 0 means unbuffered, 1 means line buffered, any other
224+
positive value means use a buffer of (approximately) that size. A
225+
negative \var{bufsize} means to use the system default, which is
226+
usually line buffered for for tty devices and fully buffered for other
227+
files.%
228+
\footnote{Specifying a buffer size currently has no effect on systems
229+
that don't have \code{setvbuf()}. The interface to specify the buffer
230+
size is not done using a method that calls \code{setvbuf()}, because
231+
that may dump core when called after any I/O has been performed, and
232+
there's no reliable way to determine whether this is the case.}
222233
\end{funcdesc}
223234

224235
\begin{funcdesc}{ord}{c}

Doc/libfuncs.tex

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,9 @@ \section{Built-in Functions}
206206
expression.
207207
\end{funcdesc}
208208

209-
\begin{funcdesc}{open}{filename\, mode}
210-
% XXXJH xrefs here to Built-in types?
209+
\begin{funcdesc}{open}{filename\, mode\, bufsize}
211210
Return a new file object (described earlier under Built-in Types).
212-
The string arguments are the same as for \code{stdio}'s
211+
The first two arguments are the same as for \code{stdio}'s
213212
\code{fopen()}: \var{filename} is the file name to be opened,
214213
\var{mode} indicates how the file is to be opened: \code{'r'} for
215214
reading, \code{'w'} for writing (truncating an existing file), and
@@ -219,6 +218,18 @@ \section{Built-in Functions}
219218
between binary and text files, \code{'b'} appended to the mode opens
220219
the file in binary mode. If the file cannot be opened, \code{IOError}
221220
is raised.
221+
If \var{mode} is omitted, it defaults to \code{'r'}.
222+
The optional \var{bufsize} argument specifies the file's desired
223+
buffer size: 0 means unbuffered, 1 means line buffered, any other
224+
positive value means use a buffer of (approximately) that size. A
225+
negative \var{bufsize} means to use the system default, which is
226+
usually line buffered for for tty devices and fully buffered for other
227+
files.%
228+
\footnote{Specifying a buffer size currently has no effect on systems
229+
that don't have \code{setvbuf()}. The interface to specify the buffer
230+
size is not done using a method that calls \code{setvbuf()}, because
231+
that may dump core when called after any I/O has been performed, and
232+
there's no reliable way to determine whether this is the case.}
222233
\end{funcdesc}
223234

224235
\begin{funcdesc}{ord}{c}

0 commit comments

Comments
 (0)