Skip to content

Commit

Permalink
Check the file output error more frequently
Browse files Browse the repository at this point in the history
exit(1) is removed as suggested by @b4n.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Feb 25, 2015
1 parent dd6e34c commit 9f0ea3b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ extern void writePseudoTag (
: fprintf (TagFile.fp, "%s%s\t%s\t/%s/\n",
PSEUDO_TAG_PREFIX, tagName, fileName, pattern);

abort_if_ferror (TagFile.fp);

++TagFile.numTags.added;
rememberMaxLengths (strlen (tagName), (size_t) length);
}
Expand Down Expand Up @@ -536,10 +538,13 @@ extern void closeTagFile (const boolean resize)

if (Option.etags)
writeEtagsIncludes (TagFile.fp);
abort_if_ferror (TagFile.fp);
desiredSize = ftell (TagFile.fp);
fseek (TagFile.fp, 0L, SEEK_END);
size = ftell (TagFile.fp);
fclose (TagFile.fp);
if (fclose (TagFile.fp) != 0)
error (FATAL | PERROR, "cannot close tag file");

if (resize && desiredSize < size)
{
DebugStatement (
Expand All @@ -563,6 +568,8 @@ extern void endEtagsFile (const char *const name)
const char *line;

fprintf (TagFile.fp, "\f\n%s,%ld\n", name, (long) TagFile.etags.byteCount);
abort_if_ferror (TagFile.fp);

if (TagFile.etags.fp != NULL)
{
rewind (TagFile.etags.fp);
Expand Down

0 comments on commit 9f0ea3b

Please sign in to comment.