mirror of https://github.com/mkerrisk/man-pages
Various minor clarifications.
This commit is contained in:
parent
aa52d7769a
commit
2df47dc8f1
|
@ -21,7 +21,7 @@
|
||||||
.\" Formatted or processed versions of this manual, if unaccompanied by
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
||||||
.\" the source, must acknowledge the copyright and authors of this work.
|
.\" the source, must acknowledge the copyright and authors of this work.
|
||||||
.\" License.
|
.\" License.
|
||||||
.TH GETLINE 3 2001-10-07 "GNU" "Linux Programmer's Manual"
|
.TH GETLINE 3 2006-05-17 "GNU" "Linux Programmer's Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
getline, getdelim \- delimited string input
|
getline, getdelim \- delimited string input
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
@ -34,19 +34,19 @@ getline, getdelim \- delimited string input
|
||||||
.BI "ssize_t getdelim(char **" lineptr ", size_t *" n ", int " delim ", FILE *" stream );
|
.BI "ssize_t getdelim(char **" lineptr ", size_t *" n ", int " delim ", FILE *" stream );
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.BR getline ()
|
.BR getline ()
|
||||||
reads an entire line, storing the address of the buffer containing
|
reads an entire line from \fIstream\fP,
|
||||||
the text into
|
storing the address of the buffer containing the text into
|
||||||
.IR "*lineptr" .
|
.IR "*lineptr" .
|
||||||
The buffer is null-terminated and includes the newline character, if a
|
The buffer is null-terminated and includes the newline character, if
|
||||||
newline delimiter was found.
|
one was found.
|
||||||
|
|
||||||
.\" FIXME what happens if *lineptr is NULL but *n isn't zero ?
|
.\" FIXME what happens if *lineptr is NULL but *n isn't zero ?
|
||||||
.\" Answer: *n is ignored and a new buffer is allocated
|
.\" Answer: *n is ignored and a new buffer is allocated
|
||||||
If
|
If
|
||||||
.IR "*lineptr"
|
.IR "*lineptr"
|
||||||
is NULL, then the
|
is NULL, then
|
||||||
.BR getline ()
|
.BR getline ()
|
||||||
routine will allocate a buffer for containing the line, which must be freed
|
will allocate a buffer for storing the line, which should be freed
|
||||||
by the user program.
|
by the user program.
|
||||||
Alternatively, before calling
|
Alternatively, before calling
|
||||||
.BR getline (),
|
.BR getline (),
|
||||||
|
@ -55,9 +55,9 @@ can contain a pointer to a
|
||||||
.BR malloc ()\-allocated
|
.BR malloc ()\-allocated
|
||||||
buffer
|
buffer
|
||||||
.IR "*n"
|
.IR "*n"
|
||||||
bytes in size. If the buffer is not large enough to hold the line read in,
|
bytes in size. If the buffer is not large enough to hold the line,
|
||||||
.BR getline ()
|
.BR getline ()
|
||||||
resizes the buffer to fit with
|
resizes it with
|
||||||
.BR realloc (),
|
.BR realloc (),
|
||||||
updating
|
updating
|
||||||
.IR "*lineptr"
|
.IR "*lineptr"
|
||||||
|
@ -67,7 +67,7 @@ as necessary. In either case, on a successful call,
|
||||||
.IR "*lineptr"
|
.IR "*lineptr"
|
||||||
and
|
and
|
||||||
.IR "*n"
|
.IR "*n"
|
||||||
will be updated to reflect the buffer address and size respectively.
|
will be updated to reflect the buffer address and allocated size respectively.
|
||||||
|
|
||||||
.BR getdelim ()
|
.BR getdelim ()
|
||||||
works like
|
works like
|
||||||
|
@ -78,7 +78,6 @@ argument. As with
|
||||||
.BR getline (),
|
.BR getline (),
|
||||||
a delimiter character is not added if one was not present
|
a delimiter character is not added if one was not present
|
||||||
in the input before end of file was reached.
|
in the input before end of file was reached.
|
||||||
|
|
||||||
.SH "RETURN VALUE"
|
.SH "RETURN VALUE"
|
||||||
On success,
|
On success,
|
||||||
.BR getline ()
|
.BR getline ()
|
||||||
|
@ -90,7 +89,6 @@ to handle embedded null bytes in the line read.
|
||||||
|
|
||||||
Both functions return \-1 on failure to read a line (including end of file
|
Both functions return \-1 on failure to read a line (including end of file
|
||||||
condition).
|
condition).
|
||||||
|
|
||||||
.SH ERRORS
|
.SH ERRORS
|
||||||
.TP
|
.TP
|
||||||
.B EINVAL
|
.B EINVAL
|
||||||
|
@ -101,7 +99,6 @@ or
|
||||||
is NULL, or
|
is NULL, or
|
||||||
.I stream
|
.I stream
|
||||||
is not valid).
|
is not valid).
|
||||||
|
|
||||||
.SH "EXAMPLE"
|
.SH "EXAMPLE"
|
||||||
.nf
|
.nf
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
@ -133,7 +130,6 @@ and
|
||||||
.BR getdelim ()
|
.BR getdelim ()
|
||||||
are GNU extensions.
|
are GNU extensions.
|
||||||
They are available since libc 4.6.27.
|
They are available since libc 4.6.27.
|
||||||
|
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
.BR read (2),
|
.BR read (2),
|
||||||
.BR fgets (3),
|
.BR fgets (3),
|
||||||
|
|
Loading…
Reference in New Issue