From 6d56e356b4e91166a6584f1760e03ffff2d3585d Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 7 Jun 2010 15:13:56 -0700 Subject: [PATCH] Don't crash when using `define value for an `include argument. When pushing the current file path we need to get past any `define expansions that have been pushed onto the stack to find the real file path. This patch is partially based on a patch submitted by Steve Tell. (cherry picked from commit b2d479eaf6d91725b000fc22298ccc9b6cc8ef5e) --- ivlpp/lexor.lex | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index f5c293380..fb2291bfd 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -1483,10 +1483,17 @@ static void do_include() unsigned idx, start = 1; char path[4096]; char *cp; + struct include_stack_t* isp; /* Add the current path to the start of the include_dir list. */ - strcpy(path, istack->path); - cp = strrchr(path, '/'); + isp = istack; + while(isp && (isp->path == NULL)) + isp = isp->next; + + assert(isp); + + strcpy(path, isp->path); + cp = strrchr(path, '/'); /* I may need the relative path for a planned warning even when * we are not in relative mode, so for now keep it around. */ @@ -1508,10 +1515,11 @@ static void do_include() } } - fprintf(stderr, "%s:%u: Include file %s not found\n", istack->path, istack->lineno, standby->path); + emit_pathline(istack); + fprintf(stderr, "Include file %s not found\n", standby->path); exit(1); - code_that_switches_buffers: +code_that_switches_buffers: /* Clear the current files path from the search list. */ free(include_dir[0]);