summaryrefslogtreecommitdiff
path: root/findutils/find.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-04-21 11:09:40 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-04-21 11:09:40 +0000
commit5e34ff29bcc870936ab18172f438a34d042d4e03 (patch)
treea5e7a528f2f916eb883f1161eadceacdf2dca4be /findutils/find.c
parent8b814b4a349e2262c0ad25793b05206a14651ebb (diff)
downloadbusybox-w32-5e34ff29bcc870936ab18172f438a34d042d4e03.tar.gz
busybox-w32-5e34ff29bcc870936ab18172f438a34d042d4e03.tar.bz2
busybox-w32-5e34ff29bcc870936ab18172f438a34d042d4e03.zip
*: mass renaming of USE_XXXX to IF_XXXX
and SKIP_XXXX to IF_NOT_XXXX - the second one was especially badly named. It was not skipping anything!
Diffstat (limited to 'findutils/find.c')
-rw-r--r--findutils/find.c150
1 files changed, 75 insertions, 75 deletions
diff --git a/findutils/find.c b/findutils/find.c
index df632f219..da024afbf 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -62,8 +62,8 @@
62/* This is a NOEXEC applet. Be very careful! */ 62/* This is a NOEXEC applet. Be very careful! */
63 63
64 64
65USE_FEATURE_FIND_XDEV(static dev_t *xdev_dev;) 65IF_FEATURE_FIND_XDEV(static dev_t *xdev_dev;)
66USE_FEATURE_FIND_XDEV(static int xdev_count;) 66IF_FEATURE_FIND_XDEV(static int xdev_count;)
67 67
68typedef int (*action_fp)(const char *fileName, struct stat *statbuf, void *); 68typedef int (*action_fp)(const char *fileName, struct stat *statbuf, void *);
69 69
@@ -79,23 +79,23 @@ typedef struct {
79 action_##name* ap UNUSED_PARAM) 79 action_##name* ap UNUSED_PARAM)
80 ACTS(print) 80 ACTS(print)
81 ACTS(name, const char *pattern; bool iname;) 81 ACTS(name, const char *pattern; bool iname;)
82USE_FEATURE_FIND_PATH( ACTS(path, const char *pattern;)) 82IF_FEATURE_FIND_PATH( ACTS(path, const char *pattern;))
83USE_FEATURE_FIND_REGEX( ACTS(regex, regex_t compiled_pattern;)) 83IF_FEATURE_FIND_REGEX( ACTS(regex, regex_t compiled_pattern;))
84USE_FEATURE_FIND_PRINT0( ACTS(print0)) 84IF_FEATURE_FIND_PRINT0( ACTS(print0))
85USE_FEATURE_FIND_TYPE( ACTS(type, int type_mask;)) 85IF_FEATURE_FIND_TYPE( ACTS(type, int type_mask;))
86USE_FEATURE_FIND_PERM( ACTS(perm, char perm_char; mode_t perm_mask;)) 86IF_FEATURE_FIND_PERM( ACTS(perm, char perm_char; mode_t perm_mask;))
87USE_FEATURE_FIND_MTIME( ACTS(mtime, char mtime_char; unsigned mtime_days;)) 87IF_FEATURE_FIND_MTIME( ACTS(mtime, char mtime_char; unsigned mtime_days;))
88USE_FEATURE_FIND_MMIN( ACTS(mmin, char mmin_char; unsigned mmin_mins;)) 88IF_FEATURE_FIND_MMIN( ACTS(mmin, char mmin_char; unsigned mmin_mins;))
89USE_FEATURE_FIND_NEWER( ACTS(newer, time_t newer_mtime;)) 89IF_FEATURE_FIND_NEWER( ACTS(newer, time_t newer_mtime;))
90USE_FEATURE_FIND_INUM( ACTS(inum, ino_t inode_num;)) 90IF_FEATURE_FIND_INUM( ACTS(inum, ino_t inode_num;))
91USE_FEATURE_FIND_USER( ACTS(user, uid_t uid;)) 91IF_FEATURE_FIND_USER( ACTS(user, uid_t uid;))
92USE_FEATURE_FIND_SIZE( ACTS(size, char size_char; off_t size;)) 92IF_FEATURE_FIND_SIZE( ACTS(size, char size_char; off_t size;))
93USE_FEATURE_FIND_CONTEXT(ACTS(context, security_context_t context;)) 93IF_FEATURE_FIND_CONTEXT(ACTS(context, security_context_t context;))
94USE_FEATURE_FIND_PAREN( ACTS(paren, action ***subexpr;)) 94IF_FEATURE_FIND_PAREN( ACTS(paren, action ***subexpr;))
95USE_FEATURE_FIND_PRUNE( ACTS(prune)) 95IF_FEATURE_FIND_PRUNE( ACTS(prune))
96USE_FEATURE_FIND_DELETE( ACTS(delete)) 96IF_FEATURE_FIND_DELETE( ACTS(delete))
97USE_FEATURE_FIND_EXEC( ACTS(exec, char **exec_argv; unsigned *subst_count; int exec_argc;)) 97IF_FEATURE_FIND_EXEC( ACTS(exec, char **exec_argv; unsigned *subst_count; int exec_argc;))
98USE_FEATURE_FIND_GROUP( ACTS(group, gid_t gid;)) 98IF_FEATURE_FIND_GROUP( ACTS(group, gid_t gid;))
99 99
100static action ***actions; 100static action ***actions;
101static bool need_print = 1; 101static bool need_print = 1;
@@ -376,8 +376,8 @@ ACTF(context)
376 376
377static int FAST_FUNC fileAction(const char *fileName, 377static int FAST_FUNC fileAction(const char *fileName,
378 struct stat *statbuf, 378 struct stat *statbuf,
379 void *userData SKIP_FEATURE_FIND_MAXDEPTH(UNUSED_PARAM), 379 void *userData IF_NOT_FEATURE_FIND_MAXDEPTH(UNUSED_PARAM),
380 int depth SKIP_FEATURE_FIND_MAXDEPTH(UNUSED_PARAM)) 380 int depth IF_NOT_FEATURE_FIND_MAXDEPTH(UNUSED_PARAM))
381{ 381{
382 int i; 382 int i;
383#if ENABLE_FEATURE_FIND_MAXDEPTH 383#if ENABLE_FEATURE_FIND_MAXDEPTH
@@ -451,73 +451,73 @@ static action*** parse_params(char **argv)
451 enum { 451 enum {
452 PARM_a , 452 PARM_a ,
453 PARM_o , 453 PARM_o ,
454 USE_FEATURE_FIND_NOT( PARM_char_not ,) 454 IF_FEATURE_FIND_NOT( PARM_char_not ,)
455#if ENABLE_DESKTOP 455#if ENABLE_DESKTOP
456 PARM_and , 456 PARM_and ,
457 PARM_or , 457 PARM_or ,
458 USE_FEATURE_FIND_NOT( PARM_not ,) 458 IF_FEATURE_FIND_NOT( PARM_not ,)
459#endif 459#endif
460 PARM_print , 460 PARM_print ,
461 USE_FEATURE_FIND_PRINT0( PARM_print0 ,) 461 IF_FEATURE_FIND_PRINT0( PARM_print0 ,)
462 USE_FEATURE_FIND_DEPTH( PARM_depth ,) 462 IF_FEATURE_FIND_DEPTH( PARM_depth ,)
463 USE_FEATURE_FIND_PRUNE( PARM_prune ,) 463 IF_FEATURE_FIND_PRUNE( PARM_prune ,)
464 USE_FEATURE_FIND_DELETE( PARM_delete ,) 464 IF_FEATURE_FIND_DELETE( PARM_delete ,)
465 USE_FEATURE_FIND_EXEC( PARM_exec ,) 465 IF_FEATURE_FIND_EXEC( PARM_exec ,)
466 USE_FEATURE_FIND_PAREN( PARM_char_brace,) 466 IF_FEATURE_FIND_PAREN( PARM_char_brace,)
467 /* All options starting from here require argument */ 467 /* All options starting from here require argument */
468 PARM_name , 468 PARM_name ,
469 PARM_iname , 469 PARM_iname ,
470 USE_FEATURE_FIND_PATH( PARM_path ,) 470 IF_FEATURE_FIND_PATH( PARM_path ,)
471 USE_FEATURE_FIND_REGEX( PARM_regex ,) 471 IF_FEATURE_FIND_REGEX( PARM_regex ,)
472 USE_FEATURE_FIND_TYPE( PARM_type ,) 472 IF_FEATURE_FIND_TYPE( PARM_type ,)
473 USE_FEATURE_FIND_PERM( PARM_perm ,) 473 IF_FEATURE_FIND_PERM( PARM_perm ,)
474 USE_FEATURE_FIND_MTIME( PARM_mtime ,) 474 IF_FEATURE_FIND_MTIME( PARM_mtime ,)
475 USE_FEATURE_FIND_MMIN( PARM_mmin ,) 475 IF_FEATURE_FIND_MMIN( PARM_mmin ,)
476 USE_FEATURE_FIND_NEWER( PARM_newer ,) 476 IF_FEATURE_FIND_NEWER( PARM_newer ,)
477 USE_FEATURE_FIND_INUM( PARM_inum ,) 477 IF_FEATURE_FIND_INUM( PARM_inum ,)
478 USE_FEATURE_FIND_USER( PARM_user ,) 478 IF_FEATURE_FIND_USER( PARM_user ,)
479 USE_FEATURE_FIND_GROUP( PARM_group ,) 479 IF_FEATURE_FIND_GROUP( PARM_group ,)
480 USE_FEATURE_FIND_SIZE( PARM_size ,) 480 IF_FEATURE_FIND_SIZE( PARM_size ,)
481 USE_FEATURE_FIND_CONTEXT(PARM_context ,) 481 IF_FEATURE_FIND_CONTEXT(PARM_context ,)
482 }; 482 };
483 483
484 static const char params[] ALIGN1 = 484 static const char params[] ALIGN1 =
485 "-a\0" 485 "-a\0"
486 "-o\0" 486 "-o\0"
487 USE_FEATURE_FIND_NOT( "!\0" ) 487 IF_FEATURE_FIND_NOT( "!\0" )
488#if ENABLE_DESKTOP 488#if ENABLE_DESKTOP
489 "-and\0" 489 "-and\0"
490 "-or\0" 490 "-or\0"
491 USE_FEATURE_FIND_NOT( "-not\0" ) 491 IF_FEATURE_FIND_NOT( "-not\0" )
492#endif 492#endif
493 "-print\0" 493 "-print\0"
494 USE_FEATURE_FIND_PRINT0( "-print0\0" ) 494 IF_FEATURE_FIND_PRINT0( "-print0\0" )
495 USE_FEATURE_FIND_DEPTH( "-depth\0" ) 495 IF_FEATURE_FIND_DEPTH( "-depth\0" )
496 USE_FEATURE_FIND_PRUNE( "-prune\0" ) 496 IF_FEATURE_FIND_PRUNE( "-prune\0" )
497 USE_FEATURE_FIND_DELETE( "-delete\0" ) 497 IF_FEATURE_FIND_DELETE( "-delete\0" )
498 USE_FEATURE_FIND_EXEC( "-exec\0" ) 498 IF_FEATURE_FIND_EXEC( "-exec\0" )
499 USE_FEATURE_FIND_PAREN( "(\0" ) 499 IF_FEATURE_FIND_PAREN( "(\0" )
500 /* All options starting from here require argument */ 500 /* All options starting from here require argument */
501 "-name\0" 501 "-name\0"
502 "-iname\0" 502 "-iname\0"
503 USE_FEATURE_FIND_PATH( "-path\0" ) 503 IF_FEATURE_FIND_PATH( "-path\0" )
504 USE_FEATURE_FIND_REGEX( "-regex\0" ) 504 IF_FEATURE_FIND_REGEX( "-regex\0" )
505 USE_FEATURE_FIND_TYPE( "-type\0" ) 505 IF_FEATURE_FIND_TYPE( "-type\0" )
506 USE_FEATURE_FIND_PERM( "-perm\0" ) 506 IF_FEATURE_FIND_PERM( "-perm\0" )
507 USE_FEATURE_FIND_MTIME( "-mtime\0" ) 507 IF_FEATURE_FIND_MTIME( "-mtime\0" )
508 USE_FEATURE_FIND_MMIN( "-mmin\0" ) 508 IF_FEATURE_FIND_MMIN( "-mmin\0" )
509 USE_FEATURE_FIND_NEWER( "-newer\0" ) 509 IF_FEATURE_FIND_NEWER( "-newer\0" )
510 USE_FEATURE_FIND_INUM( "-inum\0" ) 510 IF_FEATURE_FIND_INUM( "-inum\0" )
511 USE_FEATURE_FIND_USER( "-user\0" ) 511 IF_FEATURE_FIND_USER( "-user\0" )
512 USE_FEATURE_FIND_GROUP( "-group\0" ) 512 IF_FEATURE_FIND_GROUP( "-group\0" )
513 USE_FEATURE_FIND_SIZE( "-size\0" ) 513 IF_FEATURE_FIND_SIZE( "-size\0" )
514 USE_FEATURE_FIND_CONTEXT("-context\0") 514 IF_FEATURE_FIND_CONTEXT("-context\0")
515 ; 515 ;
516 516
517 action*** appp; 517 action*** appp;
518 unsigned cur_group = 0; 518 unsigned cur_group = 0;
519 unsigned cur_action = 0; 519 unsigned cur_action = 0;
520 USE_FEATURE_FIND_NOT( bool invert_flag = 0; ) 520 IF_FEATURE_FIND_NOT( bool invert_flag = 0; )
521 521
522 /* This is the only place in busybox where we use nested function. 522 /* This is the only place in busybox where we use nested function.
523 * So far more standard alternatives were bigger. */ 523 * So far more standard alternatives were bigger. */
@@ -530,8 +530,8 @@ static action*** parse_params(char **argv)
530 appp[cur_group][cur_action++] = ap = xmalloc(sizeof_struct); 530 appp[cur_group][cur_action++] = ap = xmalloc(sizeof_struct);
531 appp[cur_group][cur_action] = NULL; 531 appp[cur_group][cur_action] = NULL;
532 ap->f = f; 532 ap->f = f;
533 USE_FEATURE_FIND_NOT( ap->invert = invert_flag; ) 533 IF_FEATURE_FIND_NOT( ap->invert = invert_flag; )
534 USE_FEATURE_FIND_NOT( invert_flag = 0; ) 534 IF_FEATURE_FIND_NOT( invert_flag = 0; )
535 return ap; 535 return ap;
536 } 536 }
537 537
@@ -569,10 +569,10 @@ static action*** parse_params(char **argv)
569 * it doesn't give smaller code. Other arches? */ 569 * it doesn't give smaller code. Other arches? */
570 570
571 /* --- Operators --- */ 571 /* --- Operators --- */
572 if (parm == PARM_a USE_DESKTOP(|| parm == PARM_and)) { 572 if (parm == PARM_a IF_DESKTOP(|| parm == PARM_and)) {
573 /* no further special handling required */ 573 /* no further special handling required */
574 } 574 }
575 else if (parm == PARM_o USE_DESKTOP(|| parm == PARM_or)) { 575 else if (parm == PARM_o IF_DESKTOP(|| parm == PARM_or)) {
576 /* start new OR group */ 576 /* start new OR group */
577 cur_group++; 577 cur_group++;
578 appp = xrealloc(appp, (cur_group+2) * sizeof(*appp)); 578 appp = xrealloc(appp, (cur_group+2) * sizeof(*appp));
@@ -581,7 +581,7 @@ static action*** parse_params(char **argv)
581 cur_action = 0; 581 cur_action = 0;
582 } 582 }
583#if ENABLE_FEATURE_FIND_NOT 583#if ENABLE_FEATURE_FIND_NOT
584 else if (parm == PARM_char_not USE_DESKTOP(|| parm == PARM_not)) { 584 else if (parm == PARM_char_not IF_DESKTOP(|| parm == PARM_not)) {
585 /* also handles "find ! ! -name 'foo*'" */ 585 /* also handles "find ! ! -name 'foo*'" */
586 invert_flag ^= 1; 586 invert_flag ^= 1;
587 } 587 }
@@ -591,13 +591,13 @@ static action*** parse_params(char **argv)
591 else if (parm == PARM_print) { 591 else if (parm == PARM_print) {
592 need_print = 0; 592 need_print = 0;
593 /* GNU find ignores '!' here: "find ! -print" */ 593 /* GNU find ignores '!' here: "find ! -print" */
594 USE_FEATURE_FIND_NOT( invert_flag = 0; ) 594 IF_FEATURE_FIND_NOT( invert_flag = 0; )
595 (void) ALLOC_ACTION(print); 595 (void) ALLOC_ACTION(print);
596 } 596 }
597#if ENABLE_FEATURE_FIND_PRINT0 597#if ENABLE_FEATURE_FIND_PRINT0
598 else if (parm == PARM_print0) { 598 else if (parm == PARM_print0) {
599 need_print = 0; 599 need_print = 0;
600 USE_FEATURE_FIND_NOT( invert_flag = 0; ) 600 IF_FEATURE_FIND_NOT( invert_flag = 0; )
601 (void) ALLOC_ACTION(print0); 601 (void) ALLOC_ACTION(print0);
602 } 602 }
603#endif 603#endif
@@ -608,7 +608,7 @@ static action*** parse_params(char **argv)
608#endif 608#endif
609#if ENABLE_FEATURE_FIND_PRUNE 609#if ENABLE_FEATURE_FIND_PRUNE
610 else if (parm == PARM_prune) { 610 else if (parm == PARM_prune) {
611 USE_FEATURE_FIND_NOT( invert_flag = 0; ) 611 IF_FEATURE_FIND_NOT( invert_flag = 0; )
612 (void) ALLOC_ACTION(prune); 612 (void) ALLOC_ACTION(prune);
613 } 613 }
614#endif 614#endif
@@ -624,7 +624,7 @@ static action*** parse_params(char **argv)
624 int i; 624 int i;
625 action_exec *ap; 625 action_exec *ap;
626 need_print = 0; 626 need_print = 0;
627 USE_FEATURE_FIND_NOT( invert_flag = 0; ) 627 IF_FEATURE_FIND_NOT( invert_flag = 0; )
628 ap = ALLOC_ACTION(exec); 628 ap = ALLOC_ACTION(exec);
629 ap->exec_argv = ++argv; /* first arg after -exec */ 629 ap->exec_argv = ++argv; /* first arg after -exec */
630 ap->exec_argc = 0; 630 ap->exec_argc = 0;
@@ -813,13 +813,13 @@ int find_main(int argc, char **argv)
813{ 813{
814 static const char options[] ALIGN1 = 814 static const char options[] ALIGN1 =
815 "-follow\0" 815 "-follow\0"
816USE_FEATURE_FIND_XDEV( "-xdev\0" ) 816IF_FEATURE_FIND_XDEV( "-xdev\0" )
817USE_FEATURE_FIND_MAXDEPTH("-mindepth\0""-maxdepth\0") 817IF_FEATURE_FIND_MAXDEPTH("-mindepth\0""-maxdepth\0")
818 ; 818 ;
819 enum { 819 enum {
820 OPT_FOLLOW, 820 OPT_FOLLOW,
821USE_FEATURE_FIND_XDEV( OPT_XDEV ,) 821IF_FEATURE_FIND_XDEV( OPT_XDEV ,)
822USE_FEATURE_FIND_MAXDEPTH(OPT_MINDEPTH,) 822IF_FEATURE_FIND_MAXDEPTH(OPT_MINDEPTH,)
823 }; 823 };
824 824
825 char *arg; 825 char *arg;