split.c (bb78dba49b79cf66f84c863e3c392ba9f9b7f08d) split.c (49198c429758b2bca2854d3748a4c6cfaf6cc633)
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

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

125 else if (*ep == 'm')
126 scale = 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;
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

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

125 else if (*ep == 'm')
126 scale = 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 'p' : /* pattern matching. */
134 if (regcomp(&rgx, optarg, REG_EXTENDED|REG_NOSUB) != 0)
135 errx(EX_USAGE, "%s: illegal regexp", optarg);
136 pflag = 1;
137 break;
138 case 'l': /* Line count. */
139 if (numlines != 0)
140 usage();
141 if ((numlines = strtol(optarg, &ep, 10)) <= 0 || *ep)
142 errx(EX_USAGE,
143 "%s: illegal line count", optarg);
144 break;
133 case 'l': /* Line count. */
134 if (numlines != 0)
135 usage();
136 if ((numlines = strtol(optarg, &ep, 10)) <= 0 || *ep)
137 errx(EX_USAGE,
138 "%s: illegal line count", optarg);
139 break;
140 case 'p': /* pattern matching. */
141 if (regcomp(&rgx, optarg, REG_EXTENDED|REG_NOSUB) != 0)
142 errx(EX_USAGE, "%s: illegal regexp", optarg);
143 pflag = 1;
144 break;
145 default:
146 usage();
147 }
148 argv += optind;
149 argc -= optind;
150
151 if (*argv != NULL) { /* Input file. */
152 if (strcmp(*argv, "-") == 0)

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

330 err(EX_IOERR, "%s", fname);
331 file_open = 1;
332}
333
334static void
335usage(void)
336{
337 (void)fprintf(stderr,
145 default:
146 usage();
147 }
148 argv += optind;
149 argc -= optind;
150
151 if (*argv != NULL) { /* Input file. */
152 if (strcmp(*argv, "-") == 0)

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

330 err(EX_IOERR, "%s", fname);
331 file_open = 1;
332}
333
334static void
335usage(void)
336{
337 (void)fprintf(stderr,
338"usage: split [-a sufflen] [-b byte_count] [-l line_count] [-p pattern]\n");
339 (void)fprintf(stderr,
340" [file [prefix]]\n");
338"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 -p pattern [-a suffix_length] [file [prefix]]\n");
341 exit(EX_USAGE);
342}
341 exit(EX_USAGE);
342}