Lines 41-46
Link Here
|
41 |
|
41 |
|
42 |
#include <sys/types.h> |
42 |
#include <sys/types.h> |
43 |
|
43 |
|
|
|
44 |
#include <ctype.h> |
44 |
#include <err.h> |
45 |
#include <err.h> |
45 |
#include <errno.h> |
46 |
#include <errno.h> |
46 |
#include <inttypes.h> |
47 |
#include <inttypes.h> |
Lines 190-196
Link Here
|
190 |
|
191 |
|
191 |
res = get_num(arg); |
192 |
res = get_num(arg); |
192 |
if (res < 1 || res > SSIZE_MAX) |
193 |
if (res < 1 || res > SSIZE_MAX) |
193 |
errx(1, "bs must be between 1 and %jd", (intmax_t)SSIZE_MAX); |
194 |
errx(1, "bs must be between 1 and %zd", SSIZE_MAX); |
194 |
in.dbsz = out.dbsz = (size_t)res; |
195 |
in.dbsz = out.dbsz = (size_t)res; |
195 |
} |
196 |
} |
196 |
|
197 |
|
Lines 201-207
Link Here
|
201 |
|
202 |
|
202 |
res = get_num(arg); |
203 |
res = get_num(arg); |
203 |
if (res < 1 || res > SSIZE_MAX) |
204 |
if (res < 1 || res > SSIZE_MAX) |
204 |
errx(1, "cbs must be between 1 and %jd", (intmax_t)SSIZE_MAX); |
205 |
errx(1, "cbs must be between 1 and %zd", SSIZE_MAX); |
205 |
cbsz = (size_t)res; |
206 |
cbsz = (size_t)res; |
206 |
} |
207 |
} |
207 |
|
208 |
|
Lines 208-222
Link Here
|
208 |
static void |
209 |
static void |
209 |
f_count(char *arg) |
210 |
f_count(char *arg) |
210 |
{ |
211 |
{ |
211 |
intmax_t res; |
212 |
uintmax_t res; |
212 |
|
213 |
|
213 |
res = (intmax_t)get_num(arg); |
214 |
res = get_num(arg); |
214 |
if (res < 0) |
215 |
if (res == UINTMAX_MAX) |
215 |
errx(1, "count cannot be negative"); |
216 |
errc(1, ERANGE, "%s", oper); |
216 |
if (res == 0) |
217 |
if (res == 0) |
217 |
cpy_cnt = (uintmax_t)-1; |
218 |
cpy_cnt = UINTMAX_MAX; |
218 |
else |
219 |
else |
219 |
cpy_cnt = (uintmax_t)res; |
220 |
cpy_cnt = res; |
220 |
} |
221 |
} |
221 |
|
222 |
|
222 |
static void |
223 |
static void |
Lines 225-231
Link Here
|
225 |
|
226 |
|
226 |
files_cnt = get_num(arg); |
227 |
files_cnt = get_num(arg); |
227 |
if (files_cnt < 1) |
228 |
if (files_cnt < 1) |
228 |
errx(1, "files must be between 1 and %jd", (uintmax_t)-1); |
229 |
errx(1, "files must be between 1 and %zu", SIZE_MAX); |
229 |
} |
230 |
} |
230 |
|
231 |
|
231 |
static void |
232 |
static void |
Lines 246-253
Link Here
|
246 |
if (!(ddflags & C_BS)) { |
247 |
if (!(ddflags & C_BS)) { |
247 |
res = get_num(arg); |
248 |
res = get_num(arg); |
248 |
if (res < 1 || res > SSIZE_MAX) |
249 |
if (res < 1 || res > SSIZE_MAX) |
249 |
errx(1, "ibs must be between 1 and %jd", |
250 |
errx(1, "ibs must be between 1 and %zd", |
250 |
(intmax_t)SSIZE_MAX); |
251 |
SSIZE_MAX); |
251 |
in.dbsz = (size_t)res; |
252 |
in.dbsz = (size_t)res; |
252 |
} |
253 |
} |
253 |
} |
254 |
} |
Lines 267-274
Link Here
|
267 |
if (!(ddflags & C_BS)) { |
268 |
if (!(ddflags & C_BS)) { |
268 |
res = get_num(arg); |
269 |
res = get_num(arg); |
269 |
if (res < 1 || res > SSIZE_MAX) |
270 |
if (res < 1 || res > SSIZE_MAX) |
270 |
errx(1, "obs must be between 1 and %jd", |
271 |
errx(1, "obs must be between 1 and %zd", |
271 |
(intmax_t)SSIZE_MAX); |
272 |
SSIZE_MAX); |
272 |
out.dbsz = (size_t)res; |
273 |
out.dbsz = (size_t)res; |
273 |
} |
274 |
} |
274 |
} |
275 |
} |
Lines 378-388
Link Here
|
378 |
uintmax_t num, mult, prevnum; |
379 |
uintmax_t num, mult, prevnum; |
379 |
char *expr; |
380 |
char *expr; |
380 |
|
381 |
|
|
|
382 |
while (isspace(val[0])) |
383 |
val++; |
384 |
|
385 |
if (val[0] == '-') |
386 |
errx(1, "%s: cannot be negative", oper); |
387 |
|
381 |
errno = 0; |
388 |
errno = 0; |
382 |
num = strtouq(val, &expr, 0); |
389 |
num = strtoull(val, &expr, 0); |
383 |
if (errno != 0) /* Overflow or underflow. */ |
390 |
if (errno != 0) /* Overflow or underflow. */ |
384 |
err(1, "%s", oper); |
391 |
err(1, "%s", oper); |
385 |
|
392 |
|
386 |
if (expr == val) /* No valid digits. */ |
393 |
if (expr == val) /* No valid digits. */ |
387 |
errx(1, "%s: illegal numeric value", oper); |
394 |
errx(1, "%s: illegal numeric value", oper); |
388 |
|
395 |
|