+ 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)
+{
+ /* Checks if SRC_EXTENSION is NULL. In the other case, %source_extension
+ was specified in the grammar file. */
+ if (src_extension == NULL)
+ {
+ src_extension = tr (ext, 'y', 'c');
+ src_extension = tr (src_extension, 'Y', 'C');
+ }
+ /* Checks if HEADER_EXTENSION is NULL. In the other case,
+ %header_extension was specified in the grammar file. */
+ if (header_extension == NULL)
+ {
+ 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)
+{
+ /* We use this function when the user specifies `-o' or `--output',
+ so the extenions must be computed unconditionally from the file name
+ given by this option. */
+ src_extension = xstrdup (ext);
+ header_extension = tr (ext, 'c', 'h');
+ header_extension = tr (header_extension, 'C', 'H');
+}
+
+/* FIXME: Should use xstrndup. */