Allow a macro generated string to work with an include

This commit is contained in:
Cary R 2021-02-13 16:43:05 -08:00
parent 7bb8a4463f
commit 2cc41a4639
1 changed files with 6 additions and 5 deletions

View File

@ -50,7 +50,7 @@ static void do_expand(int use_args);
static const char* do_magic(const char*name); static const char* do_magic(const char*name);
static const char* macro_name(void); static const char* macro_name(void);
static void include_filename(void); static void include_filename(int macro_str);
static void do_include(void); static void do_include(void);
static int load_next_input(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); if (macro_needs_args(yytext+1)) yy_push_state(MA_START); else do_expand(0);
} }
<PPINCLUDE>\"[^\"]*\" { include_filename(); } <PPINCLUDE>\"[^\"]*\" { include_filename(0); } /* A normal (") string */
<PPINCLUDE>`\"[^\"]*`\" { include_filename(1); } /* A macro (`") string */
<PPINCLUDE>[ \t\b\f] { ; } <PPINCLUDE>[ \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) { if(standby) {
emit_pathline(istack); emit_pathline(istack);
@ -1717,8 +1718,8 @@ static void include_filename(void)
} }
standby = malloc(sizeof(struct include_stack_t)); standby = malloc(sizeof(struct include_stack_t));
standby->path = strdup(yytext+1); standby->path = strdup(yytext+1+macro_str);
standby->path[strlen(standby->path)-1] = 0; standby->path[strlen(standby->path)-1-macro_str] = 0;
standby->lineno = 0; standby->lineno = 0;
standby->comment = NULL; standby->comment = NULL;
} }