split.c (49198c429758b2bca2854d3748a4c6cfaf6cc633) split.c (a6dd1c93f49cf4b8e1d7ed6ed4100aef37d0ceab)
1/*
2 * Copyright (c) 1987, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 102 unchanged lines hidden (view full) ---

111 case 'a': /* Suffix length */
112 if ((sufflen = strtol(optarg, &ep, 10)) <= 0 || *ep)
113 errx(EX_USAGE,
114 "%s: illegal suffix length", optarg);
115 break;
116 case 'b': /* Byte count. */
117 errno = 0;
118 if ((bytecnti = strtoimax(optarg, &ep, 10)) <= 0 ||
1/*
2 * Copyright (c) 1987, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 102 unchanged lines hidden (view full) ---

111 case 'a': /* Suffix length */
112 if ((sufflen = strtol(optarg, &ep, 10)) <= 0 || *ep)
113 errx(EX_USAGE,
114 "%s: illegal suffix length", optarg);
115 break;
116 case 'b': /* Byte count. */
117 errno = 0;
118 if ((bytecnti = strtoimax(optarg, &ep, 10)) <= 0 ||
119 (*ep != '\0' && *ep != 'k' && *ep != 'm') ||
120 errno != 0)
119 strchr("kKmMgG", *ep) == NULL || errno != 0)
121 errx(EX_USAGE,
122 "%s: illegal byte count", optarg);
120 errx(EX_USAGE,
121 "%s: illegal byte count", optarg);
123 if (*ep == 'k')
122 if (*ep == 'k' || *ep == 'K')
124 scale = 1024;
123 scale = 1024;
125 else if (*ep == 'm')
124 else if (*ep == 'm' || *ep == 'M')
126 scale = 1024 * 1024;
125 scale = 1024 * 1024;
126 else if (*ep == 'g' || *ep == 'G')
127 scale = 1024 * 1024 * 1024;
127 else
128 scale = 1;
129 if (bytecnti > OFF_MAX / scale)
130 errx(EX_USAGE, "%s: offset too large", optarg);
131 bytecnt = (off_t)(bytecnti * scale);
132 break;
133 case 'l': /* Line count. */
134 if (numlines != 0)

--- 196 unchanged lines hidden (view full) ---

331 file_open = 1;
332}
333
334static void
335usage(void)
336{
337 (void)fprintf(stderr,
338"usage: split [-l line_count] [-a suffix_length] [file [prefix]]\n"
128 else
129 scale = 1;
130 if (bytecnti > OFF_MAX / scale)
131 errx(EX_USAGE, "%s: offset too large", optarg);
132 bytecnt = (off_t)(bytecnti * scale);
133 break;
134 case 'l': /* Line count. */
135 if (numlines != 0)

--- 196 unchanged lines hidden (view full) ---

332 file_open = 1;
333}
334
335static void
336usage(void)
337{
338 (void)fprintf(stderr,
339"usage: split [-l line_count] [-a suffix_length] [file [prefix]]\n"
339" split -b byte_count[k|m] [-a suffix_length] [file [prefix]]\n"
340" split -b byte_count[K|k|M|m|G|g] [-a suffix_length] [file [prefix]]\n"
340" split -p pattern [-a suffix_length] [file [prefix]]\n");
341 exit(EX_USAGE);
342}
341" split -p pattern [-a suffix_length] [file [prefix]]\n");
342 exit(EX_USAGE);
343}