mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
vkd3d-shader/preproc: Strip whitespace when stringifying.
This commit is contained in:
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
@ -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)",
|
||||
|
Loading…
Reference in New Issue
Block a user