summaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2006-11-02 18:15:03 +0000
committerRay Lai <ray@cvs.openbsd.org>2006-11-02 18:15:03 +0000
commit745bbe97058998e62c44685f6958ed770d0f8dd4 (patch)
treebc9fa1f609066c3bb4736e996faffb5591ec7537 /games
parent3d4fc3222dc4f2ac4f621b71240d5df6128730ba (diff)
Check fgets failure and clarify character checks.
OK moritz@.
Diffstat (limited to 'games')
-rw-r--r--games/sail/pl_main.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/games/sail/pl_main.c b/games/sail/pl_main.c
index 159df6a702b..67f42e0c7c7 100644
--- a/games/sail/pl_main.c
+++ b/games/sail/pl_main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pl_main.c,v 1.10 2003/07/06 02:03:13 avsm Exp $ */
+/* $OpenBSD: pl_main.c,v 1.11 2006/11/02 18:15:02 ray Exp $ */
/* $NetBSD: pl_main.c,v 1.5 1995/04/24 12:25:25 cgd Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pl_main.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: pl_main.c,v 1.10 2003/07/06 02:03:13 avsm Exp $";
+static char rcsid[] = "$OpenBSD: pl_main.c,v 1.11 2006/11/02 18:15:02 ray Exp $";
#endif
#endif /* not lint */
@@ -197,8 +197,8 @@ reprint:
else {
(void) printf("Your name, Captain? ");
(void) fflush(stdout);
- (void) fgets(captain, sizeof captain, stdin);
- if (!*captain || *captain == '\n')
+ if (fgets(captain, sizeof captain, stdin) == NULL ||
+ captain[0] == '\0' || captain[0] == '\n')
(void) strlcpy(captain, "no name", sizeof captain);
else if (captain[strlen(captain) - 1] == '\n')
captain[strlen(captain) - 1] = '\0';