diff options
author | dholland <dholland@NetBSD.org> | 2008-02-24 06:03:35 +0000 |
---|---|---|
committer | dholland <dholland@NetBSD.org> | 2008-02-24 06:03:35 +0000 |
commit | 26ed5a094d93bb19c3fa7e2a29ccca62a7955c64 (patch) | |
tree | 153e949a5328cd890d3634cf02186329f29e37eb /monop | |
parent | 54d758cb4f91850365584775a8a4a3ad42f135d4 (diff) | |
download | bsdgames-darwin-26ed5a094d93bb19c3fa7e2a29ccca62a7955c64.tar.gz bsdgames-darwin-26ed5a094d93bb19c3fa7e2a29ccca62a7955c64.tar.zst bsdgames-darwin-26ed5a094d93bb19c3fa7e2a29ccca62a7955c64.zip |
Fix some more lint. (There's plenty to go around.)
If we try to load a game and it bombs, keep prompting for another one,
because if we try to continue with a half-loaded game we'll probably
end up in trouble.
Diffstat (limited to 'monop')
-rw-r--r-- | monop/execute.c | 36 | ||||
-rw-r--r-- | monop/monop.c | 6 |
2 files changed, 22 insertions, 20 deletions
diff --git a/monop/execute.c b/monop/execute.c index 9cace327..b8208fcc 100644 --- a/monop/execute.c +++ b/monop/execute.c @@ -1,4 +1,4 @@ -/* $NetBSD: execute.c,v 1.19 2008/02/24 03:56:48 christos Exp $ */ +/* $NetBSD: execute.c,v 1.20 2008/02/24 06:03:35 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)execute.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: execute.c,v 1.19 2008/02/24 03:56:48 christos Exp $"); +__RCSID("$NetBSD: execute.c,v 1.20 2008/02/24 06:03:35 dholland Exp $"); #endif #endif /* not lint */ @@ -333,27 +333,29 @@ save() * This routine restores an old game from a file */ void -restore() +restore(void) { char *sp; - printf("Which file do you wish to restore from? "); - fgets(buf, sizeof(buf), stdin); - if (feof(stdin)) - return; - sp = strchr(buf, '\n'); - if (sp) - *sp = '\0'; - rest_f(buf); + for (;;) { + printf("Which file do you wish to restore from? "); + fgets(buf, sizeof(buf), stdin); + if (feof(stdin)) + return; + sp = strchr(buf, '\n'); + if (sp) + *sp = '\0'; + if (rest_f(buf) == 0) + break; + } } /* - * This does the actual restoring. It returns TRUE if the - * backup was successful, else false. + * This does the actual restoring. It returns zero on success, + * and -1 on failure. */ int -rest_f(file) - const char *file; +rest_f(const char *file) { char *sp; FILE *inf; @@ -364,7 +366,7 @@ rest_f(file) inf = fopen(file, "r"); if (inf == NULL) { warn("%s", file); - return FALSE; + return -1; } printf("\"%s\" ", file); if (fstat(fileno(inf), &sbuf) < 0) { @@ -415,7 +417,7 @@ rest_f(file) continue; *sp = '\0'; printf("[%s]\n", xbuf); - return TRUE; + return 0; } /* diff --git a/monop/monop.c b/monop/monop.c index 72b4b2b8..e4faa86e 100644 --- a/monop/monop.c +++ b/monop/monop.c @@ -1,4 +1,4 @@ -/* $NetBSD: monop.c,v 1.22 2008/02/24 03:56:49 christos Exp $ */ +/* $NetBSD: monop.c,v 1.23 2008/02/24 06:03:35 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ #if 0 static char sccsid[] = "@(#)monop.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: monop.c,v 1.22 2008/02/24 03:56:49 christos Exp $"); +__RCSID("$NetBSD: monop.c,v 1.23 2008/02/24 06:03:35 dholland Exp $"); #endif #endif /* not lint */ @@ -235,7 +235,7 @@ main(ac, av) init_decks(); init_monops(); if (ac > 1) { - if (!rest_f(av[1])) + if (rest_f(av[1]) < 0) restore(); } else { |