Path: csiph.com!xmission!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Philipp Klaus Krause Newsgroups: comp.compilers Subject: Re: What happens at the end of the file for lex? Date: Thu, 4 Jun 2020 19:16:09 +0200 Organization: solani.org Lines: 11 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <20-06-002@comp.compilers> References: <20-06-001@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="81737"; mail-complaints-to="abuse@iecc.com" Keywords: flex Posted-Date: 04 Jun 2020 20:45:51 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Content-Language: en-US Xref: csiph.com comp.compilers:2523 Further investigation shows that this was an intentional, but undocumented change in flex in 2015 (flex 2.5.4 input() returns EOF at the end of the file, flex 2.6.4 input() returns 0). However I still have no idea why this change was made. I guess the only portable way to handle the end of the file is to set a flag in yywrap() and check it each time input() was called. Philipp [Returning EOF was a bug. The lex input() always returned 0 at end of file. -John]