xargs: minor optimizations
This commit is contained in:
parent
67ca2428d5
commit
8e486d5282
9
xargs.c
9
xargs.c
@ -234,12 +234,13 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cmd[i] = estrdup("/bin/echo");
|
cmd[i] = estrdup("/bin/echo");
|
||||||
argsz += strlen(cmd[i]) + 1;
|
argsz += strlen("/bin/echo") + 1;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
while (leftover || (arg = poparg())) {
|
while (leftover || (arg = poparg())) {
|
||||||
if (argsz + strlen(arg) + 1 > argmaxsz || i >= NARGS - 1) {
|
arglen = strlen(arg);
|
||||||
if (strlen(arg) + 1 > argmaxsz) {
|
if (argsz + arglen >= argmaxsz || i >= NARGS - 1) {
|
||||||
|
if (arglen >= argmaxsz) {
|
||||||
weprintf("insufficient argument space\n");
|
weprintf("insufficient argument space\n");
|
||||||
if (xflag)
|
if (xflag)
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -248,7 +249,7 @@ main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmd[i] = estrdup(arg);
|
cmd[i] = estrdup(arg);
|
||||||
argsz += strlen(cmd[i]) + 1;
|
argsz += arglen + 1;
|
||||||
i++;
|
i++;
|
||||||
a++;
|
a++;
|
||||||
leftover = 0;
|
leftover = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user