1. Line ends gotcha

I just discovered something odd/interesting while using eutest: if the .ex file is using CR only as the line-ending then all the tests pass even if they should all fail.

Is it written down anywhere that OE handles LF-, CRLF- but not CR- terminated lines?

-Bruce

new topic     » topic index » view message » categorize

2. Re: Line ends gotcha

The only statements that require a line break are shebang (e.g. #!/usr/bin/eui) and include. Shebang specifically has to have line feed only '\n' to work on *NIX. Beyond that the interpreter treats whitespace as whitespace whether it's a space ' ', tab '\t', carriage return '\r', or line feed '\n'. You could write an entire program without line breaks. My guess is this is a problem with eutest and not the interpreter itself. Can you provide a simple example that reproduces the problem?

Scratch that. I did some preliminary testing and yes it seems the interpreter only processes the first line when CR is the only line break character.

Either of these print "one" and "two" as expected:

puts(1,"one\n")\n 
puts(1,"two\n")\n 
puts(1,"one\n")\r\n 
puts(1,"two\n")\r\n 

But this only prints "one" and then... exits?

puts(1,"one\n")\r 
puts(1,"two\n")\r 

This is very strange because, as I indicated in my original response, these characters shouldn't make a difference. More investigation is required.

-Greg

new topic     » goto parent     » topic index » view message » categorize

3. Re: Line ends gotcha

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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu