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

vkd3d-shader/preproc: Stringify text immediately in macro invocations.

parent cbb1d840
No related branches found
No related tags found
1 merge request!291vkd3d-shader/preproc: Various fixes.
......@@ -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. */
{
......
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