[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
replace atoi with strtonum in cal.c
- To: tech_(_at_)_openbsd_(_dot_)_org
- Subject: replace atoi with strtonum in cal.c
- From: Han Boetes <han_(_at_)_mijncomputer_(_dot_)_nl>
- Date: Thu, 30 Mar 2006 08:40:00 +0200
- Mail-followup-to: tech_(_at_)_openbsd_(_dot_)_org
Hi,
Changelog:
atoi -> strtonum
>From Han Boetes.
Index: cal.c
===================================================================
RCS file: /cvs/src/usr.bin/cal/cal.c,v
retrieving revision 1.19
diff -u -p -r1.19 cal.c
--- cal.c 24 Mar 2006 03:44:14 -0000 1.19
+++ cal.c 30 Mar 2006 06:29:00 -0000
@@ -135,6 +135,7 @@ int
main(int argc, char *argv[])
{
struct tm *local_time;
+ const char *errstr;
time_t now;
int ch, month, year, yflag;
@@ -170,8 +171,10 @@ main(int argc, char *argv[])
local_time = localtime(&now);
year = local_time->tm_year + TM_YEAR_BASE;
} else {
- if ((year = atoi(*argv)) < 1 || year > 9999)
+ year = strtonum(*argv, 1, 9999, &errstr);
+ if (errstr)
errx(1, "illegal year value: use 1-9999");
+
}
break;
case 0:
# Han
Visit your host, monkey.org