Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games Check for write errors in auxiliary programs used duri...



details:   https://anonhg.NetBSD.org/src/rev/3fed4ef1c1d5
branches:  trunk
changeset: 476225:3fed4ef1c1d5
user:      jsm <jsm%NetBSD.org@localhost>
date:      Fri Sep 10 00:18:20 1999 +0000

description:
Check for write errors in auxiliary programs used during build of games.

diffstat:

 games/boggle/mkdict/mkdict.c    |   8 ++++++--
 games/boggle/mkindex/mkindex.c  |   8 ++++++--
 games/fortune/strfile/strfile.c |   7 +++++--
 games/monop/initdeck.c          |  13 +++++++------
 4 files changed, 24 insertions(+), 12 deletions(-)

diffs (136 lines):

diff -r ccd4782b7c52 -r 3fed4ef1c1d5 games/boggle/mkdict/mkdict.c
--- a/games/boggle/mkdict/mkdict.c      Fri Sep 10 00:16:43 1999 +0000
+++ b/games/boggle/mkdict/mkdict.c      Fri Sep 10 00:18:20 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkdict.c,v 1.3 1997/10/11 02:12:21 lukem Exp $ */
+/*     $NetBSD: mkdict.c,v 1.4 1999/09/10 00:18:20 jsm Exp $   */
 
 /*-
  * Copyright (c) 1993
@@ -46,7 +46,7 @@
 #if 0
 static char sccsid[] = "@(#)mkdict.c   8.1 (Berkeley) 6/11/93";
 #else
-static char rcsid[] = "$NetBSD: mkdict.c,v 1.3 1997/10/11 02:12:21 lukem Exp $";
+static char rcsid[] = "$NetBSD: mkdict.c,v 1.4 1999/09/10 00:18:20 jsm Exp $";
 #endif
 #endif /* not lint */
 
@@ -62,6 +62,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <err.h>
 
 #include "bog.h"
 
@@ -125,5 +126,8 @@
                current = !current;
        }
        warnx("%d words", nwords);
+       fflush(stdout);
+       if (ferror(stdout))
+               err(1, "writing standard output");
        exit(0);
 }
diff -r ccd4782b7c52 -r 3fed4ef1c1d5 games/boggle/mkindex/mkindex.c
--- a/games/boggle/mkindex/mkindex.c    Fri Sep 10 00:16:43 1999 +0000
+++ b/games/boggle/mkindex/mkindex.c    Fri Sep 10 00:18:20 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkindex.c,v 1.4 1998/09/11 13:16:05 hubertf Exp $      */
+/*     $NetBSD: mkindex.c,v 1.5 1999/09/10 00:18:21 jsm Exp $  */
 
 /*-
  * Copyright (c) 1993
@@ -46,10 +46,11 @@
 #if 0
 static char sccsid[] = "@(#)mkindex.c  8.1 (Berkeley) 6/11/93";
 #else
-static char rcsid[] = "$NetBSD: mkindex.c,v 1.4 1998/09/11 13:16:05 hubertf Exp $";
+static char rcsid[] = "$NetBSD: mkindex.c,v 1.5 1999/09/10 00:18:21 jsm Exp $";
 #endif
 #endif /* not lint */
 
+#include <err.h>
 #include <stdio.h>
 
 #include "bog.h"
@@ -75,6 +76,9 @@
                off += clen + 1;
        }
        printf("%c %6ld %6ld\n", prev, start, off - 1);
+       fflush(stdout);
+       if (ferror(stdout))
+               err(1, "writing standard output");
        exit(0);
 }
 
diff -r ccd4782b7c52 -r 3fed4ef1c1d5 games/fortune/strfile/strfile.c
--- a/games/fortune/strfile/strfile.c   Fri Sep 10 00:16:43 1999 +0000
+++ b/games/fortune/strfile/strfile.c   Fri Sep 10 00:18:20 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: strfile.c,v 1.12 1999/09/09 17:30:19 jsm Exp $ */
+/*     $NetBSD: strfile.c,v 1.13 1999/09/10 00:18:21 jsm Exp $ */
 
 /*-
  * Copyright (c) 1989, 1993
@@ -46,7 +46,7 @@
 #if 0
 static char sccsid[] = "@(#)strfile.c  8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: strfile.c,v 1.12 1999/09/09 17:30:19 jsm Exp $");
+__RCSID("$NetBSD: strfile.c,v 1.13 1999/09/10 00:18:21 jsm Exp $");
 #endif
 #endif /* not lint */
 
@@ -256,6 +256,9 @@
                        HTOBE64(*p);
                (void) fwrite((char *) Seekpts, sizeof *Seekpts, (int) Num_pts, outf);
        }
+       fflush(outf);
+       if (ferror(outf))
+               err(1, "fwrite %s", Outfile);
        (void) fclose(outf);
        exit(0);
 }
diff -r ccd4782b7c52 -r 3fed4ef1c1d5 games/monop/initdeck.c
--- a/games/monop/initdeck.c    Fri Sep 10 00:16:43 1999 +0000
+++ b/games/monop/initdeck.c    Fri Sep 10 00:18:20 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: initdeck.c,v 1.10 1999/09/09 17:27:59 jsm Exp $        */
+/*     $NetBSD: initdeck.c,v 1.11 1999/09/10 00:18:21 jsm Exp $        */
 
 /*
  * Copyright (c) 1980, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)initdeck.c 8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: initdeck.c,v 1.10 1999/09/09 17:27:59 jsm Exp $");
+__RCSID("$NetBSD: initdeck.c,v 1.11 1999/09/10 00:18:21 jsm Exp $");
 #endif
 #endif /* not lint */
 
@@ -105,10 +105,8 @@
        if (CC_D.offsets == NULL || CH_D.offsets == NULL)
                errx(1, "out of memory");
        fseek(inf, 0L, SEEK_SET);
-       if ((outf = fopen(outfile, "w")) == NULL) {
-               perror(outfile);
-               exit(0);
-       }
+       if ((outf = fopen(outfile, "w")) == NULL)
+               err(1, "fopen %s", outfile);
 
        /*
         * these fields will be overwritten after the offsets are calculated,
@@ -143,6 +141,9 @@
        fwrite(CC_D.offsets, sizeof (off_t), CC_D.num_cards, outf);
        fwrite(CH_D.offsets, sizeof (off_t), CH_D.num_cards, outf);
 
+       fflush(outf);
+       if (ferror(outf))
+               err(1, "fwrite %s", outfile);
        fclose(outf);
        printf("There were %d com. chest and %d chance cards\n",
            CC_D.num_cards, CH_D.num_cards);



Home | Main Index | Thread Index | Old Index