public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/5468] New: Error in getline(3) manpage
@ 2007-12-10 22:42 luke dot hutch at mit dot edu
2007-12-10 22:52 ` [Bug libc/5468] " drepper at redhat dot com
0 siblings, 1 reply; 4+ messages in thread
From: luke dot hutch at mit dot edu @ 2007-12-10 22:42 UTC (permalink / raw)
To: glibc-bugs
The getline(3) manpage states:
ssize_t getline(char **lineptr, size_t *n, FILE *stream);
[...]
If *lineptr is NULL, then getline() will allocate a buffer for
storing the line, which should be
freed by the user program. (The value in *n is ignored.)
Based on this description (particularly the part that says the value *n is
ignored), you should be able to do something like:
char *line = NULL;
getline(&line, NULL, stream);
However this always fails, because the code for getline does the following:
if (!lineptr || !n || !stream)
{
errno = EINVAL;
return -1;
}
if (!*lineptr)
{
*n = MIN_CHUNK;
*lineptr = malloc (*n);
if (!*lineptr)
{
errno = ENOMEM;
return -1;
}
*lineptr[0] = '\0';
}
(thus the !n check always causes -1 to be returned).
Probably the manpage should just be modified to say something like "(The value
in *n is ignored on entry, but *n must still point to a valid int, and its value
is updated on exit to reflect the size of the newly malloc'd buffer.)"
This is pretty confusing behavior otherwise -- I had to read the source for
getline() to know what was going on.
Thanks!
--
Summary: Error in getline(3) manpage
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: luke dot hutch at mit dot edu
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=5468
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/5468] Error in getline(3) manpage
2007-12-10 22:42 [Bug libc/5468] New: Error in getline(3) manpage luke dot hutch at mit dot edu
@ 2007-12-10 22:52 ` drepper at redhat dot com
0 siblings, 0 replies; 4+ messages in thread
From: drepper at redhat dot com @ 2007-12-10 22:52 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From drepper at redhat dot com 2007-12-10 22:52 -------
glibc does not come with man pages.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |WONTFIX
http://sourceware.org/bugzilla/show_bug.cgi?id=5468
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/5468] Error in getline(3) manpage
[not found] <bug-5468-131@http.sourceware.org/bugzilla/>
2014-01-07 21:02 ` mtk.manpages at gmail dot com
@ 2014-01-07 21:04 ` mtk.manpages at gmail dot com
1 sibling, 0 replies; 4+ messages in thread
From: mtk.manpages at gmail dot com @ 2014-01-07 21:04 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=5468
--- Comment #3 from Michael Kerrisk <mtk.manpages at gmail dot com> ---
(In reply to Luke Hutchison from comment #0)
> The getline(3) manpage states:
>
> ssize_t getline(char **lineptr, size_t *n, FILE *stream);
> [...]
> If *lineptr is NULL, then getline() will allocate a buffer for
> storing the line, which should be
> freed by the user program. (The value in *n is ignored.)
>
> Based on this description (particularly the part that says the value *n is
> ignored), you should be able to do something like:
>
> char *line = NULL;
> getline(&line, NULL, stream);
>
> However this always fails, because the code for getline does the following:
>
> if (!lineptr || !n || !stream)
> {
> errno = EINVAL;
> return -1;
> }
>
> if (!*lineptr)
> {
> *n = MIN_CHUNK;
> *lineptr = malloc (*n);
> if (!*lineptr)
> {
> errno = ENOMEM;
> return -1;
> }
> *lineptr[0] = '\0';
> }
>
> (thus the !n check always causes -1 to be returned).
>
> Probably the manpage should just be modified to say something like "(The
> value
> in *n is ignored on entry, but *n must still point to a valid int, and its
> value
> is updated on exit to reflect the size of the newly malloc'd buffer.)"
>
> This is pretty confusing behavior otherwise -- I had to read the source for
> getline() to know what was going on.
>
> Thanks!
getline(3) text changed to read:
If *lineptr is set to NULL and *n is set 0 before the call,
then getline() will allocate a buffer for storing the line,
which should be freed by the user program.
--
You are receiving this mail because:
You are on the CC list for the bug.
>From glibc-bugs-return-20701-listarch-glibc-bugs=sources.redhat.com@sourceware.org Tue Jan 07 21:09:09 2014
Return-Path: <glibc-bugs-return-20701-listarch-glibc-bugs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-glibc-bugs@sources.redhat.com
Received: (qmail 6523 invoked by alias); 7 Jan 2014 21:09:09 -0000
Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <glibc-bugs.sourceware.org>
List-Subscribe: <mailto:glibc-bugs-subscribe@sourceware.org>
List-Post: <mailto:glibc-bugs@sourceware.org>
List-Help: <mailto:glibc-bugs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: glibc-bugs-owner@sourceware.org
Delivered-To: mailing list glibc-bugs@sourceware.org
Received: (qmail 6466 invoked by uid 48); 7 Jan 2014 21:09:05 -0000
From: "bje at sources dot redhat.com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug manual/1481] No man pages are part of glibc, DO NOT REPORT MAN PAGE BUGS HERE!
Date: Tue, 07 Jan 2014 21:09:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: glibc
X-Bugzilla-Component: manual
X-Bugzilla-Version: unspecified
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: bje at sources dot redhat.com
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: roland at gnu dot org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-1481-131-F6XyW2jxez@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-1481-131@http.sourceware.org/bugzilla/>
References: <bug-1481-131@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-01/txt/msg00102.txt.bz2
Content-length: 377
https://sourceware.org/bugzilla/show_bug.cgi?id\x1481
Ben Elliston <bje at sources dot redhat.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC|bje at sources dot redhat.com |
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/5468] Error in getline(3) manpage
[not found] <bug-5468-131@http.sourceware.org/bugzilla/>
@ 2014-01-07 21:02 ` mtk.manpages at gmail dot com
2014-01-07 21:04 ` mtk.manpages at gmail dot com
1 sibling, 0 replies; 4+ messages in thread
From: mtk.manpages at gmail dot com @ 2014-01-07 21:02 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=5468
Michael Kerrisk <mtk.manpages at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mtk.manpages at gmail dot com
Resolution|WONTFIX |DUPLICATE
--- Comment #2 from Michael Kerrisk <mtk.manpages at gmail dot com> ---
*** This bug has been marked as a duplicate of bug 1481 ***
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-01-07 21:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-10 22:42 [Bug libc/5468] New: Error in getline(3) manpage luke dot hutch at mit dot edu
2007-12-10 22:52 ` [Bug libc/5468] " drepper at redhat dot com
[not found] <bug-5468-131@http.sourceware.org/bugzilla/>
2014-01-07 21:02 ` mtk.manpages at gmail dot com
2014-01-07 21:04 ` mtk.manpages at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).