diff options
author | elad <elad@NetBSD.org> | 2006-01-20 21:40:08 +0000 |
---|---|---|
committer | elad <elad@NetBSD.org> | 2006-01-20 21:40:08 +0000 |
commit | 70f825fc24933eacf0a9d8619a5cb35e7153b41a (patch) | |
tree | cbbbf71eef229765ae10b8d8f2f42bfdae0e9d22 /monop/getinp.c | |
parent | fc19bed38121a44d92bd36ec9fc2d20d063fd69d (diff) | |
download | bsdgames-darwin-70f825fc24933eacf0a9d8619a5cb35e7153b41a.tar.gz bsdgames-darwin-70f825fc24933eacf0a9d8619a5cb35e7153b41a.tar.zst bsdgames-darwin-70f825fc24933eacf0a9d8619a5cb35e7153b41a.zip |
better handle ^d in getinp(), so we dont loop endlessly.
i have no idea why i wanted to play this game.
Diffstat (limited to 'monop/getinp.c')
-rw-r--r-- | monop/getinp.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/monop/getinp.c b/monop/getinp.c index fee84c5e..cd0253c9 100644 --- a/monop/getinp.c +++ b/monop/getinp.c @@ -1,4 +1,4 @@ -/* $NetBSD: getinp.c,v 1.13 2004/11/05 21:30:32 dsl Exp $ */ +/* $NetBSD: getinp.c,v 1.14 2006/01/20 21:40:08 elad Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)getinp.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: getinp.c,v 1.13 2004/11/05 21:30:32 dsl Exp $"); +__RCSID("$NetBSD: getinp.c,v 1.14 2006/01/20 21:40:08 elad Exp $"); #endif #endif /* not lint */ @@ -58,13 +58,12 @@ getinp(prompt, list) int c; for (;;) { -inter: printf("%s", prompt); for (sp = buf; (c=getchar()) != '\n'; ) { + if (c == -1) + return 0; *sp = c; - if (c == -1) /* check for interrupted system call */ - goto inter; - else if (sp != buf || *sp != ' ') + if (sp != buf || *sp != ' ') sp++; } *sp = c; |