From: _z33 <timid.Gentoo@gmail.com>
To: linux-c-programming@vger.kernel.org
Subject: Re: Confusing Prototype
Date: Tue, 13 Sep 2005 09:26:50 +0530 [thread overview]
Message-ID: <dg5im3$etc$1@sea.gmane.org> (raw)
In-Reply-To: <6a00c8d5050912093622607b44@mail.gmail.com>
Steve Graegert wrote:
>
> Sorry, I do not fully agree.
I knew I must have gone wrong somewhere ;-)
> NULL is also returned when the system
> encountered EOF. SUSv3 says that if EOF or an error occurred the
> stream's EOF/error indicator is set, which means that to make sure
> what happened you will have to call ferror and feof anyway. In both
> cases the buffer is left unchanged.
>
> From this point of view, returning an int indicating an error and EOF
> with a value of 0 and the number of bytes read otherwise would be
> sufficient. One could then write
>
> while (fgets(buf, BUFSIZE, stream) > 0) { /* do some stuff */ }
>
I agree absolutely.
> For me, it is an academic discussion and I can live with the current
> solution quite well. Besides this, I have had the opportunity to
> implement parts of an IO library for an embedded project and we have
> chosen not to return a pointer to the input buffer but the number of
> bytes actually read or 0 on EOF or error. It was possible since
> everything was written from scratch, so nothing broke.
nice solution.
_z33
--
I love TUX; well... that's an understatement :)
next prev parent reply other threads:[~2005-09-13 3:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-11 18:00 Confusing Prototype James Colannino
2005-09-12 12:30 ` _z33
2005-09-12 16:36 ` Steve Graegert
2005-09-13 3:56 ` _z33 [this message]
2005-09-13 18:34 ` Steve Graegert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='dg5im3$etc$1@sea.gmane.org' \
--to=timid.gentoo@gmail.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).