summaryrefslogtreecommitdiff
path: root/lib/buildcmd.c
diff options
context:
space:
mode:
authorJames Youngman <jay@gnu.org>2005-11-23 07:06:13 +0000
committerJames Youngman <jay@gnu.org>2005-11-23 07:06:13 +0000
commitdd0afc68506079d99c6925419b3a1ab7a260989a (patch)
tree285d48ea9f1f4160fe8ca93dc8ba576555180409 /lib/buildcmd.c
parent71bc3468b052f8f4441cecf72ba9815d6859afcd (diff)
downloadfindutils-dd0afc68506079d99c6925419b3a1ab7a260989a.tar.gz
Merged changes from the 4.2.x branch
Diffstat (limited to 'lib/buildcmd.c')
-rw-r--r--lib/buildcmd.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/lib/buildcmd.c b/lib/buildcmd.c
index ccb11392..0bf94f95 100644
--- a/lib/buildcmd.c
+++ b/lib/buildcmd.c
@@ -183,6 +183,25 @@ void do_exec(const struct buildcmd_control *ctl,
}
+/* Return nonzero if there would not be enoughy room for an additional
+ * argument. If we return zero, there still may not be enough room
+ * for the next one, depending on its length.
+ */
+static int
+bc_argc_limit_reached(int initial_args,
+ const struct buildcmd_control *ctl,
+ struct buildcmd_state *state)
+{
+ if (!initial_args && ctl->args_per_exec &&
+ ( (state->cmd_argc - ctl->initial_argc) == ctl->args_per_exec))
+ return 1;
+ else if (state->cmd_argc == ARG_MAX / sizeof (void *) - 1)
+ return 1;
+ else
+ return 0;
+}
+
+
/* Add ARG to the end of the list of arguments `cmd_argv' to pass
to the command.
LEN is the length of ARG, including the terminating null.
@@ -211,9 +230,9 @@ bc_push_arg (const struct buildcmd_control *ctl,
error (1, 0, _("argument list too long"));
do_exec (ctl, state);
}
- if (!initial_args && ctl->args_per_exec &&
- state->cmd_argc - ctl->initial_argc == ctl->args_per_exec)
- do_exec (ctl, state);
+
+ if (bc_argc_limit_reached(initial_args, ctl, state))
+ do_exec (ctl, state);
}
if (state->cmd_argc >= state->cmd_argv_alloc)
@@ -250,11 +269,8 @@ bc_push_arg (const struct buildcmd_control *ctl,
* conditional on arg!=NULL, since do_exec()
* actually calls bc_push_arg(ctl, state, NULL, 0, false).
*/
- if ((!initial_args
- && ctl->args_per_exec
- && (state->cmd_argc - ctl->initial_argc) == ctl->args_per_exec)
- || state->cmd_argc == ARG_MAX / sizeof (void *) - 1)
- do_exec (ctl, state);
+ if (bc_argc_limit_reached(initial_args, ctl, state))
+ do_exec (ctl, state);
}
/* If this is an initial argument, set the high-water mark. */