public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Peng Yu <pengyu.ut@gmail.com>
To: libc-help@sourceware.org
Subject: EOF is a misnomer?
Date: Tue, 11 May 2021 08:27:46 -0500	[thread overview]
Message-ID: <CABrM6wk_Y-Xff+=ZwHZjm-LMkFuG2OpQG9rzkLfp_c3qnX9D3Q@mail.gmail.com> (raw)

man getchar says

"       fgetc(), getc(), and getchar() return the character read as an unsigned
       char cast to an int or EOF on end of file or error."

EOF literally stands for end of file. But the above functions can
return EOF when there is an error.

In feof(), "eof" just means end of file as shown in man feof.

       The function feof() tests the  end-of-file  indicator  for  the  stream
       pointed  to by stream, returning nonzero if it is set.  The end-of-file
       indicator can be cleared only by the function clearer().

So the macro name EOF is a misnomer. It could have been named as
something like EOF_OR_ERR? The fact that its name is EOF is due to
some historical reasons? Thanks.

-- 
Regards,
Peng

             reply	other threads:[~2021-05-11 13:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11 13:27 Peng Yu [this message]
2021-05-11 13:38 ` Konstantin Kharlamov
2021-05-11 14:11   ` Peng Yu
2021-05-11 13:42 ` Florian Weimer

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='CABrM6wk_Y-Xff+=ZwHZjm-LMkFuG2OpQG9rzkLfp_c3qnX9D3Q@mail.gmail.com' \
    --to=pengyu.ut@gmail.com \
    --cc=libc-help@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).