-#ifdef MSDOS
- strlwr (spec_file_prefix);
-#endif /* MSDOS */
- short_base_name = xstrdup (spec_file_prefix);
- base_name = XMALLOC (char,
- strlen (short_base_name) + strlen (EXT_TAB) + 1);
- stpcpy (stpcpy (base_name, short_base_name), EXT_TAB);
-
- return;
- }
-
- /* If neither -o nor --file-prefix were specified, and the input
- file is foo.y, BASE_NAME is `foo.tab', and SHORT_BASE_NAME is
- `foo'.
-
- If --yacc is used, do as if the input file was `y.y'. */
- {
- const char *name_base = yacc_flag ? "y.y" : infile;
-
- /* BASE_LENGTH gets length of BASE_NAME, sans ".y" suffix if any. */
-
- base_length = strlen (name_base);
-
- ext_index = get_extension_index (name_base);
- /* if the initial segment of extension contains a 'y' or a 'Y', I assume
- that it is a yacc or bison grammar file */
- if (ext_index)
- ext_index = (strspn(name_base + ext_index + 1, "yY")) ? ext_index : 0;
- if (ext_index)
- {
- base_length -= strlen (name_base + ext_index);
- compute_exts_from_gf(name_base + ext_index);
- }
-
- short_base_length = base_length;
- short_base_name = strndup (name_base, short_base_length);
-
- base_name = XMALLOC (char,
- strlen (short_base_name) + strlen (EXT_TAB) + 1);
- stpcpy (stpcpy (base_name, short_base_name), EXT_TAB);
+ if (spec_file_prefix)
+ {
+ /* If --file-prefix=foo was specified, SHORT_BASE_NAME =
+ `foo'. */
+ short_base_name = xstrdup (spec_file_prefix);
+ }
+ else if (yacc_flag)
+ {
+ /* If --yacc, then the output is `y.tab.c'. */
+ short_base_name = xstrdup ("y");
+ }
+ else
+ {
+ /* Otherwise, the short base name is computed from the input
+ grammar: `foo/bar.yy' => `bar'. */
+ filename_split (grammar_file, &base, &tab, &ext);
+ short_base_name =
+ xstrndup (base,
+ (strlen (base) - (ext ? strlen (ext) : 0)));
+ }