diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2015-04-01 20:28:05 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2015-04-01 20:28:05 +0000 |
commit | aeca232e15d041fe340d010bfa003d0bbfc9746f (patch) | |
tree | 2d9ab0db1adc9d3a965cf197a495baed95166c01 /usr.bin | |
parent | b237269096431f40f409a44a9a1a1cf3543c1433 (diff) |
If strtoul() fails to parse the argument to -k, just pass the
error back to the caller instead of calling err() directly.
The user gets a more useful error message this way.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/sort/sort.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/usr.bin/sort/sort.c b/usr.bin/sort/sort.c index c6d89fbc586..88f99c9768b 100644 --- a/usr.bin/sort/sort.c +++ b/usr.bin/sort/sort.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sort.c,v 1.57 2015/04/01 20:24:12 millert Exp $ */ +/* $OpenBSD: sort.c,v 1.58 2015/04/01 20:28:04 millert Exp $ */ /*- * Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org> @@ -561,18 +561,18 @@ parse_pos(const char *s, struct key_specs *ks, bool *mef_flags, bool second) if (second) { errno = 0; - ks->f2 = (size_t) strtoul(f, NULL, 10); + ks->f2 = (size_t)strtoul(f, NULL, 10); if (errno != 0) - err(2, "-k"); + goto end; if (ks->f2 == 0) { warn("0 field in key specs"); goto end; } } else { errno = 0; - ks->f1 = (size_t) strtoul(f, NULL, 10); + ks->f1 = (size_t)strtoul(f, NULL, 10); if (errno != 0) - err(2, "-k"); + goto end; if (ks->f1 == 0) { warn("0 field in key specs"); goto end; @@ -588,14 +588,14 @@ parse_pos(const char *s, struct key_specs *ks, bool *mef_flags, bool second) if (second) { errno = 0; - ks->c2 = (size_t) strtoul(c, NULL, 10); + ks->c2 = (size_t)strtoul(c, NULL, 10); if (errno != 0) - err(2, "-k"); + goto end; } else { errno = 0; - ks->c1 = (size_t) strtoul(c, NULL, 10); + ks->c1 = (size_t)strtoul(c, NULL, 10); if (errno != 0) - err(2, "-k"); + goto end; if (ks->c1 == 0) { warn("0 column in key specs"); goto end; |