43c43
< __FBSDID("$FreeBSD: head/usr.bin/find/function.c 96785 2002-05-17 05:11:07Z jmallett $");
---
> __FBSDID("$FreeBSD: head/usr.bin/find/function.c 97736 2002-06-02 12:57:41Z tjr $");
57a58
> #include <limits.h>
530a532,538
> if (entry == NULL && plan->flags & F_EXECPLUS) {
> if (plan->e_ppos == plan->e_pbnum)
> return (1);
> plan->e_argv[plan->e_ppos] = NULL;
> goto doexec;
> }
>
538,541c546,561
< for (cnt = 0; plan->e_argv[cnt]; ++cnt)
< if (plan->e_len[cnt])
< brace_subst(plan->e_orig[cnt], &plan->e_argv[cnt],
< file, plan->e_len[cnt]);
---
> if (plan->flags & F_EXECPLUS) {
> if ((plan->e_argv[plan->e_ppos] = strdup(file)) == NULL)
> err(1, NULL);
> plan->e_len[plan->e_ppos] = strlen(file);
> plan->e_psize += plan->e_len[plan->e_ppos];
> if (++plan->e_ppos < plan->e_pnummax &&
> plan->e_psize < plan->e_psizemax)
> return (1);
> plan->e_argv[plan->e_ppos] = NULL;
> } else {
> for (cnt = 0; plan->e_argv[cnt]; ++cnt)
> if (plan->e_len[cnt])
> brace_subst(plan->e_orig[cnt],
> &plan->e_argv[cnt], file,
> plan->e_len[cnt]);
> }
543c563
< if ((plan->flags & F_NEEDOK) && !queryuser(plan->e_argv))
---
> doexec: if ((plan->flags & F_NEEDOK) && !queryuser(plan->e_argv))
563a584,589
> if (plan->flags & F_EXECPLUS) {
> while (--plan->e_ppos >= plan->e_pbnum)
> free(plan->e_argv[plan->e_ppos]);
> plan->e_ppos = plan->e_pbnum;
> plan->e_psize = plan->e_pbsize;
> }
581c607,608
< int cnt;
---
> long argmax;
> int cnt, i;
597a625,628
> if (**ap == '+' && ap != argv && strcmp(*(ap - 1), "{}") == 0) {
> new->flags |= F_EXECPLUS;
> break;
> }
603a635,650
> if (new->flags & F_EXECPLUS) {
> new->e_ppos = new->e_pbnum = cnt - 2;
> if ((argmax = sysconf(_SC_ARG_MAX)) == -1) {
> warn("sysconf(_SC_ARG_MAX)");
> argmax = _POSIX_ARG_MAX;
> }
> /*
> * Estimate the maximum number of arguments as {ARG_MAX}/10,
> * and the maximum number of bytes to use for arguments as
> * {ARG_MAX}*(3/4).
> */
> new->e_pnummax = argmax / 10;
> new->e_psizemax = (argmax / 4) * 3;
> new->e_pbsize = 0;
> cnt += new->e_pnummax + 1;
> }
612a660,661
> if (new->flags & F_EXECPLUS)
> new->e_pbsize += strlen(*argv) + 1;
614c663,664
< if (p[0] == '{' && p[1] == '}') {
---
> if (!(new->flags & F_EXECPLUS) && p[0] == '{' &&
> p[1] == '}') {
625a676,686
> if (new->flags & F_EXECPLUS) {
> new->e_psize = new->e_pbsize;
> cnt--;
> for (i = 0; i < new->e_pnummax; i++) {
> new->e_argv[cnt] = NULL;
> new->e_len[cnt] = 0;
> cnt++;
> }
> argv = ap;
> goto done;
> }
628c689
< *argvp = argv + 1;
---
> done: *argvp = argv + 1;
< __FBSDID("$FreeBSD: head/usr.bin/find/function.c 96785 2002-05-17 05:11:07Z jmallett $");
---
> __FBSDID("$FreeBSD: head/usr.bin/find/function.c 97736 2002-06-02 12:57:41Z tjr $");
57a58
> #include <limits.h>
530a532,538
> if (entry == NULL && plan->flags & F_EXECPLUS) {
> if (plan->e_ppos == plan->e_pbnum)
> return (1);
> plan->e_argv[plan->e_ppos] = NULL;
> goto doexec;
> }
>
538,541c546,561
< for (cnt = 0; plan->e_argv[cnt]; ++cnt)
< if (plan->e_len[cnt])
< brace_subst(plan->e_orig[cnt], &plan->e_argv[cnt],
< file, plan->e_len[cnt]);
---
> if (plan->flags & F_EXECPLUS) {
> if ((plan->e_argv[plan->e_ppos] = strdup(file)) == NULL)
> err(1, NULL);
> plan->e_len[plan->e_ppos] = strlen(file);
> plan->e_psize += plan->e_len[plan->e_ppos];
> if (++plan->e_ppos < plan->e_pnummax &&
> plan->e_psize < plan->e_psizemax)
> return (1);
> plan->e_argv[plan->e_ppos] = NULL;
> } else {
> for (cnt = 0; plan->e_argv[cnt]; ++cnt)
> if (plan->e_len[cnt])
> brace_subst(plan->e_orig[cnt],
> &plan->e_argv[cnt], file,
> plan->e_len[cnt]);
> }
543c563
< if ((plan->flags & F_NEEDOK) && !queryuser(plan->e_argv))
---
> doexec: if ((plan->flags & F_NEEDOK) && !queryuser(plan->e_argv))
563a584,589
> if (plan->flags & F_EXECPLUS) {
> while (--plan->e_ppos >= plan->e_pbnum)
> free(plan->e_argv[plan->e_ppos]);
> plan->e_ppos = plan->e_pbnum;
> plan->e_psize = plan->e_pbsize;
> }
581c607,608
< int cnt;
---
> long argmax;
> int cnt, i;
597a625,628
> if (**ap == '+' && ap != argv && strcmp(*(ap - 1), "{}") == 0) {
> new->flags |= F_EXECPLUS;
> break;
> }
603a635,650
> if (new->flags & F_EXECPLUS) {
> new->e_ppos = new->e_pbnum = cnt - 2;
> if ((argmax = sysconf(_SC_ARG_MAX)) == -1) {
> warn("sysconf(_SC_ARG_MAX)");
> argmax = _POSIX_ARG_MAX;
> }
> /*
> * Estimate the maximum number of arguments as {ARG_MAX}/10,
> * and the maximum number of bytes to use for arguments as
> * {ARG_MAX}*(3/4).
> */
> new->e_pnummax = argmax / 10;
> new->e_psizemax = (argmax / 4) * 3;
> new->e_pbsize = 0;
> cnt += new->e_pnummax + 1;
> }
612a660,661
> if (new->flags & F_EXECPLUS)
> new->e_pbsize += strlen(*argv) + 1;
614c663,664
< if (p[0] == '{' && p[1] == '}') {
---
> if (!(new->flags & F_EXECPLUS) && p[0] == '{' &&
> p[1] == '}') {
625a676,686
> if (new->flags & F_EXECPLUS) {
> new->e_psize = new->e_pbsize;
> cnt--;
> for (i = 0; i < new->e_pnummax; i++) {
> new->e_argv[cnt] = NULL;
> new->e_len[cnt] = 0;
> cnt++;
> }
> argv = ap;
> goto done;
> }
628c689
< *argvp = argv + 1;
---
> done: *argvp = argv + 1;