ivlpp: Fixed handling of absolute paths

The updates to the do_include code destroyed the
handling of absolute paths; all of the code that
handles buffer-switching was erroneously placed
in just the relative-path branch. Thanks go to
Cary R. for pointing out the problem.

Now the common code has been extracted yet again,
and the notorious goto statement has been used
in favor redundancy.

The test vvp_reg.pl produces the same output as
before, so hopefully nothing new is broken.

Signed-off-by: Michael Witten <mfwitten@mit.edu>
This commit is contained in:
Michael Witten 2008-03-04 23:57:23 -05:00 committed by Stephen Williams
parent 8d3febff2b
commit 8b45797ccf
1 changed files with 20 additions and 20 deletions

View File

@ -1385,10 +1385,8 @@ static void do_include()
/* standby is defined by include_filename() */
if (standby->path[0] == '/')
{
standby->file = fopen(standby->path, "r");
if(depend_file && standby->file)
fprintf(depend_file, "%s\n", istack->path);
if ((standby->file = fopen(standby->path, "r")))
goto code_that_switches_buffers;
}
else
{
@ -1419,29 +1417,31 @@ static void do_include()
if ((standby->file = fopen(path, "r")))
{
if(depend_file)
fprintf(depend_file, "%s\n", path);
if (line_direct_flag)
fprintf(yyout, "\n`line %u \"%s\" 1\n", istack->lineno+1, path);
standby->path = strdup(path);
standby->next = istack;
istack->yybs = YY_CURRENT_BUFFER;
istack = standby;
standby = 0;
yy_switch_to_buffer(yy_create_buffer(istack->file, YY_BUF_SIZE));
return;
goto code_that_switches_buffers;
}
}
}
fprintf(stderr, "%s:%u: Include file %s not found\n", istack->path, istack->lineno, standby->path);
exit(1);
code_that_switches_buffers:
if(depend_file)
fprintf(depend_file, "%s\n", standby->path);
if (line_direct_flag)
fprintf(yyout, "\n`line %u \"%s\" 1\n", istack->lineno+1, standby->path);
standby->next = istack;
istack->yybs = YY_CURRENT_BUFFER;
istack = standby;
standby = 0;
yy_switch_to_buffer(yy_create_buffer(istack->file, YY_BUF_SIZE));
}
/* walk the include stack until we find an entry with a valid pathname,