From 2cc41a46392ac62593675fef6a31c54ed9062186 Mon Sep 17 00:00:00 2001 From: Cary R Date: Sat, 13 Feb 2021 16:43:05 -0800 Subject: [PATCH] Allow a macro generated string to work with an include --- ivlpp/lexor.lex | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index d862f4236..70cfd7b2a 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -50,7 +50,7 @@ static void do_expand(int use_args); static const char* do_magic(const char*name); static const char* macro_name(void); -static void include_filename(void); +static void include_filename(int macro_str); static void do_include(void); static int load_next_input(void); @@ -290,7 +290,8 @@ keywords (include|define|undef|ifdef|ifndef|else|elsif|endif) if (macro_needs_args(yytext+1)) yy_push_state(MA_START); else do_expand(0); } -\"[^\"]*\" { include_filename(); } +\"[^\"]*\" { include_filename(0); } /* A normal (") string */ +`\"[^\"]*`\" { include_filename(1); } /* A macro (`") string */ [ \t\b\f] { ; } @@ -1706,7 +1707,7 @@ static void output_init(void) } } -static void include_filename(void) +static void include_filename(int macro_str) { if(standby) { emit_pathline(istack); @@ -1717,8 +1718,8 @@ static void include_filename(void) } standby = malloc(sizeof(struct include_stack_t)); - standby->path = strdup(yytext+1); - standby->path[strlen(standby->path)-1] = 0; + standby->path = strdup(yytext+1+macro_str); + standby->path[strlen(standby->path)-1-macro_str] = 0; standby->lineno = 0; standby->comment = NULL; }