Re: [Flex-devel] api change for [yy]input()
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Nate R. <na...@go...> - 2017-06-26 16:54:44
|
On Sun, Jun 25, 2017 at 12:34 PM Will Estes <wes...@gm...> wrote: > On Monday, 22 May 2017, 11:10 pm +0000, Nate Rosenblum <na...@go...> > wrote: > > > I recently discovered that the behavior of input() has changed from > > returning EOF at end of file to returning 0. Searching around I came > across > > a closed github issue (https://github.com/westes/flex/issues/212), but > this > > really feels like something for the mailing list. So: > > > > Why change this return value, potentially breaking callers? Is it simply > > because Apple chose to do so ( > > > https://opensource.apple.com/source/flex/flex-26/patches/scanEOF.diff.auto.html > )? > > If that's the case, perhaps the man page should be updated to match. > > There was a reason why, but it escapes me. It's on my list and I keep > thinking I will get to it and I keep not getting to it. I imagine this > involves looking at the code and git blame in various ways. > > It was not solely because Apple. There was some particular thing that made > me think it was a good idea. > > If you can point me to an example in the wild where this is a problem, > that helps a bunch. > > Failing that, your point about updating the documentation is a good one -- > and pull requests against github are easy for me to process. > Thanks for getting back to me. For my use case, the change is not a significant problem (just unexpected); I already had to special-case the return value on OSX builds. It seems like this change could, however, make it quite hard to use yyinput() when scanning syntaxes that allow embedded null characters. Returning -1 on end of file allows one to differentiate end of file conditions from valid 0 bytes. --nate |