On 2024-05-20 23:49:13 +0200, Alejandro Colomar wrote: > I think I found a bug in POSIX.1-2017 (and probably, previous ones too, > but didn't check). I already reported the issue in 2009 about the example: > However: > <https://pubs.opengroup.org/onlinepubs/009695399/functions/fgets.html>: > The following sections are informative. > EXAMPLES > > Reading Input > > The following example uses fgets() to read each line of input. {LINE_MAX}, which defines the maximum size of the input line, is defined in the <limits.h> header. > > #include <stdio.h> > ... > char line[LINE_MAX]; > ... > while (fgets(line, LINE_MAX, fp) != NULL) { > ... > } > ... See thread "fgets/strtok and LINE_MAX" I started on 2009-09-21 in the Austin Group mailing-list. It is available on gmane: Path: news.gmane.org!not-for-mail From: Vincent Lefevre <vincent-opgr-opTGSl+ZDNkdnm+yROfE0A@xxxxxxxxxxxxxxxx> Newsgroups: gmane.comp.standards.posix.austin.general Subject: fgets/strtok and LINE_MAX Date: Mon, 21 Sep 2009 01:03:13 +0200 Lines: 31 Approved: news@xxxxxxxxx Message-ID: <20090920230313.GV657@xxxxxxxxxxxxxxxxxxx> [...] There's the issue with the missing "+1", but also whether LINE_MAX < INT_MAX. See also https://www.austingroupbugs.net/view.php?id=182 -- Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)