X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/cae601224e356773fcd101dce0677f558e7c4357..ed86e78c906a287e49d89b7417e43479000de092:/src/files.c diff --git a/src/files.c b/src/files.c index 5240c410..22f29c1e 100644 --- a/src/files.c +++ b/src/files.c @@ -1,5 +1,6 @@ /* Open and close files for bison, - Copyright 1984, 1986, 1989, 1992, 2000, 2001 Free Software Foundation, Inc. + Copyright 1984, 1986, 1989, 1992, 2000, 2001, 2002 + Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -54,15 +55,18 @@ char *infile = NULL; char *attrsfile = NULL; static char *full_base_name = NULL; + +/* Prefix used to generate output file names. */ char *short_base_name = NULL; +/* Infix used to generate output file names (i.e., `.tab', or `_tab', + or `'). */ +char *output_infix = NULL; + /* C source file extension (the parser source). */ const char *src_extension = NULL; /* Header file extension (if option ``-d'' is specified). */ const char *header_extension = NULL; - -/* Should we insert '.tab' in yacc-compatible parsers? */ -int tab_extension = 0; /*--------------------------. @@ -188,6 +192,7 @@ skeleton_find (const char *envvar, const char *skeleton_name) const char *res = getenv (envvar); #if defined (MSDOS) || defined (_WIN32) + const char *cp = getenv ("INIT"); if (!res) { /* Skeleton file name without path */ @@ -200,7 +205,6 @@ skeleton_find (const char *envvar, const char *skeleton_name) ++skel_name; /* File doesn't exist in current directory; try in INIT directory. */ - const char *cp = getenv ("INIT"); if (cp) { res = XMALLOC (char, strlen (cp) + strlen (skel_name) + 2); @@ -347,14 +351,16 @@ compute_base_names (void) full_base_name = xstrndup (spec_outfile, (strlen (spec_outfile) - (ext ? strlen (ext) : 0))); + /* The short base name goes up to TAB, excluding it. */ short_base_name = xstrndup (spec_outfile, (strlen (spec_outfile) - (tab ? strlen (tab) : (ext ? strlen (ext) : 0)))); - /* Do we have a tab part? */ - tab_extension = !!tab; + if (tab) + output_infix = xstrndup (tab, + (strlen (tab) - (ext ? strlen (ext) : 0))); if (ext) compute_exts_from_src (ext); @@ -388,7 +394,8 @@ compute_base_names (void) } /* In these cases, always append `.tab'. */ - tab_extension = 1; + output_infix = xstrdup (EXT_TAB); + full_base_name = XMALLOC (char, strlen (short_base_name) + strlen (EXT_TAB) + 1); @@ -396,7 +403,7 @@ compute_base_names (void) /* Computes the extensions from the grammar file name. */ filename_split (infile, &base, &tab, &ext); - if (ext) + if (ext && !yacc_flag) compute_exts_from_gf (ext); } } @@ -410,15 +417,15 @@ compute_output_file_names (void) { compute_base_names (); - parser_file_name = - spec_outfile ? spec_outfile : stringappend (full_base_name, src_extension); - /* If not yet done. */ if (!src_extension) src_extension = ".c"; if (!header_extension) header_extension = ".h"; - + + parser_file_name = + spec_outfile ? spec_outfile : stringappend (full_base_name, src_extension); + /* It the defines filename if not given, we create it. */ if (!spec_defines_file) spec_defines_file = stringappend (full_base_name, header_extension);