summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordrochner <drochner@NetBSD.org>2008-08-08 16:10:47 +0000
committerdrochner <drochner@NetBSD.org>2008-08-08 16:10:47 +0000
commit8218dc5ff267a1066f10d1dc24a259770c7e1257 (patch)
tree0cb722dff6cd475d71113cb6ee9ef928f9ee3b17
parent4ca7662068dbec217082e73d01ea38705f82833b (diff)
downloadbsdgames-darwin-8218dc5ff267a1066f10d1dc24a259770c7e1257.tar.gz
bsdgames-darwin-8218dc5ff267a1066f10d1dc24a259770c7e1257.tar.zst
bsdgames-darwin-8218dc5ff267a1066f10d1dc24a259770c7e1257.zip
if initscr() fails, exit with a message rather than crash in the
next curses call
-rw-r--r--atc/graphics.c7
-rw-r--r--boggle/boggle/mach.c9
-rw-r--r--canfield/canfield/canfield.c9
-rw-r--r--cribbage/crib.c7
-rw-r--r--gomoku/bdisp.c10
-rw-r--r--hangman/main.c7
-rw-r--r--hunt/hunt/hunt.c7
-rw-r--r--mille/mille.c7
-rw-r--r--phantasia/main.c7
-rw-r--r--rain/rain.c7
-rw-r--r--robots/main.c7
-rw-r--r--rogue/init.c9
-rw-r--r--snake/snake/snake.c7
-rw-r--r--worm/worm.c7
-rw-r--r--worms/worms.c7
15 files changed, 70 insertions, 44 deletions
diff --git a/atc/graphics.c b/atc/graphics.c
index 9d9ba6fb..c29b2674 100644
--- a/atc/graphics.c
+++ b/atc/graphics.c
@@ -1,4 +1,4 @@
-/* $NetBSD: graphics.c,v 1.14 2007/12/15 19:44:38 perry Exp $ */
+/* $NetBSD: graphics.c,v 1.15 2008/08/08 16:10:47 drochner Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -46,7 +46,7 @@
#if 0
static char sccsid[] = "@(#)graphics.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: graphics.c,v 1.14 2007/12/15 19:44:38 perry Exp $");
+__RCSID("$NetBSD: graphics.c,v 1.15 2008/08/08 16:10:47 drochner Exp $");
#endif
#endif /* not lint */
@@ -115,7 +115,8 @@ init_gr(void)
{
static char buffer[BUFSIZ];
- (void)initscr();
+ if (!initscr())
+ errx(0, "couldn't initialize screen");
setbuf(stdout, buffer);
input = newwin(INPUT_LINES, COLS - PLANE_COLS, LINES - INPUT_LINES, 0);
credit = newwin(INPUT_LINES, PLANE_COLS, LINES - INPUT_LINES,
diff --git a/boggle/boggle/mach.c b/boggle/boggle/mach.c
index e8a481c2..aaaacbbb 100644
--- a/boggle/boggle/mach.c
+++ b/boggle/boggle/mach.c
@@ -1,4 +1,4 @@
-/* $NetBSD: mach.c,v 1.17 2007/12/15 19:44:39 perry Exp $ */
+/* $NetBSD: mach.c,v 1.18 2008/08/08 16:10:47 drochner Exp $ */
/*-
* Copyright (c) 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)mach.c 8.1 (Berkeley) 6/11/93";
#else
-__RCSID("$NetBSD: mach.c,v 1.17 2007/12/15 19:44:39 perry Exp $");
+__RCSID("$NetBSD: mach.c,v 1.18 2008/08/08 16:10:47 drochner Exp $");
#endif
#endif /* not lint */
@@ -558,7 +558,10 @@ prompt(const char *mesg)
static int
tty_setup(void)
{
- initscr();
+ if (!initscr()) {
+ fprintf(stderr, "couldn't initialize screen\n");
+ exit (0);
+ }
raw();
noecho();
diff --git a/canfield/canfield/canfield.c b/canfield/canfield/canfield.c
index 54111c02..be6f35b5 100644
--- a/canfield/canfield/canfield.c
+++ b/canfield/canfield/canfield.c
@@ -1,4 +1,4 @@
-/* $NetBSD: canfield.c,v 1.24 2008/07/20 01:03:21 lukem Exp $ */
+/* $NetBSD: canfield.c,v 1.25 2008/08/08 16:10:47 drochner Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\
#if 0
static char sccsid[] = "@(#)canfield.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: canfield.c,v 1.24 2008/07/20 01:03:21 lukem Exp $");
+__RCSID("$NetBSD: canfield.c,v 1.25 2008/08/08 16:10:47 drochner Exp $");
#endif
#endif /* not lint */
@@ -1774,7 +1774,10 @@ main(void)
signal(SIGINT, askquit);
signal(SIGHUP, cleanup);
signal(SIGTERM, cleanup);
- initscr();
+ if (!initscr()) {
+ fprintf(stderr, "couldn't initialize screen\n");
+ exit (0);
+ }
raw();
noecho();
initall();
diff --git a/cribbage/crib.c b/cribbage/crib.c
index 1699d768..ee8e2d6f 100644
--- a/cribbage/crib.c
+++ b/cribbage/crib.c
@@ -1,4 +1,4 @@
-/* $NetBSD: crib.c,v 1.21 2008/07/20 01:03:21 lukem Exp $ */
+/* $NetBSD: crib.c,v 1.22 2008/08/08 16:10:47 drochner Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\
#if 0
static char sccsid[] = "@(#)crib.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: crib.c,v 1.21 2008/07/20 01:03:21 lukem Exp $");
+__RCSID("$NetBSD: crib.c,v 1.22 2008/08/08 16:10:47 drochner Exp $");
#endif
#endif /* not lint */
@@ -102,7 +102,8 @@ main(int argc, char *argv[])
exit(1);
}
- initscr();
+ if (!initscr())
+ errx(0, "couldn't initialize screen");
(void)signal(SIGINT, receive_intr);
cbreak();
noecho();
diff --git a/gomoku/bdisp.c b/gomoku/bdisp.c
index 522d92f1..b1f18033 100644
--- a/gomoku/bdisp.c
+++ b/gomoku/bdisp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: bdisp.c,v 1.8 2003/08/07 09:37:16 agc Exp $ */
+/* $NetBSD: bdisp.c,v 1.9 2008/08/08 16:10:47 drochner Exp $ */
/*
* Copyright (c) 1994
@@ -37,12 +37,13 @@
#if 0
static char sccsid[] = "@(#)bdisp.c 8.2 (Berkeley) 5/3/95";
#else
-__RCSID("$NetBSD: bdisp.c,v 1.8 2003/08/07 09:37:16 agc Exp $");
+__RCSID("$NetBSD: bdisp.c,v 1.9 2008/08/08 16:10:47 drochner Exp $");
#endif
#endif /* not lint */
#include <curses.h>
#include <string.h>
+#include <stdlib.h>
#include "gomoku.h"
#define SCRNH 24 /* assume 24 lines for the moment */
@@ -61,7 +62,10 @@ void
cursinit()
{
- initscr();
+ if (!initscr()) {
+ fprintf(stderr, "couldn't initialize screen\n");
+ exit (0);
+ }
noecho();
cbreak();
leaveok(stdscr, TRUE);
diff --git a/hangman/main.c b/hangman/main.c
index 93b981e4..8ddcb804 100644
--- a/hangman/main.c
+++ b/hangman/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.13 2008/07/20 01:03:21 lukem Exp $ */
+/* $NetBSD: main.c,v 1.14 2008/08/08 16:10:47 drochner Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: main.c,v 1.13 2008/07/20 01:03:21 lukem Exp $");
+__RCSID("$NetBSD: main.c,v 1.14 2008/08/08 16:10:47 drochner Exp $");
#endif
#endif /* not lint */
@@ -76,7 +76,8 @@ main(argc, argv)
}
}
- initscr();
+ if (!initscr())
+ errx(0, "couldn't initialize screen");
signal(SIGINT, die);
setup();
for (;;) {
diff --git a/hunt/hunt/hunt.c b/hunt/hunt/hunt.c
index 780eaa29..aecaa308 100644
--- a/hunt/hunt/hunt.c
+++ b/hunt/hunt/hunt.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hunt.c,v 1.26 2008/01/28 03:23:29 dholland Exp $ */
+/* $NetBSD: hunt.c,v 1.27 2008/08/08 16:10:47 drochner Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hunt.c,v 1.26 2008/01/28 03:23:29 dholland Exp $");
+__RCSID("$NetBSD: hunt.c,v 1.27 2008/08/08 16:10:47 drochner Exp $");
#endif /* not lint */
# include <sys/param.h>
@@ -259,7 +259,8 @@ main(ac, av)
if (!isatty(0) || (term = getenv("TERM")) == NULL)
errx(1, "no terminal type");
# ifdef USE_CURSES
- initscr();
+ if (!initscr())
+ errx(0, "couldn't initialize screen");
(void) noecho();
(void) cbreak();
# else /* !USE_CURSES */
diff --git a/mille/mille.c b/mille/mille.c
index 62a45586..293b7491 100644
--- a/mille/mille.c
+++ b/mille/mille.c
@@ -1,4 +1,4 @@
-/* $NetBSD: mille.c,v 1.15 2008/07/20 01:03:21 lukem Exp $ */
+/* $NetBSD: mille.c,v 1.16 2008/08/08 16:10:47 drochner Exp $ */
/*
* Copyright (c) 1982, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1982, 1993\
#if 0
static char sccsid[] = "@(#)mille.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: mille.c,v 1.15 2008/07/20 01:03:21 lukem Exp $");
+__RCSID("$NetBSD: mille.c,v 1.16 2008/08/08 16:10:47 drochner Exp $");
#endif
#endif /* not lint */
@@ -78,7 +78,8 @@ main(ac, av)
/* NOTREACHED */
}
Play = PLAYER;
- initscr();
+ if (!initscr())
+ errx(0, "couldn't initialize screen");
delwin(stdscr);
stdscr = Board = newwin(BOARD_Y, BOARD_X, 0, 0);
Score = newwin(SCORE_Y, SCORE_X, 0, 40);
diff --git a/phantasia/main.c b/phantasia/main.c
index 11dc6fb1..996622ed 100644
--- a/phantasia/main.c
+++ b/phantasia/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.16 2006/05/13 22:29:53 christos Exp $ */
+/* $NetBSD: main.c,v 1.17 2008/08/08 16:10:47 drochner Exp $ */
/*
* Phantasia 3.3.2 -- Interterminal fantasy game
@@ -995,7 +995,10 @@ playinit()
signal(SIGPIPE, ill_sig);
#endif
- initscr(); /* turn on curses */
+ if (!initscr()) { /* turn on curses */
+ fprintf(stderr, "couldn't initialize screen\n");
+ exit (0);
+ }
noecho(); /* do not echo input */
cbreak(); /* do not process erase, kill */
clear();
diff --git a/rain/rain.c b/rain/rain.c
index 5256faa1..bd60ec32 100644
--- a/rain/rain.c
+++ b/rain/rain.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rain.c,v 1.20 2008/07/20 01:03:22 lukem Exp $ */
+/* $NetBSD: rain.c,v 1.21 2008/08/08 16:10:47 drochner Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\
#if 0
static char sccsid[] = "@(#)rain.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: rain.c,v 1.20 2008/07/20 01:03:22 lukem Exp $");
+__RCSID("$NetBSD: rain.c,v 1.21 2008/08/08 16:10:47 drochner Exp $");
#endif
#endif /* not lint */
@@ -93,7 +93,8 @@ main(int argc, char **argv)
return 1;
}
- (void)initscr();
+ if (!initscr())
+ errx(0, "couldn't initialize screen");
cols = COLS - 4;
lines = LINES - 4;
diff --git a/robots/main.c b/robots/main.c
index fbcc496c..98e2ff29 100644
--- a/robots/main.c
+++ b/robots/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.23 2008/07/20 01:03:22 lukem Exp $ */
+/* $NetBSD: main.c,v 1.24 2008/08/08 16:10:47 drochner Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: main.c,v 1.23 2008/07/20 01:03:22 lukem Exp $");
+__RCSID("$NetBSD: main.c,v 1.24 2008/08/08 16:10:47 drochner Exp $");
#endif
#endif /* not lint */
@@ -146,7 +146,8 @@ main(ac, av)
sleep(2);
}
- initscr();
+ if (!initscr())
+ errx(0, "couldn't initialize screen");
signal(SIGINT, quit);
cbreak();
noecho();
diff --git a/rogue/init.c b/rogue/init.c
index 0bb3d3b0..982a95cb 100644
--- a/rogue/init.c
+++ b/rogue/init.c
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.17 2008/01/14 03:50:01 dholland Exp $ */
+/* $NetBSD: init.c,v 1.18 2008/08/08 16:10:47 drochner Exp $ */
/*
* Copyright (c) 1988, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: init.c,v 1.17 2008/01/14 03:50:01 dholland Exp $");
+__RCSID("$NetBSD: init.c,v 1.18 2008/08/08 16:10:47 drochner Exp $");
#endif
#endif /* not lint */
@@ -113,7 +113,10 @@ init(int argc, char *argv[])
fflush(stdout);
}
- initscr();
+ if (!initscr()) {
+ fprintf(stderr, "couldn't initialize screen\n");
+ exit (0);
+ }
if ((LINES < DROWS) || (COLS < DCOLS)) {
clean_up("must be played on at least 80 x 24 screen");
}
diff --git a/snake/snake/snake.c b/snake/snake/snake.c
index 6d7ebb87..cac56136 100644
--- a/snake/snake/snake.c
+++ b/snake/snake/snake.c
@@ -1,4 +1,4 @@
-/* $NetBSD: snake.c,v 1.24 2008/07/20 01:03:22 lukem Exp $ */
+/* $NetBSD: snake.c,v 1.25 2008/08/08 16:10:47 drochner Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\
#if 0
static char sccsid[] = "@(#)snake.c 8.2 (Berkeley) 1/7/94";
#else
-__RCSID("$NetBSD: snake.c,v 1.24 2008/07/20 01:03:22 lukem Exp $");
+__RCSID("$NetBSD: snake.c,v 1.25 2008/08/08 16:10:47 drochner Exp $");
#endif
#endif /* not lint */
@@ -191,7 +191,8 @@ main(argc, argv)
srandom((int) tv);
penalty = loot = 0;
- initscr();
+ if (!initscr())
+ errx(0, "couldn't initialize screen");;
cbreak();
noecho();
#ifdef KEY_LEFT
diff --git a/worm/worm.c b/worm/worm.c
index 0e5c7920..2c166128 100644
--- a/worm/worm.c
+++ b/worm/worm.c
@@ -1,4 +1,4 @@
-/* $NetBSD: worm.c,v 1.27 2008/07/20 01:03:22 lukem Exp $ */
+/* $NetBSD: worm.c,v 1.28 2008/08/08 16:10:47 drochner Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\
#if 0
static char sccsid[] = "@(#)worm.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: worm.c,v 1.27 2008/07/20 01:03:22 lukem Exp $");
+__RCSID("$NetBSD: worm.c,v 1.28 2008/08/08 16:10:47 drochner Exp $");
#endif
#endif /* not lint */
@@ -106,7 +106,8 @@ main(argc, argv)
signal(SIGALRM, wake);
signal(SIGINT, leave);
signal(SIGQUIT, leave);
- initscr();
+ if (!initscr())
+ errx(0, "couldn't initialize screen");
cbreak();
noecho();
#ifdef KEY_LEFT
diff --git a/worms/worms.c b/worms/worms.c
index e6b85229..f5a600dd 100644
--- a/worms/worms.c
+++ b/worms/worms.c
@@ -1,4 +1,4 @@
-/* $NetBSD: worms.c,v 1.18 2008/07/20 01:03:22 lukem Exp $ */
+/* $NetBSD: worms.c,v 1.19 2008/08/08 16:10:47 drochner Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\
#if 0
static char sccsid[] = "@(#)worms.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: worms.c,v 1.18 2008/07/20 01:03:22 lukem Exp $");
+__RCSID("$NetBSD: worms.c,v 1.19 2008/08/08 16:10:47 drochner Exp $");
#endif
#endif /* not lint */
@@ -237,7 +237,8 @@ main(argc, argv)
if (!(worm = malloc((size_t)number *
sizeof(struct worm))) || !(mp = malloc((size_t)1024)))
nomem();
- initscr();
+ if (!initscr())
+ errx(0, "couldn't initialize screen");
curs_set(0);
CO = COLS;
LI = LINES;