vkd3d-shader/preproc: Strip whitespace when stringifying.

This commit is contained in:
Zebediah Figura 2023-07-29 18:32:04 -05:00 committed by Alexandre Julliard
parent 6fc3ae2b5c
commit 250a24bd3f
Notes: Alexandre Julliard 2023-08-02 21:24:27 +09:00
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/291
2 changed files with 16 additions and 1 deletions

View File

@ -358,7 +358,16 @@ static void preproc_stringify(struct preproc_ctx *ctx, struct vkd3d_string_buffe
vkd3d_string_buffer_printf(buffer, "\"");
if ((expansion = find_arg_expansion(ctx, p)))
{
for (i = 0; i < expansion->text.content_size; ++i)
size_t len = expansion->text.content_size;
size_t start = 0;
while (len && strchr(" \t\r\n", expansion->text.buffer[len - 1]))
--len;
while (start < len && strchr(" \t\r\n", expansion->text.buffer[start]))
++start;
for (i = start; i < len; ++i)
{
char c = expansion->text.buffer[i];

View File

@ -193,6 +193,12 @@ static void test_preprocess(void)
"\"apple\"",
},
{
"#define KEY(a) #a\n"
"KEY( \t\r\n apple \t\r\n )",
"\"apple\"",
},
{
"#define KEY(if) #if\n"
"KEY(apple)",