Deutsch English Français Italiano |
<voc9d7$13pam$2@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: Lawrence D'Oliveiro <ldo@nz.invalid> Newsgroups: comp.lang.c Subject: Re: Buffer contents well-defined after fgets() reaches EOF ? Date: Mon, 10 Feb 2025 07:21:11 -0000 (UTC) Organization: A noiseless patient Spider Lines: 19 Message-ID: <voc9d7$13pam$2@dont-email.me> References: <vo9g74$fu8u$1@dont-email.me> <vo9hlo$g0to$1@dont-email.me> <vo9khf$ggd4$1@dont-email.me> <vobf3h$sefh$2@dont-email.me> <vobjdt$t5ka$1@dont-email.me> <vobro1$u9fa$1@dont-email.me> <vobu9b$12bi8$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Mon, 10 Feb 2025 08:21:11 +0100 (CET) Injection-Info: dont-email.me; posting-host="8d964e1be02ec4fc321f0a3e4e27d15a"; logging-data="1172822"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18dgb9TJxbQ5UGlaVNTUc0f" User-Agent: Pan/0.161 (Chasiv Yar; ) Cancel-Lock: sha1:/tAcw5KZUzScv1QNPNt7IYt7f3Q= Bytes: 1926 On Sun, 9 Feb 2025 20:11:22 -0800, Andrey Tarasevich wrote: > This manpage, for one example, is in full agreement with the standard > > https://www.man7.org/linux/man-pages/man3/fgets.3p.html Notice these two sentences would seem to contradict one another: A null byte shall be written immediately after the last byte read into the array. If the end-of-file condition is encountered before any bytes are read, the contents of the array pointed to by s shall not be changed. > A practical experiment demonstrates that [supposedly] POSIX-obeying > implementations do not write '\0' into the buffer in "immediate > end-of-file" situations: > https://coliru.stacked-crooked.com/a/3e672e6718dd388b My test program does the same. I would say that settles it.