aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/split.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-08-25 15:32:22 -0500
committerRob Landley <rob@landley.net>2018-08-25 15:32:22 -0500
commit482c422f8e8ec517de071266d425b425c4628103 (patch)
tree709d459ba58b1416c340ffedab69faf21d4bee99 /toys/posix/split.c
parent79c403179b603a9f3c8cd120a93c2f560017864b (diff)
downloadtoybox-482c422f8e8ec517de071266d425b425c4628103.tar.gz
Convert more argument variables in GLOBALS() to new style.
Diffstat (limited to 'toys/posix/split.c')
-rw-r--r--toys/posix/split.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/toys/posix/split.c b/toys/posix/split.c
index 98d70c2a..0da8da6a 100644
--- a/toys/posix/split.c
+++ b/toys/posix/split.c
@@ -28,9 +28,7 @@ config SPLIT
#include "toys.h"
GLOBALS(
- long lines;
- long bytes;
- long suflen;
+ long l, b, a;
char *outfile;
)
@@ -56,23 +54,23 @@ static void do_split(int infd, char *in)
}
// Start new output file?
- if ((TT.bytes && !bytesleft) || (TT.lines && !linesleft)) {
+ if ((TT.b && !bytesleft) || (TT.l && !linesleft)) {
char *s = TT.outfile + strlen(TT.outfile);
j = filenum++;
- for (i = 0; i<TT.suflen; i++) {
+ for (i = 0; i<TT.a; i++) {
*(--s) = 'a'+(j%26);
j /= 26;
}
if (j) error_exit("bad suffix");
- bytesleft = TT.bytes;
- linesleft = TT.lines;
+ bytesleft = TT.b;
+ linesleft = TT.l;
if (outfd != -1) close(outfd);
outfd = xcreate(TT.outfile, O_RDWR|O_CREAT|O_TRUNC, st.st_mode & 0777);
}
// Write next chunk of output.
- if (TT.lines) {
+ if (TT.l) {
for (i = pos; i < len; ) {
if (toybuf[i++] == '\n' && !--linesleft) break;
if (!--bytesleft) break;
@@ -97,11 +95,11 @@ static void do_split(int infd, char *in)
void split_main(void)
{
- if (!TT.bytes && !TT.lines) TT.lines = 1000;
+ if (!TT.b && !TT.l) TT.l = 1000;
// Allocate template for output filenames
TT.outfile = xmprintf("%s%*c", (toys.optc == 2) ? toys.optargs[1] : "x",
- (int)TT.suflen, ' ');
+ (int)TT.a, ' ');
// We only ever use one input, but this handles '-' or no input for us.
loopfiles(toys.optargs, do_split);