+ len = strlen (filename);
+
+ if (filename[len-- - 1] == '.')
+ return (0);
+
+ while ((len > 0) && (filename[len - 1] != '.'))
+ if (filename[len - 1] == '/')
+ return (0);
+ else
+ len--;
+
+ return (len - 1);
+}
+
+/* Computes extensions from the grammar file extension. */
+static void
+compute_exts_from_gf(const char *ext)
+{
+ src_extension = tr(ext, 'y', 'c');
+ src_extension = tr(src_extension, 'Y', 'C');
+ header_extension = tr(ext, 'y', 'h');
+ header_extension = tr(header_extension, 'Y', 'H');
+}
+
+/* Computes extensions from the given c source file extension. */
+static void
+compute_exts_from_src(const char *ext)
+{
+ src_extension = xstrdup(ext);
+ header_extension = tr(ext, 'c', 'h');
+ header_extension = tr(header_extension, 'C', 'H');
+}
+
+/* FIXME: Should use xstrndup. */
+
+static void
+compute_base_names (void)
+{
+ size_t base_length;
+ size_t short_base_length;
+ size_t ext_index;
+
+ /* Set default extensions */
+ src_extension = ".c";
+ header_extension = ".h";
+
+ /* If --output=foo.c was specified (SPEC_OUTFILE == foo.c),
+ BASE_NAME and SHORT_BASE_NAME are `foo'.
+
+ If --output=foo.tab.c was specified, BASE_NAME is `foo.tab' and
+ SHORT_BASE_NAME is `foo'.
+
+ The precise -o name will be used for FTABLE. For other output
+ files, remove the ".c" or ".tab.c" suffix. */