summaryrefslogtreecommitdiff
path: root/games/tetris
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2006-04-20 03:24:13 +0000
committerRay Lai <ray@cvs.openbsd.org>2006-04-20 03:24:13 +0000
commit5d75087b8fdf1c7fbec78cc3b93a71d67561141f (patch)
tree52ef6f5a6ee383073e8ee04456a0cd77cfdf2498 /games/tetris
parentb38aea99f7a0ba94ca98ac3962ae4b7f143b639b (diff)
Clean up getopt stuff and use strtonum instead of atoi.
OK jaredy@
Diffstat (limited to 'games/tetris')
-rw-r--r--games/tetris/tetris.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/games/tetris/tetris.c b/games/tetris/tetris.c
index 65db7ddf0f6..4402d42958b 100644
--- a/games/tetris/tetris.c
+++ b/games/tetris/tetris.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tetris.c,v 1.20 2004/07/10 07:26:24 deraadt Exp $ */
+/* $OpenBSD: tetris.c,v 1.21 2006/04/20 03:24:12 ray Exp $ */
/* $NetBSD: tetris.c,v 1.2 1995/04/22 07:42:47 cgd Exp $ */
/*-
@@ -160,6 +160,7 @@ main(int argc, char *argv[])
char *keys;
int level = 2;
char key_write[6][10];
+ const char *errstr;
int ch, i, j;
keys = "jkl pq";
@@ -169,7 +170,7 @@ main(int argc, char *argv[])
setegid(gid);
classic = showpreview = 0;
- while ((ch = getopt(argc, argv, "chk:l:ps")) != -1)
+ while ((ch = getopt(argc, argv, "ck:l:ps")) != -1)
switch(ch) {
case 'c':
/*
@@ -184,8 +185,9 @@ main(int argc, char *argv[])
usage();
break;
case 'l':
- level = atoi(optarg);
- if (level < MINLEVEL || level > MAXLEVEL)
+ level = (int)strtonum(optarg, MINLEVEL, MAXLEVEL,
+ &errstr);
+ if (errstr)
errx(1, "level must be from %d to %d",
MINLEVEL, MAXLEVEL);
break;
@@ -195,8 +197,6 @@ main(int argc, char *argv[])
case 's':
showscores(0);
exit(0);
- case '?':
- case 'h':
default:
usage();
}