From a873444aa3e57d05c639c849a41a2add146f0309 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 18 Jul 2014 18:31:41 -0500 Subject: Find bugfixes. The check for -print vs -print0 was tested before I optimized out the "-" in the strcmps, and I didn't adjust the offset or retest it. (Ooops.) Also, I wasn't clearing the ! value when descending into parentheticals, so "find . -name blah -o \! \( -stuff -o -thing \)" acted like it had a spurious second ! before -stuff inside the parentheses. --- toys/posix/find.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'toys/posix/find.c') diff --git a/toys/posix/find.c b/toys/posix/find.c index cd9da924..873f83cb 100644 --- a/toys/posix/find.c +++ b/toys/posix/find.c @@ -143,6 +143,7 @@ static int do_find(struct dirtree *new) if (pcount == sizeof(toybuf)) goto error; toybuf[pcount++] = not+(active<<1); if (!check) active = 0; + not = 0; // Pop status, apply deferred not to test } else if (*s == ')') { @@ -171,7 +172,7 @@ static int do_find(struct dirtree *new) } else if (!strcmp(s, "print") || !strcmp("print0", s)) { print++; - if (check) do_print(new, s[6] ? 0 : '\n'); + if (check) do_print(new, s[5] ? 0 : '\n'); } else if (!strcmp(s, "nouser")) { if (check) if (getpwuid(new->st.st_uid)) test = 0; -- cgit v1.2.3