From patchwork Wed Sep 25 09:48:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1989276 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RAJvBHwJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XDBl13BtMz1xt4 for ; Wed, 25 Sep 2024 19:49:01 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9B8C13858403 for ; Wed, 25 Sep 2024 09:48:59 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 852E13858D28 for ; Wed, 25 Sep 2024 09:48:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 852E13858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 852E13858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727257725; cv=none; b=CGu+aowEzptftH2RDRF3agv4v20LC2hW2txfpMu5/Y2kPzVIY7uH55KQkAibhwdl/t6hVeacwGxGtrJlleLY2egRPxsYfLJ76d+kI4JGBllgmr9O5UCBI1u9pZPPw0bA7MqK++3MnxnFg3H6l6uHAwIrYVg4zYk6o1g+6J2n9RU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727257725; c=relaxed/simple; bh=QjTBtrLh+OipwA8bWgLw29OBhZ9UFqjJsKbwvrYuid4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=vP8S6HtByWtPqfCskuebVJTRNJz28TfOYHapn8BTf8YngDNIkk6ZOYgTGER8xAuLMIswGUQwGndrRpqnUsmg4MzPWE5apXZGztaM5EnsViBT/1subg3qtydMqwfFNnddEClN5cF9YuUnpG/szxUwsJWXWB0ilAl5K6h2inUyPaE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727257716; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=3cdc10FVZh+EJdonBeFm0+36jCydjh0xxrGeyPsn95g=; b=RAJvBHwJGlWjaWykRqIItyBAEDqiK/HoyuVNS22zWQM7sLbbeZjZmBjUC4sKgOGJr+ZZOd B3tl8pIukqFHh4Fz9zfQDnW0nzsl3SJJ7FGiOwh5CaHC01T67Jx0YG0daVjL1RFVC6U9N2 s1dgQ5tFSr/V9kKXEUfdNia+4Gotn6o= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-202-QShzXdq6P0G31sSVaTjejg-1; Wed, 25 Sep 2024 05:48:35 -0400 X-MC-Unique: QShzXdq6P0G31sSVaTjejg-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 709B4196C430 for ; Wed, 25 Sep 2024 09:48:34 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.45.224.151]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1B5701956054; Wed, 25 Sep 2024 09:48:32 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Cc: DJ Delorie Subject: [PATCH v2] manual: Document that feof and ferror are mutually exclusive Date: Wed, 25 Sep 2024 11:48:30 +0200 Message-ID: <87frpoawsx.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org This is not completely clear from the C standard (although there is footnote number 289 in C11), but I assume that our implementation works this way. --- v2: Additional language to clarify that feof can be reported on wide streams. manual/stdio.texi | 9 +++++++++ 1 file changed, 9 insertions(+) base-commit: 4ff55d08df0e6f11cbd217f4dca4532bd7d9330d diff --git a/manual/stdio.texi b/manual/stdio.texi index 8590ae955a..c7a2b4a9a1 100644 --- a/manual/stdio.texi +++ b/manual/stdio.texi @@ -4168,6 +4168,15 @@ check indicators that are part of the internal state of the stream object, indicators set if the appropriate condition was detected by a previous I/O operation on that stream. +The end of file and error conditions are mutually exclusive. For a +narrow oriented stream, end of file is not considered an error. For +wide oriented streams, reaching the end of the underlying file can +result an error if the underlying file ends with an incomplete multibyte +sequence. This is reported as an error by @code{ferror}, and not as an +end of file by @code{feof}. End of file on wide oriented streams that +does not fall into the middle of a multibyte sequence is reported via +@code{feof}. + @deftypevr Macro int EOF @standards{ISO, stdio.h} This macro is an integer value that is returned by a number of narrow