aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-10-01 20:27:28 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2020-10-01 20:27:28 +0200
commit3c3928fc658bddacd4e540589868bc28a8e4ca0a (patch)
treeed201a577877cf45911983def13513d8f6b91ef8
parent4a0eb0370c4df8ee01973b50bb460560532b79f1 (diff)
downloadbusybox-w32-3c3928fc658bddacd4e540589868bc28a8e4ca0a.tar.gz
busybox-w32-3c3928fc658bddacd4e540589868bc28a8e4ca0a.tar.bz2
busybox-w32-3c3928fc658bddacd4e540589868bc28a8e4ca0a.zip
tydy up a few uses of recursive_action(), no logic changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--debianutils/run_parts.c8
-rw-r--r--findutils/grep.c13
-rw-r--r--include/libbb.h6
3 files changed, 14 insertions, 13 deletions
diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c
index c80cc863f..196e0640d 100644
--- a/debianutils/run_parts.c
+++ b/debianutils/run_parts.c
@@ -133,10 +133,10 @@ static int bb_alphasort(const void *p1, const void *p2)
133 133
134static int FAST_FUNC act(const char *file, struct stat *statbuf, void *args UNUSED_PARAM, int depth) 134static int FAST_FUNC act(const char *file, struct stat *statbuf, void *args UNUSED_PARAM, int depth)
135{ 135{
136 if (depth == 1) 136 if (depth == 0)
137 return TRUE; 137 return TRUE;
138 138
139 if (depth == 2 139 if (depth == 1
140 && ( !(statbuf->st_mode & (S_IFREG | S_IFLNK)) 140 && ( !(statbuf->st_mode & (S_IFREG | S_IFLNK))
141 || invalid_name(file) 141 || invalid_name(file)
142 || (!(option_mask32 & OPT_l) && access(file, X_OK) != 0)) 142 || (!(option_mask32 & OPT_l) && access(file, X_OK) != 0))
@@ -200,8 +200,8 @@ int run_parts_main(int argc UNUSED_PARAM, char **argv)
200 act, /* file action */ 200 act, /* file action */
201 act, /* dir action */ 201 act, /* dir action */
202 NULL, /* user data */ 202 NULL, /* user data */
203 1 /* depth */ 203 0 /* depth */
204 ); 204 );
205 205
206 if (!names) 206 if (!names)
207 return 0; 207 return 0;
diff --git a/findutils/grep.c b/findutils/grep.c
index b456ed467..0892a713a 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -694,15 +694,16 @@ static int FAST_FUNC file_action_grep(const char *filename,
694static int grep_dir(const char *dir) 694static int grep_dir(const char *dir)
695{ 695{
696 int matched = 0; 696 int matched = 0;
697 recursive_action(dir, 697 recursive_action(dir, 0
698 /* recurse=yes */ ACTION_RECURSE | 698 | ACTION_RECURSE
699 /* followLinks=always */ ((option_mask32 & OPT_R) ? ACTION_FOLLOWLINKS : 0) | 699 | ((option_mask32 & OPT_R) ? ACTION_FOLLOWLINKS : 0)
700 /* followLinks=command line only */ ACTION_FOLLOWLINKS_L0 | 700 | ACTION_FOLLOWLINKS_L0 /* grep -r ... SYMLINK follows it */
701 /* depthFirst=yes */ ACTION_DEPTHFIRST, 701 | ACTION_DEPTHFIRST
702 | 0,
702 /* fileAction= */ file_action_grep, 703 /* fileAction= */ file_action_grep,
703 /* dirAction= */ NULL, 704 /* dirAction= */ NULL,
704 /* userData= */ &matched, 705 /* userData= */ &matched,
705 /* depth= */ 0); 706 0);
706 return matched; 707 return matched;
707} 708}
708 709
diff --git a/include/libbb.h b/include/libbb.h
index 3e23b5bbd..8b84d13a0 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -437,15 +437,15 @@ enum {
437 ACTION_FOLLOWLINKS = (1 << 1), 437 ACTION_FOLLOWLINKS = (1 << 1),
438 ACTION_FOLLOWLINKS_L0 = (1 << 2), 438 ACTION_FOLLOWLINKS_L0 = (1 << 2),
439 ACTION_DEPTHFIRST = (1 << 3), 439 ACTION_DEPTHFIRST = (1 << 3),
440 /*ACTION_REVERSE = (1 << 4), - unused */ 440 ACTION_QUIET = (1 << 4),
441 ACTION_QUIET = (1 << 5), 441 ACTION_DANGLING_OK = (1 << 5),
442 ACTION_DANGLING_OK = (1 << 6),
443}; 442};
444typedef uint8_t recurse_flags_t; 443typedef uint8_t recurse_flags_t;
445extern int recursive_action(const char *fileName, unsigned flags, 444extern int recursive_action(const char *fileName, unsigned flags,
446 int FAST_FUNC (*fileAction)(const char *fileName, struct stat* statbuf, void* userData, int depth), 445 int FAST_FUNC (*fileAction)(const char *fileName, struct stat* statbuf, void* userData, int depth),
447 int FAST_FUNC (*dirAction)(const char *fileName, struct stat* statbuf, void* userData, int depth), 446 int FAST_FUNC (*dirAction)(const char *fileName, struct stat* statbuf, void* userData, int depth),
448 void* userData, unsigned depth) FAST_FUNC; 447 void* userData, unsigned depth) FAST_FUNC;
448
449extern int device_open(const char *device, int mode) FAST_FUNC; 449extern int device_open(const char *device, int mode) FAST_FUNC;
450enum { GETPTY_BUFSIZE = 16 }; /* more than enough for "/dev/ttyXXX" */ 450enum { GETPTY_BUFSIZE = 16 }; /* more than enough for "/dev/ttyXXX" */
451extern int xgetpty(char *line) FAST_FUNC; 451extern int xgetpty(char *line) FAST_FUNC;