public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: linux-man@vger.kernel.org
Cc: Alejandro Colomar <alx@kernel.org>,
	"G. Branden Robinson" <g.branden.robinson@gmail.com>
Subject: [PATCH] EOF.3const: Add documentation for EOF
Date: Fri, 14 Oct 2022 21:18:05 +0200	[thread overview]
Message-ID: <20221014191804.26914-1-alx@kernel.org> (raw)

Reported-by: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
---

Hi Branden!

How do you feel about this page?

I wasn't inspired to write an example program.  I welcome any input if
you or someone reading the list has a trivial one at hand.

Cheers,
Alex

 man3const/EOF.3const | 54 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 man3const/EOF.3const

diff --git a/man3const/EOF.3const b/man3const/EOF.3const
new file mode 100644
index 000000000..f59511a47
--- /dev/null
+++ b/man3const/EOF.3const
@@ -0,0 +1,54 @@
+.\" Copyright (c) 2022 by Alejandro Colomar <alx@kernel.org>
+.\"
+.\" SPDX-License-Identifier: Linux-man-pages-copyleft
+.\"
+.\"
+.TH EOF 3const (date) "Linux man-pages (unreleased)"
+.SH NAME
+EOF \- end of file or error indicator
+.SH LIBRARY
+Standard C library
+.RI ( libc )
+.SH SYNOPSIS
+.nf
+.B #include <stdio.h>
+.PP
+.B "#define EOF  /* ... */"
+.fi
+.SH DESCRIPTION
+.B EOF
+represents the end of an input file, or an error indication.
+It is a negative value, of type
+.IR int .
+.PP
+.B EOF
+is not a character
+(it can't be represented by
+.IR "unsigned char" ).
+It is instead a sentinel value outside of the valid range for valid characters.
+.SH CONFORMING TO
+C99 and later;
+POSIX.1-2001 and later.
+.SH CAVEATS
+.SS Input
+Programs should read the return value of an input function
+before using functions of the
+.BR feof (3)
+family.
+Only when the function returned the sentinel value
+.B EOF
+it makes sense to distinguish between the end of a file or an error with
+.BR feof (3)
+or
+.BR ferror (3).
+.SS Output
+Programs can't pass this value to an output function
+to "write" the end of a file.
+That would likely result in undefined behavior.
+Instead,
+closing the writing stream or file descriptor
+that refers to such file
+is the way to signal the end of that file.
+.SH SEE ALSO
+.BR feof (3),
+.BR fgetc (3)
-- 
2.37.2


             reply	other threads:[~2022-10-14 19:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-14 19:18 Alejandro Colomar [this message]
2022-10-14 19:25 ` [PATCH] EOF.3const: Add documentation for EOF Alejandro Colomar

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=20221014191804.26914-1-alx@kernel.org \
    --to=alx.manpages@gmail.com \
    --cc=alx@kernel.org \
    --cc=g.branden.robinson@gmail.com \
    --cc=linux-man@vger.kernel.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