Skip to content
Snippets Groups Projects
Commit 250a24bd authored by Elizabeth Figura's avatar Elizabeth Figura Committed by Alexandre Julliard
Browse files

vkd3d-shader/preproc: Strip whitespace when stringifying.

parent 6fc3ae2b
No related branches found
No related tags found
1 merge request!291vkd3d-shader/preproc: Various fixes.
......@@ -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];
......
......@@ -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)",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment