Re: Line ends gotcha
- Posted by ghaberek (admin) Mar 02, 2023
- 756 views
Yeah good catch! It's (sort of?) a bug in EGets(), which is the back end function for builtin gets() function. I created ticket #1021 to address this.
Specifically this loop in be_runtime.c which only checks for '\n' or EOF so a file terminated with only '\r' will read everything until EOF and you end up with something like "line1\rline2\rline3\n".
The scanner could overcome this in read_line() but it's currently not equipped to split lines and assumes gets() returns a single line.
I'm surprised it took this long to find but CR-only line endings are only common on MacOS and we've not done a lot of testing there. (Yet another thing I'm half-working on as best I can.)
-Greg