[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bison fixes for checking close, I/O errors
From: |
Paul Eggert |
Subject: |
bison fixes for checking close, I/O errors |
Date: |
Tue, 29 Oct 2002 22:22:00 -0800 (PST) |
Bison was inconsistent about whether it checked for failures of close
and fclose, along with I/O error. I installed the following patch.
2002-10-29 Paul Eggert <address@hidden>
* lib/bitset_stats.c (bitset_stats_read, bitset_stats_write):
Check for close failures.
* src/files.h (xfclose): Return void, not int, since it always
returned zero.
* src/files.c (xfclose): Likewise. Report I/O error if ferror
indicates one.
* src/output.c (output_skeleton): Use xfclose rather than fclose
and ferror. xfclose now checks ferror.
Index: lib/bitset_stats.c
===================================================================
RCS file: /cvsroot/bison/bison/lib/bitset_stats.c,v
retrieving revision 1.6
diff -p -u -r1.6 bitset_stats.c
--- lib/bitset_stats.c 16 Oct 2002 06:20:44 -0000 1.6
+++ lib/bitset_stats.c 30 Oct 2002 06:16:24 -0000
@@ -261,7 +261,8 @@ bitset_stats_read (const char *filename)
else
fprintf (stderr, _("Bad stats file size.\n"));
}
- fclose (file);
+ if (fclose (file) != 0)
+ perror (_("Could not read stats file."));
}
bitset_stats_info_data.runs++;
}
@@ -285,7 +286,8 @@ bitset_stats_write (const char *filename
if (fwrite (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
1, file) != 1)
perror (_("Could not write stats file."));
- fclose (file);
+ if (fclose (file) != 0)
+ perror (_("Could not write stats file."));
}
else
perror (_("Could not open stats file for writing."));
Index: src/files.h
===================================================================
RCS file: /cvsroot/bison/bison/src/files.h,v
retrieving revision 1.34
diff -p -u -r1.34 files.h
--- src/files.h 21 Oct 2002 05:30:49 -0000 1.34
+++ src/files.h 30 Oct 2002 06:16:24 -0000
@@ -55,7 +55,7 @@ extern char *infile;
void compute_output_file_names (void);
FILE *xfopen (const char *name, const char *mode);
-int xfclose (FILE *ptr);
+void xfclose (FILE *ptr);
/* Is SUFFIX ending STRING? */
int strsuffix (const char* string, const char* suffix);
cvs server: I know nothing about src/filec.c
Index: src/output.c
===================================================================
RCS file: /cvsroot/bison/bison/src/output.c,v
retrieving revision 1.202
diff -p -u -r1.202 output.c
--- src/output.c 24 Oct 2002 11:40:27 -0000 1.202
+++ src/output.c 30 Oct 2002 06:16:25 -0000
@@ -500,8 +500,9 @@ output_skeleton (void)
full_path[pkgdatadirlen] = '/';
strcpy (full_path + pkgdatadirlen + 1, m4sugar);
in = fopen (full_path, "r");
- if (! in || fclose (in) != 0)
+ if (! in)
error (EXIT_FAILURE, errno, "%s", full_path);
+ xfclose (in);
strcpy (full_path + pkgdatadirlen + 1, skeleton);
/* Create an m4 subprocess connected to us via two pipes. */
@@ -539,8 +540,6 @@ output_skeleton (void)
fputs ("m4_wrap([m4_divert_pop(0)])\n", out);
fputs ("m4_divert_push(0)dnl\n", out);
- if (ferror (out))
- error (EXIT_FAILURE, 0, "pipe output error");
xfclose (out);
/* Read and process m4's output. */
@@ -549,8 +548,6 @@ output_skeleton (void)
if (! in)
error (EXIT_FAILURE, errno, "fdopen");
scan_skel (in);
- if (ferror (in))
- error (EXIT_FAILURE, 0, "pipe input error");
xfclose (in);
reap_subpipe (pid, m4);
timevar_pop (TV_M4);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bison fixes for checking close, I/O errors,
Paul Eggert <=