diff options
author | Rob Landley <rob@landley.net> | 2015-08-01 12:22:18 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2015-08-01 12:22:18 -0500 |
commit | 5c6766a3ae30770784d054ffbf47faf290dee80e (patch) | |
tree | 684375871c8dc4537f8b2e05b463d33678583389 /toys/posix | |
parent | 7cc95a79a7a4ed8fb8fb3c5e1946a59c93ff335e (diff) | |
download | toybox-5c6766a3ae30770784d054ffbf47faf290dee80e.tar.gz |
Replace xcheckrange() with atolx_range()
Diffstat (limited to 'toys/posix')
-rw-r--r-- | toys/posix/cal.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/toys/posix/cal.c b/toys/posix/cal.c index bb476dfd..bd3afad4 100644 --- a/toys/posix/cal.c +++ b/toys/posix/cal.c @@ -64,14 +64,6 @@ static char *calstrings(char *buf, struct tm *tm) return buf; } -void xcheckrange(long val, long low, long high) -{ - char *err = "%ld %s than %ld"; - - if (val < low) error_exit(err, val, "less", low); - if (val > high) error_exit(err, val, "greater", high); -} - // Worst case scenario toybuf usage: sizeof(struct tm) plus 21 bytes/line // plus 8 lines/month plus 12 months, comes to a bit over 2k of our 4k buffer. @@ -86,12 +78,12 @@ void cal_main(void) buf += sizeof(struct tm); // Last argument is year, one before that (if any) is month. - xcheckrange(tm->tm_year = atol(toys.optargs[--toys.optc]),1,9999); + tm->tm_year = atolx_range(toys.optargs[--toys.optc], 1, 9999); tm->tm_year -= 1900; tm->tm_mday = 1; tm->tm_hour = 12; // noon to avoid timezone weirdness if (toys.optc) { - xcheckrange(tm->tm_mon = atol(toys.optargs[--toys.optc]),1,12); + tm->tm_mon = atolx_range(toys.optargs[--toys.optc], 1, 12); tm->tm_mon--; // Print 12 months of the year |