[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH] find: fix -exec + flush with parens
From:       "Alex Xu (Hello71)" <alex_y_xu () yahoo ! ca>
Date:       2021-12-10 15:01:07
Message-ID: 20211210150107.134564-1-alex_y_xu () yahoo ! ca
[Download RAW message or body]

With CONFIG_FEATURE_FIND_PAREN=y:

function                                             old     new   delta
find_main                                            598     618     +20

With CONFIG_FEATURE_FIND_PAREN=n, no change.

Fixes https://bugs.busybox.net/show_bug.cgi?id=12881.
---
 findutils/find.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/findutils/find.c b/findutils/find.c
index fdc5c152d..0d1be36bc 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -560,6 +560,12 @@ static char *strcpy_upcase(char *dst, const char *src)
 }
 #endif
 
+#if ENABLE_FEATURE_FIND_PAREN
+ACTF(paren)
+{
+	return exec_actions(ap->subexpr, fileName, statbuf);
+}
+#endif
 ACTF(name)
 {
 	int r;
@@ -812,11 +818,10 @@ ACTF(exec)
 	return do_exec(ap, fileName);
 }
 # if ENABLE_FEATURE_FIND_EXEC_PLUS
-static int flush_exec_plus(void)
+static int flush_exec_plus(action ***appp)
 {
 	action *ap;
 	action **app;
-	action ***appp = G.actions;
 	while ((app = *appp++) != NULL) {
 		while ((ap = *app++) != NULL) {
 			if (ap->f == (action_fp)func_exec) {
@@ -830,6 +835,11 @@ static int flush_exec_plus(void)
 						return 1;
 				}
 			}
+#  if ENABLE_FEATURE_FIND_PAREN
+			if (ap->f == (action_fp)func_paren) {
+				return flush_exec_plus(((action_paren *)ap)->subexpr);
+			}
+#  endif
 		}
 	}
 	return 0;
@@ -860,12 +870,6 @@ ACTF(print)
 	puts(fileName);
 	return TRUE;
 }
-#if ENABLE_FEATURE_FIND_PAREN
-ACTF(paren)
-{
-	return exec_actions(ap->subexpr, fileName, statbuf);
-}
-#endif
 #if ENABLE_FEATURE_FIND_SIZE
 ACTF(size)
 {
@@ -1679,6 +1683,6 @@ int find_main(int argc UNUSED_PARAM, char **argv)
 		}
 	}
 
-	IF_FEATURE_FIND_EXEC_PLUS(G.exitstatus |= flush_exec_plus();)
+	IF_FEATURE_FIND_EXEC_PLUS(G.exitstatus |= flush_exec_plus(G.actions);)
 	return G.exitstatus;
 }
-- 
2.34.1

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic