From cf01d1a75f87ac045c8d710c7d6e353bc6600c3a Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 25 Jun 2008 14:41:03 -0700 Subject: [PATCH] V0.8: Remork previous patch to use the correct method --- ivlpp/lexor.lex | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 1d5410891..39d04d47c 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -93,7 +93,7 @@ static void ifdef_enter(void) cur = (struct ifdef_stack_t*) calloc(1, sizeof(struct ifdef_stack_t)); - cur->path = strdup(istack->path); + if (istack->path) cur->path = strdup(istack->path); cur->lineno = istack->lineno; cur->next = ifdef_stack; ifdef_stack = cur; @@ -108,7 +108,10 @@ static void ifdef_leave(void) cur = ifdef_stack; ifdef_stack = cur->next; - if (strcmp(istack->path,cur->path) != 0) { + /* If either path is from a non-file context e.g.(macro expansion) + * we assume that the non-file part is from this file. */ + if (istack->path != NULL && cur->path != NULL && + strcmp(istack->path,cur->path) != 0) { fprintf(stderr, "%s:%u: warning: " "This `endif matches an ifdef in another file.\n", istack->path, istack->lineno); @@ -459,8 +462,6 @@ static void def_match() calloc(1, sizeof(struct include_stack_t)); isp->str = cur->value; isp->next = istack; - isp->path = istack->path; - isp->lineno = istack->lineno; istack->yybs = YY_CURRENT_BUFFER; istack = isp; yy_switch_to_buffer(yy_create_buffer(istack->file, YY_BUF_SIZE));