#include "complain.h"
/* From basename.c. Almost a lie, as it returns a char *. */
-const char *base_name PARAMS ((char const *name));
+const char *base_name (char const *name);
FILE *finput = NULL;
char *spec_defines_file = NULL; /* for --defines. */
char *parser_file_name = NULL;
-char *infile = NULL;
+struniq_t grammar_file = NULL;
+struniq_t current_file = 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). */
ptr = fopen (name, mode);
if (!ptr)
- error (2, errno, _("cannot open file `%s'"), name);
+ error (EXIT_FAILURE, errno, _("cannot open file `%s'"), name);
return ptr;
}
| Try to close file PTR, and print an error message if fails. |
`-------------------------------------------------------------*/
-int
+void
xfclose (FILE *ptr)
{
- int result;
-
if (ptr == NULL)
- return 0;
+ return;
- result = fclose (ptr);
- if (result == EOF)
- error (2, errno, _("cannot close file"));
+ if (ferror (ptr))
+ error (EXIT_FAILURE, 0, _("I/O error"));
- return result;
+ if (fclose (ptr) != 0)
+ error (EXIT_FAILURE, errno, _("cannot close file"));
}
\f
(strlen (spec_outfile)
- (tab ? strlen (tab) : (ext ? strlen (ext) : 0))));
- if (tab)
- output_infix = xstrndup (tab,
- (strlen (tab) - (ext ? strlen (ext) : 0)));
-
if (ext)
compute_exts_from_src (ext);
}
{
/* Otherwise, the short base name is computed from the input
grammar: `foo/bar.yy' => `bar'. */
- filename_split (infile, &base, &tab, &ext);
+ filename_split (grammar_file, &base, &tab, &ext);
short_base_name =
xstrndup (base,
(strlen (base) - (ext ? strlen (ext) : 0)));
}
- /* In these cases, always append `.tab'. */
- output_infix = xstrdup (EXT_TAB);
-
full_base_name = XMALLOC (char,
strlen (short_base_name)
+ strlen (EXT_TAB) + 1);
stpcpy (stpcpy (full_base_name, short_base_name), EXT_TAB);
/* Computes the extensions from the grammar file name. */
- filename_split (infile, &base, &tab, &ext);
+ filename_split (grammar_file, &base, &tab, &ext);
if (ext && !yacc_flag)
compute_exts_from_gf (ext);
}