From 92877f7a430e678dec7c5c9c1c1fe81edd417568 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Thu, 14 Jan 2021 14:47:48 -0600 Subject: [PATCH] vkd3d-shader: Implement __FILE__. Signed-off-by: Zebediah Figura Signed-off-by: Matteo Bruni Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- libs/vkd3d-shader/preproc.l | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l index c5c49251..80ac7d03 100644 --- a/libs/vkd3d-shader/preproc.l +++ b/libs/vkd3d-shader/preproc.l @@ -472,6 +472,29 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner) continue; } + if (!strcmp(text, "__FILE__")) + { + const struct preproc_file *file = preproc_get_top_file(ctx); + + /* Not the current file name, but rather the file name + * before invoking any macros. */ + + if (ctx->current_directive) + { + char *string; + + if (!(string = vkd3d_malloc(strlen(file->filename) + 3))) + return 0; + sprintf(string, "\"%s\"", file->filename); + lval->string = string; + return T_STRING; + } + + if (preproc_is_writing(ctx)) + vkd3d_string_buffer_printf(&ctx->buffer, "\"%s\" ", file->filename); + continue; + } + if (!strcmp(text, "__LINE__")) { const struct preproc_file *file = preproc_get_top_file(ctx);