From 105ef282736090c034599ecbe5abca56ea6d05a1 Mon Sep 17 00:00:00 2001 From: Victor Chiletto Date: Wed, 22 May 2024 14:07:00 -0300 Subject: [PATCH] vkd3d-shader/preproc: Treat CR as whitespace. --- libs/vkd3d-shader/preproc.l | 2 +- tests/hlsl_d3d12.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l index d360f6ca..be50d3b9 100644 --- a/libs/vkd3d-shader/preproc.l +++ b/libs/vkd3d-shader/preproc.l @@ -65,7 +65,7 @@ static void update_location(struct preproc_ctx *ctx); %s LINE NEWLINE \r?\n -WS [ \t] +WS [ \t\r] IDENTIFIER [A-Za-z_][A-Za-z0-9_]* INT_SUFFIX [uUlL]{0,2} diff --git a/tests/hlsl_d3d12.c b/tests/hlsl_d3d12.c index 8d5d8d90..215d624a 100644 --- a/tests/hlsl_d3d12.c +++ b/tests/hlsl_d3d12.c @@ -379,6 +379,18 @@ static void test_preprocess(void) "pass", "fail", }, + + /* CRs are treated as whitespace. */ + { + "#define\rKEY(a,\rb)\ra##b\r\n" + "KEY(pa,\rss)\r\n" + "#ifndef\rKEY\r\n" + "fail\r\n" + "#endif\r\n", + + "pass", + "fail", + } }; for (i = 0; i < ARRAY_SIZE(tests); ++i)