| Deutsch English Français Italiano |
|
<vodsob$1d9le$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Mark Bourne <nntp.mbourne@spamgourmet.com> Newsgroups: comp.lang.c Subject: Re: Buffer contents well-defined after fgets() reaches EOF ? Date: Mon, 10 Feb 2025 21:57:29 +0000 Organization: A noiseless patient Spider Lines: 29 Message-ID: <vodsob$1d9le$1@dont-email.me> References: <vo9g74$fu8u$1@dont-email.me> <vo9hlo$g0to$1@dont-email.me> <vo9ki6$gib5$1@dont-email.me> <20250209125046.00001189@yahoo.com> <voaokv$oad5$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 10 Feb 2025 22:57:31 +0100 (CET) Injection-Info: dont-email.me; posting-host="189876ba285a5019f1688dfef7a2745b"; logging-data="1484462"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+t4ao4JX48IEdQfq3ehSA0" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 SeaMonkey/2.53.20 Cancel-Lock: sha1:ZTE00VtFNuVGmsvfiu3fEPjQowc= In-Reply-To: <voaokv$oad5$1@dont-email.me> Bytes: 2626 Janis Papanagnou wrote: > On 09.02.2025 11:50, Michael S wrote: >> What do you consider "last line" of the file in which last character is >> not LF? > > I consider missing newlines at the end of any text line as a bug. > (And I'm not inclined to use a weaker word than "bug".) YMMV. I think I once saw somewhere that utilities originating on Unix typically consider \n to be a line terminator, so include it at the end of every line including the last, whereas those originating on DOS/Windows typically consider \n to be a line separator, so don't include it at the end of the last line. So Unix-originated utilities might not behave as expected if the file doesn't end with \n, whereas Windows-originated utilities might treat the file as having an extra blank line at the end of the file if it does end with \n. Utilities ported from one system to the other sometimes continue following the convention of their origin, rather than the system they're running on. I'm not sure where I originally saw that, but for what it's worth the following Stack Overflow makes a similar claim: <https://stackoverflow.com/a/729795>. Most of the answer discusses POSIX, with a "line" defined as ending with a terminating newline, hence every line including the last ends with a newline, while a final footnote notes that doesn't necessarily apply to non-POSIX systems, particularly Windows. -- Mark.