X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/99518a3664f03a0839b12707e82684f120310023..046a883f893f50af80db956843570a76813aad30:/worms/worms.c?ds=sidebyside diff --git a/worms/worms.c b/worms/worms.c index e6b85229..7b63d7bf 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.23 2020/10/14 07:32:53 nia 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.23 2020/10/14 07:32:53 nia Exp $"); #endif #endif /* not lint */ @@ -177,16 +177,14 @@ static struct worm { short *xpos, *ypos; } *worm; -volatile sig_atomic_t sig_caught = 0; +static volatile sig_atomic_t sig_caught = 0; int main(int, char **); -void nomem(void) __dead; -void onsig(int); +static void nomem(void) __dead; +static void onsig(int); int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { int x, y, h, n; struct worm *w; @@ -196,7 +194,7 @@ main(argc, argv) short **ref; const char *field; char *mp; - unsigned int delay = 0; + unsigned int delay = 20000; mp = NULL; length = 16; @@ -206,7 +204,7 @@ main(argc, argv) while ((ch = getopt(argc, argv, "d:fl:n:t")) != -1) switch(ch) { case 'd': - if ((delay = (unsigned int)strtoul(optarg, (char **)NULL, 10)) < 1 || delay > 1000) + if ((delay = (unsigned int)strtoul(optarg, NULL, 10)) < 1 || delay > 1000) errx(1, "invalid delay (1-1000)"); delay *= 1000; /* ms -> us */ break; @@ -237,7 +235,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; @@ -338,15 +337,14 @@ main(argc, argv) } } -void -onsig(signo) - int signo __unused; +static void +onsig(int signo __unused) { sig_caught = 1; } -void -nomem() +static void +nomem(void) { errx(1, "not enough memory."); }