public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Konstantin Kharlamov <hi-angel@yandex.ru>
To: Peng Yu <pengyu.ut@gmail.com>, libc-help@sourceware.org
Subject: Re: EOF is a misnomer?
Date: Tue, 11 May 2021 16:38:49 +0300	[thread overview]
Message-ID: <441ba9e9ac3b9ed851b10d39025f905eef21cdea.camel@yandex.ru> (raw)
In-Reply-To: <CABrM6wk_Y-Xff+=ZwHZjm-LMkFuG2OpQG9rzkLfp_c3qnX9D3Q@mail.gmail.com>

On Tue, 2021-05-11 at 08:27 -0500, Peng Yu via Libc-help wrote:
> 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.
> 

You are probably right, but I don't think it is correct to ask that question to libc developers, whether it is Glibc or any other libc. The functions in question are part of C standard: https://en.cppreference.com/w/c/io/fgetc So any change in that regard would have to go through the procedure of sending a C language proposal to C committee.

That said, making any change to C language is very hard, see this article https://thephd.github.io/your-c-compiler-and-standard-library-will-not-help-you from a member of C committee. These days though I doubt there's much point in making changes to C, because we have Rust instead, which slowly makes its way even to the Linux kernel.


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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11 13:27 Peng Yu
2021-05-11 13:38 ` Konstantin Kharlamov [this message]
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=441ba9e9ac3b9ed851b10d39025f905eef21cdea.camel@yandex.ru \
    --to=hi-angel@yandex.ru \
    --cc=libc-help@sourceware.org \
    --cc=pengyu.ut@gmail.com \
    /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).