🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1833

Re: Yet another digression (was Re: [meta] O tempora, o mores! (was Re: does an expression in a logical statement need parenthes...

#1833
From: Keith Thompson
Date: Wed, 25 Nov 2026 00:50
49 lines
4117 bytes
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
> On 2026-11-24 05:15, James Kuyper wrote:
[...]
>> "Whether the last line requires a terminating new-line character is
>> implementation-defined." (7.24.2p2 n3998.pdf)
>
> Working in POSIX environments, though, we have the certainty and we
> need not rely on the (yet another) uncertainty that the C-standard
> exposes here.
>
> (Personally I'm not much concerned as I'm always creating terminated
> lines in text-files. I'm also using an editor where the editor cares
> about detecting and creating correct representations in files, and
> which facilitates me to control that in (very rare) cases where I'd
> need it.)
[...]

Here's what POSIX says.

https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap03.html

    3.185 Line
    A sequence of zero or more non-<newline> characters plus a
    terminating <newline> character.

    3.387 Text File
    A file that contains characters organized into zero or more
    lines. The lines do not contain NUL characters and none can
    exceed {LINE_MAX} bytes in length, including the <newline>
    character. Although POSIX.1-2024 does not distinguish between
    text files and binary files (see the ISO C standard), many
    utilities only produce predictable or meaningful output when
    operating on text files. The standard utilities that have such
    restrictions always specify "text files" in their STDIN or
    INPUT FILES sections.

So as far as C is concerned, a non-empty file not ending in a newline
may or may not be a text file, but in POSIX it is not.  And yes,
many tools will, at least by default, ensure that a created or
updated non-empty text file will end with a newline character.

But there are text-like files that don't end in a newline character
(or that have lines exceeding LINE_MAX bytes), and I expect the
tools I use to deal with such files reasonably, even if POSIX
does't require it.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Technical Details
Message-ID: <11e5bcb$3as5s$1@kst.eternal-september.org>
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!kst.eternal-september.org!.POSTED!not-for-mail
References: <11cj4a0$23796$1@dont-email.me> <JzOdnc2k5ZGeHmD3nZ2dnZfqn_qdnZ2d@giganews.com> <11dl9ou$1p00u$1@kst.eternal-september.org> <11dm94c$21u9i$1@dont-email.me> <11dmbq9$s03n$7@dont-email.me> <11dmhg2$24tb6$1@dont-email.me> <11dmib8$s03n$9@dont-email.me> <11dmqbl$289i4$1@dont-email.me> <11dmu0s$s03n$10@dont-email.me> <11dmuv3$2a3c0$1@dont-email.me> <11dnr4c$2lhv9$1@kst.eternal-september.org> <11doth7$2vhee$1@dont-email.me> <11dqpqg$3masv$2@dont-email.me> <11drvdj$12fg$1@dont-email.me> <11dt66g$fjb5$2@dont-email.me> <11dui6a$scjp$1@dont-email.me> <SpOcnXL7lP_FgJ72nZ2dnZfqn_idnZ2d@giganews.com> <RdadnUbexs0JvZ72nZ2dnZfqnPednZ2d@giganews.com> <11e136t$f9ab$1@dont-email.me> <11e331r$2gekc$1@dont-email.me> <11e3bhk$2a7k9$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!kst.eternal-september.org!.POSTED!not-for-mail
From: Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: Yet another digression (was Re: [meta] O tempora, o mores! (was Re: does an expression in a logical statement need parenthesis for proper evaluation?))
Date: Tue, 24 Nov 2026 16:50:14 -0800
Organization: None to speak of
Lines: 49
Message-ID: <11e5bcb$3as5s$1@kst.eternal-september.org>
References: <11cj4a0$23796$1@dont-email.me>
	<JzOdnc2k5ZGeHmD3nZ2dnZfqn_qdnZ2d@giganews.com>
	<11dl9ou$1p00u$1@kst.eternal-september.org>
	<11dm94c$21u9i$1@dont-email.me> <11dmbq9$s03n$7@dont-email.me>
	<11dmhg2$24tb6$1@dont-email.me> <11dmib8$s03n$9@dont-email.me>
	<11dmqbl$289i4$1@dont-email.me> <11dmu0s$s03n$10@dont-email.me>
	<11dmuv3$2a3c0$1@dont-email.me>
	<11dnr4c$2lhv9$1@kst.eternal-september.org>
	<11doth7$2vhee$1@dont-email.me> <11dqpqg$3masv$2@dont-email.me>
	<11drvdj$12fg$1@dont-email.me> <11dt66g$fjb5$2@dont-email.me>
	<11dui6a$scjp$1@dont-email.me>
	<SpOcnXL7lP_FgJ72nZ2dnZfqn_idnZ2d@giganews.com>
	<RdadnUbexs0JvZ72nZ2dnZfqnPednZ2d@giganews.com>
	<11e136t$f9ab$1@dont-email.me> <11e331r$2gekc$1@dont-email.me>
	<11e3bhk$2a7k9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Wed, 25 Nov 2026 00:50:20 +0000 (UTC)
Injection-Info: kst.eternal-september.org;
	logging-data="3502268"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/Ebd1Aln3SiZO3dMvtfPEN"; posting-host="aa24ed08a8b86014a59d35b9bb501a32"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:YOtZrTaLl0jqY9k+87wV4q7lXt0= sha256:NeFoU1uPLx2gVlwnS0JReQJSGzxKApaPksTEjEMLXOs=
	sha1:NcKocNZjMVDFWsG1rxbYqW+Ax/o= sha256:71yndDiFgIjNQEhR4B1qr7HrD4rTkFl0xJF0kT1Sffg=