From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by sourceware.org (Postfix) with ESMTPS id ABB5C3839C45 for ; Tue, 11 May 2021 13:27:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org ABB5C3839C45 Received: by mail-io1-xd29.google.com with SMTP id l21so18155903iob.1 for ; Tue, 11 May 2021 06:27:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=1H8qz8PkyJS6xaPjFxDvEZPQ7uOeyr6ywqNeSPAyAtI=; b=k0iVzlkjI77pt5i0HwzUoynY8YJL/hHYgdNhUg2gPd45YJlyWHRQ5KmzoTqaTBTT6g 7rvXnlGDg+Dh6OsQdJhgl3Mm9l/wKNi4/JcIPAIlptlmz7FFFj76f/3m8zBVhVOPQOLj iEwInxU+sqjJgLGneNS60A55NUzbTPYpKCNDkR0/0UydLTxXylYhhxGV2jWWi4b5lXRY oG0SAuFSozMHUSnT8ftl8OjVNP374nqAvL+GECPIDTJ9ki7Fkf8KT8jYCGth2KSAwm2I X4bSsSwoLG4bF9JOYmwdG6mUD8PFKL6y2EsjPAqghcZrCiS1Os6AkycPwMVHN3WGNFyo 4iWg== X-Gm-Message-State: AOAM531CoYlYe9VAZcHU+jSQbuZZJl0H6XiX7XUUmgUMnxvtOVYsUGtx SohSQjxqzP0ufkphDxY/GSdLK5IS42pdlXKrWT5NgUYeQ2w= X-Google-Smtp-Source: ABdhPJzcstbE8JrOfO9Arr4J2a+ZJRAQYuiD7RrxIKygy1h4DnbqaxZbmITN6DS8es6YR3ulCfsqczgn5iHJLMUMMrU= X-Received: by 2002:a5e:9e4a:: with SMTP id j10mr22558983ioq.52.1620739666783; Tue, 11 May 2021 06:27:46 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a5e:d714:0:0:0:0:0 with HTTP; Tue, 11 May 2021 06:27:46 -0700 (PDT) From: Peng Yu Date: Tue, 11 May 2021 08:27:46 -0500 Message-ID: Subject: EOF is a misnomer? To: libc-help@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, 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:27:48 -0000 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