From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from forward105j.mail.yandex.net (forward105j.mail.yandex.net [5.45.198.248]) by sourceware.org (Postfix) with ESMTPS id 466273839C45 for ; Tue, 11 May 2021 13:38:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 466273839C45 Received: from sas1-a507a9c2063d.qloud-c.yandex.net (sas1-a507a9c2063d.qloud-c.yandex.net [IPv6:2a02:6b8:c08:f215:0:640:a507:a9c2]) by forward105j.mail.yandex.net (Yandex) with ESMTP id 5CB4FB21D8D; Tue, 11 May 2021 16:38:50 +0300 (MSK) Received: from sas1-e00c2743cdb8.qloud-c.yandex.net (sas1-e00c2743cdb8.qloud-c.yandex.net [2a02:6b8:c14:3a22:0:640:e00c:2743]) by sas1-a507a9c2063d.qloud-c.yandex.net (mxback/Yandex) with ESMTP id Do28KS8TGE-coIqqc7T; Tue, 11 May 2021 16:38:50 +0300 Received: by sas1-e00c2743cdb8.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id WNosNgL6Ue-cnL0OXKq; Tue, 11 May 2021 16:38:49 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Message-ID: <441ba9e9ac3b9ed851b10d39025f905eef21cdea.camel@yandex.ru> Subject: Re: EOF is a misnomer? From: Konstantin Kharlamov To: Peng Yu , libc-help@sourceware.org Date: Tue, 11 May 2021 16:38:49 +0300 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 13:38:54 -0000 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.