OSDN Git Service

glsl/glcpp: Treat CR+LF pair as a single newline
authorCarl Worth <cworth@cworth.org>
Tue, 1 Jul 2014 23:31:07 +0000 (16:31 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 7 Aug 2014 23:08:29 +0000 (16:08 -0700)
commit04e40fd337a244ee77ef9553985e9398ff0344af
treeb2600fffceb1f27dc3a5ab55fbe7f1b019cb11b7
parentf4ddd026c6f155a1050b142f2e88225305ecdd90
glsl/glcpp: Treat CR+LF pair as a single newline

The GLSL specification says that either carriage-return, line-feed, or both
together can be used to terminate lines. Further, it says that when used
together, the pair of terminators shall be interpreted as a single line.

This final requirement has not been respected by glcpp up until now, (it has
been emitting two newlines for every CR+LF pair).

Here, we fix the lexer by using a regular expression for NEWLINE that eats
up both "\r\n" (or even "\n\r") if possible before also considering a single
'\n' or a single '\r' as a line terminator.

Before this commit, the test results are as follows:

\r: 135/143 tests pass
\r\n:   4/143 tests pass
\n\r:   4/143 tests pass

After this commit, the test results are as follows:

\r: 135/143 tests pass
\r\n: 140/143 tests pass
\n\r: 139/143 tests pass

So, obviously, a dramatic improvement.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/glcpp/glcpp-lex.l
src/glsl/glcpp/tests/.gitignore [new file with mode: 0644]