diff options
author | Simon J. Gerraty <sjg@FreeBSD.org> | 2014-04-28 07:50:45 +0000 |
---|---|---|
committer | Simon J. Gerraty <sjg@FreeBSD.org> | 2014-04-28 07:50:45 +0000 |
commit | 3b8f08459569bf0faa21473e5cec2491e95c9349 (patch) | |
tree | 80f45dd81ca716bcd7ca9674581e1fc40b93cd34 /usr.bin/split | |
parent | 9d2ab4a62d6733c45958627ac113bdbd818d1e2a (diff) | |
parent | b2ba55951383498f252746f618d513139da06e8e (diff) | |
download | src-3b8f08459569bf0faa21473e5cec2491e95c9349.tar.gz src-3b8f08459569bf0faa21473e5cec2491e95c9349.zip |
Merge head
Notes
Notes:
svn path=/projects/bmake/; revision=265044
Diffstat (limited to 'usr.bin/split')
-rw-r--r-- | usr.bin/split/Makefile | 2 | ||||
-rw-r--r-- | usr.bin/split/split.c | 20 |
2 files changed, 6 insertions, 16 deletions
diff --git a/usr.bin/split/Makefile b/usr.bin/split/Makefile index d176fdd7d457..097932c19007 100644 --- a/usr.bin/split/Makefile +++ b/usr.bin/split/Makefile @@ -2,5 +2,7 @@ # $FreeBSD$ PROG= split +LDADD= -lutil +DPADD= ${LIBUTIL} .include <bsd.prog.mk> diff --git a/usr.bin/split/split.c b/usr.bin/split/split.c index 572af5993071..9a0b0ecbe1aa 100644 --- a/usr.bin/split/split.c +++ b/usr.bin/split/split.c @@ -49,6 +49,7 @@ static const char sccsid[] = "@(#)split.c 8.2 (Berkeley) 4/16/94"; #include <errno.h> #include <fcntl.h> #include <inttypes.h> +#include <libutil.h> #include <limits.h> #include <locale.h> #include <stdbool.h> @@ -83,9 +84,8 @@ static void usage(void); int main(int argc, char **argv) { - intmax_t bytecnti; - long scale; int ch; + int error; char *ep, *p; setlocale(LC_ALL, ""); @@ -118,21 +118,9 @@ main(int argc, char **argv) break; case 'b': /* Byte count. */ errno = 0; - if ((bytecnti = strtoimax(optarg, &ep, 10)) <= 0 || - strchr("kKmMgG", *ep) == NULL || errno != 0) - errx(EX_USAGE, - "%s: illegal byte count", optarg); - if (*ep == 'k' || *ep == 'K') - scale = 1024; - else if (*ep == 'm' || *ep == 'M') - scale = 1024 * 1024; - else if (*ep == 'g' || *ep == 'G') - scale = 1024 * 1024 * 1024; - else - scale = 1; - if (bytecnti > OFF_MAX / scale) + error = expand_number(optarg, &bytecnt); + if (error == -1) errx(EX_USAGE, "%s: offset too large", optarg); - bytecnt = (off_t)(bytecnti * scale); break; case 'd': /* Decimal suffix */ dflag = true; |