- size_t string_len = strlen (string);
- size_t suffix_len = strlen (suffix);
- if (suffix_len <= string_len)
- return !strcmp (string + string_len - suffix_len, suffix);
- else
- return 0;
-}
-
-
+ /** File name. */
+ char *name;
+ /** Whether is a generated source file (e.g., *.c, *.java...), as
+ opposed to the report file (e.g., *.output). When late errors
+ are detected, generated source files are removed. */
+ bool is_source;
+} generated_file;
+static generated_file *generated_files = NULL;
+static int generated_files_size = 0;
+
+uniqstr grammar_file = NULL;
+uniqstr current_file = NULL;
+
+/* If --output=dir/foo.c was specified,
+ DIR_PREFIX is 'dir/' and ALL_BUT_EXT and ALL_BUT_TAB_EXT are 'dir/foo'.
+
+ If --output=dir/foo.tab.c was specified, DIR_PREFIX is 'dir/',
+ ALL_BUT_EXT is 'dir/foo.tab', and ALL_BUT_TAB_EXT is 'dir/foo'.
+
+ If --output was not specified but --file-prefix=dir/foo was specified,
+ ALL_BUT_EXT = 'foo.tab' and ALL_BUT_TAB_EXT = 'foo'.
+
+ If neither --output nor --file was specified but the input grammar
+ is name dir/foo.y, ALL_BUT_EXT and ALL_BUT_TAB_EXT are 'foo'.
+
+ If neither --output nor --file was specified, DIR_PREFIX is the
+ empty string (meaning the current directory); otherwise it is
+ 'dir/'. */
+
+char *all_but_ext;
+static char *all_but_tab_ext;
+char *dir_prefix;
+
+/* C source file extension (the parser source). */
+static char *src_extension = NULL;
+/* Header file extension (if option '`-d'' is specified). */
+static char *header_extension = NULL;
+\f