return fp;
}
+/* Close FP, whose name is FILE, and report any errors. */
+
static void
-xfclose (FILE *fp)
+xfclose (FILE *fp, char const *file)
{
if (fp == stdin)
{
{
if (fclose (fp) != 0)
{
- error (0, errno, _("error closing file"));
+ error (0, errno, "%s", file);
cleanup ();
exit (SORT_FAILURE);
}
}
}
- xfclose (fp);
+ xfclose (fp, file_name);
free (buf.buf);
if (temp.text)
free (temp.text);
/* If a file is empty, eliminate it from future consideration. */
while (i < nfps && !fillbuf (&buffer[i], fps[i], files[i]))
{
- xfclose (fps[i]);
+ xfclose (fps[i], files[i]);
zaptemp (files[i]);
--nfps;
for (j = i; j < nfps; ++j)
if (ord[i] > ord[0])
--ord[i];
--nfps;
- xfclose (fps[ord[0]]);
+ xfclose (fps[ord[0]], files[ord[0]]);
zaptemp (files[ord[0]]);
free (buffer[ord[0]].buf);
for (i = ord[0]; i < nfps; ++i)
fps[j] = xfopen (files[i * NMERGE + j], "r");
temp = create_temp_file (&tfp);
mergefps (fps, &files[i * NMERGE], NMERGE, tfp, temp);
- xfclose (tfp);
+ xfclose (tfp, temp);
files[t++] = temp;
}
for (j = 0; j < nfiles % NMERGE; ++j)
fps[j] = xfopen (files[i * NMERGE + j], "r");
temp = create_temp_file (&tfp);
mergefps (fps, &files[i * NMERGE], nfiles % NMERGE, tfp, temp);
- xfclose (tfp);
+ xfclose (tfp, temp);
files[t++] = temp;
nfiles = t;
}
while (linebase < line);
if (tfp != ofp)
- xfclose (tfp);
+ xfclose (tfp, temp_output);
}
- xfclose (fp);
+ xfclose (fp, file);
}
free (buf.buf);
cleanup ();
exit (SORT_FAILURE);
}
- xfclose (out_fp);
- xfclose (in_fp);
+ xfclose (out_fp, tmp);
+ xfclose (in_fp, files[i]);
files[i] = tmp;
}
ofp = xfopen (outfile, "w");