return;
if (ferror (ptr))
- error (EXIT_FAILURE, 0, _("I/O error"));
+ error (EXIT_FAILURE, 0, _("input/output error"));
if (fclose (ptr) != 0)
error (EXIT_FAILURE, get_errno (), _("cannot close file"));
}
\f
+FILE *
+xfdopen (int fd, char const *mode)
+{
+ FILE *res = fdopen (fd, mode);
+ if (! res)
+ error (EXIT_FAILURE, get_errno (),
+ // On a separate line to please the "unmarked_diagnostics"
+ // syntax-check.
+ "fdopen");
+ return res;
+}
+
/*------------------------------------------------------------------.
| Compute ALL_BUT_EXT, ALL_BUT_TAB_EXT and output files extensions. |
`------------------------------------------------------------------*/
static void
compute_exts_from_gf (const char *ext)
{
- if (strcmp (ext, ".y") == 0)
+ if (STREQ (ext, ".y"))
{
src_extension = xstrdup (language->src_extension);
header_extension = xstrdup (language->header_extension);
*base = last_component (file_name);
/* Look for the extension, i.e., look for the last dot. */
- *ext = mbsrchr (*base, '.');
+ *ext = strrchr (*base, '.');
*tab = NULL;
/* If there is an extension, check if there is a `.tab' part right
if (*ext)
{
size_t baselen = *ext - *base;
- size_t dottablen = 4;
+ size_t dottablen = sizeof (TAB_EXT) - 1;
if (dottablen < baselen
- && (strncmp (*ext - dottablen, ".tab", dottablen) == 0
- || strncmp (*ext - dottablen, "_tab", dottablen) == 0))
+ && STRPREFIX_LIT (TAB_EXT, *ext - dottablen))
*tab = *ext - dottablen;
}
}
output_file_name_check (char **file_name)
{
bool conflict = false;
- if (0 == strcmp (*file_name, grammar_file))
+ if (STREQ (*file_name, grammar_file))
{
- complain (_("refusing to overwrite the input file %s"),
+ complain (NULL, complaint, _("refusing to overwrite the input file %s"),
quote (*file_name));
conflict = true;
}
{
int i;
for (i = 0; i < file_names_count; i++)
- if (0 == strcmp (file_names[i], *file_name))
+ if (STREQ (file_names[i], *file_name))
{
- warn (_("conflicting outputs to file %s"),
- quote (*file_name));
+ complain (NULL, Wother, _("conflicting outputs to file %s"),
+ quote (*file_name));
conflict = true;
}
}