1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

- Swap atoi(3) for strtonum(3)

- Swap fputs(3) for fprintf(3)
- Use getprogname(3) instead of hardcoded string

OK and help from tb@
This commit is contained in:
mestre 2016-02-02 19:18:57 +00:00
parent b7bb341ad9
commit e42da8bde8

View File

@ -1,4 +1,4 @@
/* $OpenBSD: snake.c,v 1.23 2016/01/07 16:00:33 tb Exp $ */
/* $OpenBSD: snake.c,v 1.24 2016/02/02 19:18:57 mestre Exp $ */
/* $NetBSD: snake.c,v 1.8 1995/04/29 00:06:41 mycroft Exp $ */
/*
@ -156,10 +156,10 @@ main(int argc, char *argv[])
while ((ch = getopt(argc, argv, "hl:stw:")) != -1)
switch ((char)ch) {
case 'w': /* width */
ccnt = atoi(optarg);
ccnt = strtonum(optarg, 1, INT_MAX, NULL);
break;
case 'l': /* length */
lcnt = atoi(optarg);
lcnt = strtonum(optarg, 1, INT_MAX, NULL);
break;
case 's': /* score */
if (readscores(0))
@ -174,8 +174,8 @@ main(int argc, char *argv[])
case '?':
case 'h':
default:
fputs("usage: snake [-st] [-l length] [-w width]\n",
stderr);
fprintf(stderr, "usage: %s [-st] [-l length] "
"[-w width]\n", getprogname());
return 1;
}