aboutsummaryrefslogtreecommitdiff
path: root/findutils/find.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-07-24 15:54:42 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-07-24 15:54:42 +0000
commit990d0f63eeb502c8762076e5c5499196e09cba55 (patch)
tree30a2091a8159b1694d65f9952e2aba2667d7dc11 /findutils/find.c
parentbcb66ec22e82f6b1ab93f3aec917269393a5b464 (diff)
downloadbusybox-w32-990d0f63eeb502c8762076e5c5499196e09cba55.tar.gz
busybox-w32-990d0f63eeb502c8762076e5c5499196e09cba55.tar.bz2
busybox-w32-990d0f63eeb502c8762076e5c5499196e09cba55.zip
Replace index_in_[sub]str_array with index_in_[sub]strings,
which scans thru "abc\0def\0123\0\0" type strings. Saves 250 bytes. text data bss dec hex filename 781266 1328 11844 794438 c1f46 busybox_old 781010 1328 11844 794182 c1e46 busybox_unstripped
Diffstat (limited to 'findutils/find.c')
-rw-r--r--findutils/find.c76
1 files changed, 37 insertions, 39 deletions
diff --git a/findutils/find.c b/findutils/find.c
index 6f2cbbc78..eaf1d5946 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -470,38 +470,37 @@ static action*** parse_params(char **argv)
470 USE_FEATURE_FIND_CONTEXT(PARM_context ,) 470 USE_FEATURE_FIND_CONTEXT(PARM_context ,)
471 }; 471 };
472 472
473 static const char *const params[] = { 473 static const char params[] =
474 "-a" , 474 "-a\0"
475 "-o" , 475 "-o\0"
476 USE_FEATURE_FIND_NOT( "!" ,) 476 USE_FEATURE_FIND_NOT( "!\0" )
477#if ENABLE_DESKTOP 477#if ENABLE_DESKTOP
478 "-and" , 478 "-and\0"
479 "-or" , 479 "-or\0"
480 USE_FEATURE_FIND_NOT( "-not" ,) 480 USE_FEATURE_FIND_NOT( "-not\0" )
481#endif 481#endif
482 "-print" , 482 "-print\0"
483 USE_FEATURE_FIND_PRINT0( "-print0" ,) 483 USE_FEATURE_FIND_PRINT0( "-print0\0" )
484 USE_FEATURE_FIND_DEPTH( "-depth" ,) 484 USE_FEATURE_FIND_DEPTH( "-depth\0" )
485 USE_FEATURE_FIND_PRUNE( "-prune" ,) 485 USE_FEATURE_FIND_PRUNE( "-prune\0" )
486 USE_FEATURE_FIND_DELETE( "-delete" ,) 486 USE_FEATURE_FIND_DELETE( "-delete\0" )
487 USE_FEATURE_FIND_EXEC( "-exec" ,) 487 USE_FEATURE_FIND_EXEC( "-exec\0" )
488 USE_FEATURE_FIND_PAREN( "(" ,) 488 USE_FEATURE_FIND_PAREN( "(\0" )
489 /* All options starting from here require argument */ 489 /* All options starting from here require argument */
490 "-name" , 490 "-name\0"
491 USE_FEATURE_FIND_PATH( "-path" ,) 491 USE_FEATURE_FIND_PATH( "-path\0" )
492 USE_FEATURE_FIND_REGEX( "-regex" ,) 492 USE_FEATURE_FIND_REGEX( "-regex\0" )
493 USE_FEATURE_FIND_TYPE( "-type" ,) 493 USE_FEATURE_FIND_TYPE( "-type\0" )
494 USE_FEATURE_FIND_PERM( "-perm" ,) 494 USE_FEATURE_FIND_PERM( "-perm\0" )
495 USE_FEATURE_FIND_MTIME( "-mtime" ,) 495 USE_FEATURE_FIND_MTIME( "-mtime\0" )
496 USE_FEATURE_FIND_MMIN( "-mmin" ,) 496 USE_FEATURE_FIND_MMIN( "-mmin\0" )
497 USE_FEATURE_FIND_NEWER( "-newer" ,) 497 USE_FEATURE_FIND_NEWER( "-newer\0" )
498 USE_FEATURE_FIND_INUM( "-inum" ,) 498 USE_FEATURE_FIND_INUM( "-inum\0" )
499 USE_FEATURE_FIND_USER( "-user" ,) 499 USE_FEATURE_FIND_USER( "-user\0" )
500 USE_FEATURE_FIND_GROUP( "-group" ,) 500 USE_FEATURE_FIND_GROUP( "-group\0" )
501 USE_FEATURE_FIND_SIZE( "-size" ,) 501 USE_FEATURE_FIND_SIZE( "-size\0" )
502 USE_FEATURE_FIND_CONTEXT("-context",) 502 USE_FEATURE_FIND_CONTEXT("-context\0")
503 NULL 503 ;
504 };
505 504
506 action*** appp; 505 action*** appp;
507 unsigned cur_group = 0; 506 unsigned cur_group = 0;
@@ -541,7 +540,7 @@ static action*** parse_params(char **argv)
541 */ 540 */
542 while (*argv) { 541 while (*argv) {
543 const char *arg = argv[0]; 542 const char *arg = argv[0];
544 int parm = index_in_str_array(params, arg); 543 int parm = index_in_strings(params, arg);
545 const char *arg1 = argv[1]; 544 const char *arg1 = argv[1];
546 545
547 if (parm >= PARM_name) { 546 if (parm >= PARM_name) {
@@ -795,14 +794,13 @@ static action*** parse_params(char **argv)
795int find_main(int argc, char **argv); 794int find_main(int argc, char **argv);
796int find_main(int argc, char **argv) 795int find_main(int argc, char **argv)
797{ 796{
798 static const char *const options[] = { 797 static const char options[] =
799 "-follow", 798 "-follow\0"
800USE_FEATURE_FIND_XDEV( "-xdev" ,) 799USE_FEATURE_FIND_XDEV( "-xdev\0" )
801USE_FEATURE_FIND_MAXDEPTH("-maxdepth",) 800USE_FEATURE_FIND_MAXDEPTH("-maxdepth\0")
802 NULL 801 ;
803 };
804 enum { 802 enum {
805 OPT_FOLLOW, 803 OPT_FOLLOW,
806USE_FEATURE_FIND_XDEV( OPT_XDEV ,) 804USE_FEATURE_FIND_XDEV( OPT_XDEV ,)
807USE_FEATURE_FIND_MAXDEPTH(OPT_MAXDEPTH,) 805USE_FEATURE_FIND_MAXDEPTH(OPT_MAXDEPTH,)
808 }; 806 };
@@ -839,7 +837,7 @@ USE_FEATURE_FIND_MAXDEPTH(OPT_MAXDEPTH,)
839 /* (-a will be ignored by recursive parser later) */ 837 /* (-a will be ignored by recursive parser later) */
840 argp = &argv[firstopt]; 838 argp = &argv[firstopt];
841 while ((arg = argp[0])) { 839 while ((arg = argp[0])) {
842 int opt = index_in_str_array(options, arg); 840 int opt = index_in_strings(options, arg);
843 if (opt == OPT_FOLLOW) { 841 if (opt == OPT_FOLLOW) {
844 recurse_flags |= ACTION_FOLLOWLINKS; 842 recurse_flags |= ACTION_FOLLOWLINKS;
845 argp[0] = (char*)"-a"; 843 argp[0] = (char*)"-a";