diff options
author | Isaac Dunham <idunham@lavabit.com> | 2013-07-06 11:26:15 -0500 |
---|---|---|
committer | Isaac Dunham <idunham@lavabit.com> | 2013-07-06 11:26:15 -0500 |
commit | c810f9f80b9db62de09b6cf4c6ca770eed72ce53 (patch) | |
tree | 2ef2dbf640e94ecd7918b54a1e1bea7ce779f78c /toys/posix/paste.c | |
parent | 8e9ec867e5753e63778d67c3cb1cce68792f7b24 (diff) | |
download | toybox-c810f9f80b9db62de09b6cf4c6ca770eed72ce53.tar.gz |
This inlines CRC64, and nothing more.
The functions involved were called only once.
Diffstat (limited to 'toys/posix/paste.c')
-rw-r--r-- | toys/posix/paste.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/toys/posix/paste.c b/toys/posix/paste.c index 92a52534..0e170cdb 100644 --- a/toys/posix/paste.c +++ b/toys/posix/paste.c @@ -28,28 +28,26 @@ GLOBALS( void paste_main(void) { - char *p, *buf = toybuf; - char **args = toys.optargs; + char *p, *buf = toybuf, **args = toys.optargs; size_t ndelim = 0; int i, j, c; // Process delimiter list // TODO: Handle multibyte characters if (!(toys.optflags & FLAG_d)) TT.delim = "\t"; - p = TT.delim; - for (; *p; p++, buf++, ndelim++) { + for (p = TT.delim; *p; p++, buf++, ndelim++) { if (*p == '\\') { p++; if (-1 == (i = stridx("nt\\0", *p))) error_exit("bad delimiter: \\%c", *p); *buf = "\n\t\\\0"[i]; - } - else *buf = *p; + } else *buf = *p; } *buf = 0; if (toys.optflags & FLAG_s) { // Sequential FILE *f; + for (; *args; args++) { if ((*args)[0] == '-' && !(*args)[1]) f = stdin; else if (!(f = fopen(*args, "r"))) perror_exit("%s", *args); @@ -66,20 +64,21 @@ void paste_main(void) if (f != stdin) fclose(f); putchar('\n'); } - } - else { // Parallel + } else { // Parallel // Need to be careful not to print an extra line at the end FILE **files; int anyopen = 1; + files = (FILE**)(buf + 1); for (; *args; args++, files++) { if ((*args)[0] == '-' && !(*args)[1]) *files = stdin; else if (!(*files = fopen(*args, "r"))) perror_exit("%s", *args); } - for (; anyopen;) { + while (anyopen) { anyopen = 0; for (i = 0; i < toys.optc; i++) { FILE **f = (FILE**)(buf + 1) + i; + if (*f) for (;;) { c = getc(*f); if (c != EOF) { |