mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/preproc: Stringify text immediately in macro invocations.
This commit is contained in:
parent
cbb1d84069
commit
6fc3ae2b5c
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
@ -664,6 +664,21 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Stringification is another special case. Unsurprisingly,
|
||||
* we need to stringify if this is an argument. More
|
||||
* surprisingly, we need to stringify even if it's not. */
|
||||
case T_HASHSTRING:
|
||||
{
|
||||
struct vkd3d_string_buffer buffer;
|
||||
|
||||
vkd3d_string_buffer_init(&buffer);
|
||||
preproc_stringify(ctx, &buffer, text);
|
||||
if (current_arg)
|
||||
preproc_text_add(current_arg, buffer.buffer);
|
||||
vkd3d_string_buffer_cleanup(&buffer);
|
||||
break;
|
||||
}
|
||||
|
||||
case T_NEWLINE:
|
||||
if (current_arg)
|
||||
preproc_text_add(current_arg, " ");
|
||||
|
@ -236,6 +236,27 @@ static void test_preprocess(void)
|
||||
|
||||
"#",
|
||||
},
|
||||
{
|
||||
"#define KEY2(x) x\n"
|
||||
"#define KEY(a) KEY2(#a)\n"
|
||||
"KEY(apple)",
|
||||
|
||||
"\"apple\"",
|
||||
},
|
||||
{
|
||||
"#define KEY2(x) #x\n"
|
||||
"#define KEY(a) KEY2(#a)\n"
|
||||
"KEY(apple)",
|
||||
|
||||
"\"\\\"apple\\\"\"",
|
||||
},
|
||||
{
|
||||
"#define KEY2(x) #x\n"
|
||||
"#define KEY(a) KEY2(#x)\n"
|
||||
"KEY(apple)",
|
||||
|
||||
"\"\\\"x\\\"\"",
|
||||
},
|
||||
|
||||
/* #pragma is preserved. */
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user