[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

replace atoi with strtonum in cal.c



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