Using better tool for the job.
Index: arithmetic.c
===================================================================
RCS file: /cvs/src/games/arithmetic/arithmetic.c,v
retrieving revision 1.18
diff -u -p -r1.18 arithmetic.c
--- arithmetic.c 29 Aug 2013 20:22:09 -0000 1.18
+++ arithmetic.c 10 Jan 2015 17:12:11 -0000
@@ -63,6 +63,7 @@
#include <sys/types.h>
#include <err.h>
#include <ctype.h>
+#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -112,10 +113,14 @@ main(int argc, char *argv[])
nkeys = p - optarg;
break;
}
- case 'r':
- if ((rangemax = atoi(optarg)) <= 0)
- errx(1, "invalid range.");
+ case 'r': {
+ const char *errstr;
+
+ rangemax = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "range is %s", errstr);
break;
+ }
case '?':
case 'h':
default: