Implement support for relative and absolute skeleton file names.

Discussed starting at
<http://lists.gnu.org/archive/html/bison-patches/2006-12/msg00071.html>.
* doc/bison.texinfo (Decl Summary): Document in %skeleton entry.
(Bison Options): Document in --skeleton entry.
* src/output.c (output_skeleton): Use strncpy rather than strcpy since
full_skeleton can't necessarily hold all of pkgdatadir.
If the specified skeleton file name contains a `/', don't prepend
pkgdatadir.
* src/parse-gram.y (prologue_declaration): If the specified skeleton
file name contains a `/', prepend the grammar file directory.
* tests/Makefile.am (TESTSUITE_AT): Add skeletons.at.
* skeletons.at: New file.
(relative skeleton file names): New test case.
(installed skeleton file names): New test case.
* tests/testsuite.at: Include skeletons.at.

* bootstrap: Update copyright to 2007.
This commit is contained in:
Joel E. Denny
2007-01-18 02:18:17 +00:00
parent 830c9b1847
commit a7867f53b3
9 changed files with 309 additions and 81 deletions

View File

@@ -286,7 +286,30 @@ prologue_declaration:
| "%push-parser" { push_parser = true; pull_parser = false; }
| "%push-pull-parser" { push_parser = true; pull_parser = true; }
| "%require" STRING { version_check (&@2, $2); }
| "%skeleton" STRING { skeleton_arg ($2, 1, &@1); }
| "%skeleton" STRING
{
char const *skeleton_user = $2;
if (strchr (skeleton_user, '/'))
{
size_t dir_length = strlen (current_file);
char *skeleton_build;
while (dir_length && current_file[dir_length - 1] != '/')
--dir_length;
while (dir_length && current_file[dir_length - 1] == '/')
--dir_length;
skeleton_build =
xmalloc (dir_length + 1 + strlen (skeleton_user) + 1);
if (dir_length > 0)
{
strncpy (skeleton_build, current_file, dir_length);
skeleton_build[dir_length++] = '/';
}
strcpy (skeleton_build + dir_length, skeleton_user);
skeleton_user = uniqstr_new (skeleton_build);
free (skeleton_build);
}
skeleton_arg (skeleton_user, 1, &@1);
}
| "%token-table" { token_table_flag = true; }
| "%verbose" { report_flag = report_states; }
| "%yacc" { yacc_flag = true; }