--- findutils-4.1.20/find/defs.h.jj 2003-05-26 15:37:29.000000000 +0200 +++ findutils-4.1.20/find/defs.h 2004-03-29 17:49:23.000000000 +0200 @@ -255,8 +255,12 @@ struct predicate /* True if this predicate node requires default print be turned off. */ boolean no_default_print; - /* True if this predicate node requires a stat system call to execute. */ - boolean need_stat; + /* PRED_NEED_STAT if this predicate node requires a stat system + call to execute, PRED_NEED_TYPE if either stat or valid DT_* file + type is needed. */ +#define PRED_NEED_STAT 3 +#define PRED_NEED_TYPE 1 + char need_stat; /* Information needed by the predicate processor. Next to each member are listed the predicates that use it. */ --- findutils-4.1.20/find/tree.c.jj 2003-05-24 20:36:25.000000000 +0200 +++ findutils-4.1.20/find/tree.c 2004-03-30 16:43:06.230089167 +0200 @@ -356,7 +356,7 @@ set_new_parent (struct predicate *curr, new_parent = (struct predicate *) xmalloc (sizeof (struct predicate)); new_parent->p_type = BI_OP; new_parent->p_prec = high_prec; - new_parent->need_stat = false; + new_parent->need_stat = 0; switch (high_prec) { @@ -408,10 +408,10 @@ merge_pred (struct predicate *beg_list, get executed (because the expression value is determined earlier.) So every expression needing stat must be marked as such, not just the earliest, to be sure to obtain the stat. This still guarantees - that a stat is made as late as possible. Return true if the top node - in TREE requires a stat, false if not. */ + that a stat is made as late as possible. Return 2 if the top node + in TREE requires a stat, 0 if not. */ -boolean +int mark_stat (struct predicate *tree) { /* The tree is executed in-order, so walk this way (apologies to Aerosmith) @@ -423,8 +423,7 @@ mark_stat (struct predicate *tree) return tree->need_stat; case UNI_OP: - if (mark_stat (tree->pred_right)) - tree->need_stat = true; + tree->need_stat |= mark_stat (tree->pred_right); return (false); case BI_OP: @@ -432,9 +431,7 @@ mark_stat (struct predicate *tree) if (tree->pred_left != NULL) mark_stat (tree->pred_left); - if (mark_stat (tree->pred_right)) - tree->need_stat = true; - + tree->need_stat |= mark_stat (tree->pred_right); return (false); default: --- findutils-4.1.20/find/pred.c.jj 2003-05-24 20:36:25.000000000 +0200 +++ findutils-4.1.20/find/pred.c 2004-03-29 17:49:23.000000000 +0200 @@ -274,7 +274,8 @@ pred_and (char *pathname, struct stat *s pred_ptr->pred_left)) { /* Check whether we need a stat here. */ - if (pred_ptr->need_stat) + if (pred_ptr->need_stat == PRED_NEED_STAT + || (pred_ptr->need_stat && stat_buf->st_mode == 0)) { if (!have_stat && (*xstat) (rel_pathname, stat_buf) != 0) { @@ -365,7 +366,8 @@ pred_comma (char *pathname, struct stat (*pred_ptr->pred_left->pred_func) (pathname, stat_buf, pred_ptr->pred_left); /* Check whether we need a stat here. */ - if (pred_ptr->need_stat) + if (pred_ptr->need_stat == PRED_NEED_STAT + || (pred_ptr->need_stat && stat_buf->st_mode == 0)) { if (!have_stat && (*xstat) (rel_pathname, stat_buf) != 0) { @@ -926,7 +928,8 @@ boolean pred_negate (char *pathname, struct stat *stat_buf, struct predicate *pred_ptr) { /* Check whether we need a stat here. */ - if (pred_ptr->need_stat) + if (pred_ptr->need_stat == PRED_NEED_STAT + || (pred_ptr->need_stat && stat_buf->st_mode == 0)) { if (!have_stat && (*xstat) (rel_pathname, stat_buf) != 0) { @@ -1004,7 +1007,8 @@ pred_or (char *pathname, struct stat *st pred_ptr->pred_left)) { /* Check whether we need a stat here. */ - if (pred_ptr->need_stat) + if (pred_ptr->need_stat == PRED_NEED_STAT + || (pred_ptr->need_stat && stat_buf->st_mode == 0)) { if (!have_stat && (*xstat) (rel_pathname, stat_buf) != 0) { @@ -1210,6 +1214,11 @@ pred_xtype (char *pathname, struct stat struct stat sbuf; int (*ystat) (); +#ifdef S_ISLNK + if (xstat == lstat && !S_ISLNK (stat_buf->st_mode)) + return (pred_type (pathname, stat_buf, pred_ptr)); +#endif + ystat = xstat == lstat ? stat : lstat; if ((*ystat) (rel_pathname, &sbuf) != 0) { --- findutils-4.1.20/find/find.c.jj 2003-05-24 20:36:25.000000000 +0200 +++ findutils-4.1.20/find/find.c 2004-03-30 16:46:14.800294931 +0200 @@ -38,6 +38,20 @@ #include #endif +#if HAVE_DIRENT_H +# include +#else +# if HAVE_SYS_NDIR_H +# include +# endif +# if HAVE_SYS_DIR_H +# include +# endif +# if HAVE_NDIR_H +# include +# endif +#endif + #if ENABLE_NLS # include # define _(Text) gettext (Text) @@ -52,11 +66,15 @@ # define N_(String) (String) #endif +#ifndef DT_UNKNOWN +# define DT_UNKNOWN 0 +#endif + #define apply_predicate(pathname, stat_buf_ptr, node) \ (*(node)->pred_func)((pathname), (stat_buf_ptr), (node)) static void process_top_path PARAMS((char *pathname)); -static int process_path PARAMS((char *pathname, char *name, boolean leaf, char *parent)); +static int process_path PARAMS((char *pathname, char *name, boolean leaf, char *parent, char d_type)); static void process_dir PARAMS((char *pathname, char *name, int pathlen, struct stat *statp, char *parent)); static boolean no_side_effects PARAMS((struct predicate *pred)); static boolean default_prints PARAMS((struct predicate *pred)); @@ -343,11 +361,11 @@ process_top_path (char *pathname) cur_stat_buf.st_ino != stat_buf.st_ino) error (1, 0, _("%s changed during execution of %s"), pathname, program_name); - process_path (pathname, ".", false, "."); + process_path (pathname, ".", false, ".", DT_UNKNOWN); chdir_back (); } else - process_path (pathname, pathname, false, "."); + process_path (pathname, pathname, false, ".", DT_UNKNOWN); } /* Info on each directory in the current tree branch, to avoid @@ -381,7 +399,7 @@ static int dir_curr = -1; Return nonzero iff PATHNAME is a directory. */ static int -process_path (char *pathname, char *name, boolean leaf, char *parent) +process_path (char *pathname, char *name, boolean leaf, char *parent, char d_type) { struct stat stat_buf; static dev_t root_dev; /* Device ID of current argument pathname. */ @@ -394,7 +412,54 @@ process_path (char *pathname, char *name rel_pathname = name; - if (leaf) +#ifdef DTTOIF + if (d_type != DT_DIR + && DTTOIF (DT_UNKNOWN) == 0 +# ifdef DT_WHT + && d_type != DT_WHT +# endif + && (d_type != DT_LNK || xstat == lstat)) + stat_buf.st_mode = DTTOIF (d_type); +#else + switch (d_type) + { + /* Don't do anything for DT_DIR, it needs a full stat to get ino/dev. */ +# if defined DT_CHR + case DT_CHR: + stat_buf.st_mode = S_IFCHR; + break; +# endif +# if defined DT_BLK + case DT_BLK: + stat_buf.st_mode = S_IFBLK; + break; +# endif +# if defined DT_REG + case DT_REG: + stat_buf.st_mode = S_IFREG; + break; +# endif +# if defined DT_LNK && defined S_IFLNK + case DT_LNK: + if (xstat == lstat) + stat_buf.st_mode = S_IFLNK; + break; +# endif +# if defined DT_FIFO && defined S_IFIFO + case DT_FIFO: + stat_buf.st_mode = S_IFIFO; + break; +# endif +# if defined DT_SOCK && defined S_IFSOCK + case DT_SOCK: + stat_buf.st_mode = S_IFSOCK; + break; +# endif + } +#endif + if (stat_buf.st_mode) + have_stat = false; + else if (leaf) have_stat = false; else { @@ -527,10 +592,13 @@ process_dir (char *pathname, char *name, stat_buf.st_ino != dir_ids[dir_curr].ino) error (1, 0, _("%s changed during execution of %s"), starting_dir, program_name); - for (namep = name_space; *namep; namep += file_len - pathname_len + 1) + for (namep = name_space; *namep; namep += file_len - pathname_len + 2) { + char d_type = DT_UNKNOWN; + /* Append this directory entry's name to the path being searched. */ file_len = pathname_len + strlen (namep); + d_type = namep[file_len - pathname_len + 1]; if (file_len > cur_path_size) { while (file_len > cur_path_size) @@ -555,11 +623,11 @@ process_dir (char *pathname, char *name, that the rest of the entries are non-directories -- in other words, leaf files. */ subdirs_left -= process_path (cur_path, cur_name, - subdirs_left == 0, pathname); + subdirs_left == 0, pathname, d_type); else /* There might be weird (e.g., CD-ROM or MS-DOS) filesystems mounted, which don't have Unix-like directory link counts. */ - process_path (cur_path, cur_name, false, pathname); + process_path (cur_path, cur_name, false, pathname, d_type); curdepth--; } --- findutils-4.1.20/find/util.c.jj 2003-05-24 20:36:25.000000000 +0200 +++ findutils-4.1.20/find/util.c 2004-03-29 17:49:23.000000000 +0200 @@ -65,7 +65,7 @@ get_new_pred (void) last_pred->p_prec = NO_PREC; last_pred->side_effects = false; last_pred->no_default_print = false; - last_pred->need_stat = true; + last_pred->need_stat = PRED_NEED_STAT; last_pred->args.str = NULL; last_pred->pred_next = NULL; last_pred->pred_left = NULL; @@ -98,7 +98,7 @@ get_new_pred_chk_op (void) #endif /* DEBUG */ new_pred->p_type = BI_OP; new_pred->p_prec = AND_PREC; - new_pred->need_stat = false; + new_pred->need_stat = 0; new_pred->args.str = NULL; default: --- findutils-4.1.20/find/parser.c.jj 2003-05-24 20:36:25.000000000 +0200 +++ findutils-4.1.20/find/parser.c 2004-03-29 17:49:23.000000000 +0200 @@ -280,7 +280,7 @@ parse_and (char **argv, int *arg_ptr) #endif /* DEBUG */ our_pred->p_type = BI_OP; our_pred->p_prec = AND_PREC; - our_pred->need_stat = false; + our_pred->need_stat = 0; return (true); } @@ -318,7 +318,7 @@ parse_close (char **argv, int *arg_ptr) #endif /* DEBUG */ our_pred->p_type = CLOSE_PAREN; our_pred->p_prec = NO_PREC; - our_pred->need_stat = false; + our_pred->need_stat = 0; return (true); } @@ -371,7 +371,7 @@ parse_comma (char **argv, int *arg_ptr) #endif /* DEBUG */ our_pred->p_type = BI_OP; our_pred->p_prec = COMMA_PREC; - our_pred->need_stat = false; + our_pred->need_stat = 0; return (true); } @@ -425,7 +425,7 @@ parse_false (char **argv, int *arg_ptr) struct predicate *our_pred; our_pred = insert_primary (pred_false); - our_pred->need_stat = false; + our_pred->need_stat = 0; return (true); } @@ -482,7 +482,7 @@ parse_fprint (char **argv, int *arg_ptr) our_pred->args.stream = open_output_file (argv[*arg_ptr]); our_pred->side_effects = true; our_pred->no_default_print = true; - our_pred->need_stat = false; + our_pred->need_stat = 0; (*arg_ptr)++; return (true); } @@ -498,7 +498,7 @@ parse_fprint0 (char **argv, int *arg_ptr our_pred->args.stream = open_output_file (argv[*arg_ptr]); our_pred->side_effects = true; our_pred->no_default_print = true; - our_pred->need_stat = false; + our_pred->need_stat = 0; (*arg_ptr)++; return (true); } @@ -588,6 +588,7 @@ parse_ilname (char **argv, int *arg_ptr) return (false); our_pred = insert_primary (pred_ilname); our_pred->args.str = argv[*arg_ptr]; + our_pred->need_stat = PRED_NEED_TYPE; (*arg_ptr)++; return (true); } @@ -600,7 +601,7 @@ parse_iname (char **argv, int *arg_ptr) if ((argv == NULL) || (argv[*arg_ptr] == NULL)) return (false); our_pred = insert_primary (pred_iname); - our_pred->need_stat = false; + our_pred->need_stat = 0; our_pred->args.str = argv[*arg_ptr]; (*arg_ptr)++; return (true); @@ -620,7 +621,7 @@ parse_ipath (char **argv, int *arg_ptr) if ((argv == NULL) || (argv[*arg_ptr] == NULL)) return (false); our_pred = insert_primary (pred_ipath); - our_pred->need_stat = false; + our_pred->need_stat = 0; our_pred->args.str = argv[*arg_ptr]; (*arg_ptr)++; return (true); @@ -647,6 +648,7 @@ parse_lname (char **argv, int *arg_ptr) return (false); our_pred = insert_primary (pred_lname); our_pred->args.str = argv[*arg_ptr]; + our_pred->need_stat = PRED_NEED_TYPE; (*arg_ptr)++; return (true); } @@ -731,7 +733,7 @@ parse_name (char **argv, int *arg_ptr) if ((argv == NULL) || (argv[*arg_ptr] == NULL)) return (false); our_pred = insert_primary (pred_name); - our_pred->need_stat = false; + our_pred->need_stat = 0; our_pred->args.str = argv[*arg_ptr]; (*arg_ptr)++; return (true); @@ -749,7 +751,7 @@ parse_negate (char **argv, int *arg_ptr) #endif /* DEBUG */ our_pred->p_type = UNI_OP; our_pred->p_prec = NEGATE_PREC; - our_pred->need_stat = false; + our_pred->need_stat = 0; return (true); } @@ -876,7 +878,7 @@ parse_open (char **argv, int *arg_ptr) #endif /* DEBUG */ our_pred->p_type = OPEN_PAREN; our_pred->p_prec = NO_PREC; - our_pred->need_stat = false; + our_pred->need_stat = 0; return (true); } @@ -892,7 +894,7 @@ parse_or (char **argv, int *arg_ptr) #endif /* DEBUG */ our_pred->p_type = BI_OP; our_pred->p_prec = OR_PREC; - our_pred->need_stat = false; + our_pred->need_stat = 0; return (true); } @@ -904,7 +906,7 @@ parse_path (char **argv, int *arg_ptr) if ((argv == NULL) || (argv[*arg_ptr] == NULL)) return (false); our_pred = insert_primary (pred_path); - our_pred->need_stat = false; + our_pred->need_stat = 0; our_pred->args.str = argv[*arg_ptr]; (*arg_ptr)++; return (true); @@ -970,7 +972,7 @@ parse_print (char **argv, int *arg_ptr) already specified -print. */ our_pred->side_effects = true; our_pred->no_default_print = true; - our_pred->need_stat = false; + our_pred->need_stat = 0; return (true); } @@ -985,7 +987,7 @@ parse_print0 (char **argv, int *arg_ptr) already specified -print0. */ our_pred->side_effects = true; our_pred->no_default_print = true; - our_pred->need_stat = false; + our_pred->need_stat = 0; return (true); } @@ -1003,7 +1005,7 @@ parse_prune (char **argv, int *arg_ptr) struct predicate *our_pred; our_pred = insert_primary (pred_prune); - our_pred->need_stat = false; + our_pred->need_stat = 0; /* -prune has a side effect that it does not descend into the current directory. */ our_pred->side_effects = true; @@ -1026,7 +1028,7 @@ insert_regex (char **argv, int *arg_ptr, if ((argv == NULL) || (argv[*arg_ptr] == NULL)) return (false); our_pred = insert_primary (pred_regex); - our_pred->need_stat = false; + our_pred->need_stat = 0; re = (struct re_pattern_buffer *) xmalloc (sizeof (struct re_pattern_buffer)); our_pred->args.regex = re; @@ -1121,7 +1123,7 @@ parse_true (char **argv, int *arg_ptr) struct predicate *our_pred; our_pred = insert_primary (pred_true); - our_pred->need_stat = false; + our_pred->need_stat = 0; return (true); } @@ -1256,13 +1258,14 @@ insert_type (char **argv, int *arg_ptr, } our_pred = insert_primary (which_pred); our_pred->args.type = type_cell; + our_pred->need_stat = PRED_NEED_TYPE; (*arg_ptr)++; /* Move on to next argument. */ return (true); } -/* If true, we've determined that the current fprintf predicate +/* If non-zero, we've determined that the current fprintf predicate uses stat information. */ -static boolean fprintf_stat_needed; +static char fprintf_stat_needed; static boolean insert_fprintf (FILE *fp, boolean (*func) (/* ??? */), char **argv, int *arg_ptr) @@ -1275,7 +1278,7 @@ insert_fprintf (FILE *fp, boolean (*func format = argv[(*arg_ptr)++]; - fprintf_stat_needed = false; /* Might be overridden later. */ + fprintf_stat_needed = 0; /* Might be overridden later. */ our_pred = insert_primary (func); our_pred->side_effects = true; our_pred->no_default_print = true; @@ -1429,14 +1432,16 @@ make_segment (struct segment **segment, case 'g': /* group name */ case 'i': /* inode number */ case 'k': /* size in 1K blocks */ - case 'l': /* object of symlink */ case 'n': /* number of links */ case 's': /* size in bytes */ case 't': /* mtime in `ctime' format */ case 'T': /* mtime in user-specified strftime format */ case 'U': /* UID number */ case 'u': /* user name */ - fprintf_stat_needed = true; + fprintf_stat_needed = PRED_NEED_STAT; + /* FALLTHROUGH */ + case 'l': /* object of symlink */ + fprintf_stat_needed |= PRED_NEED_TYPE; /* FALLTHROUGH */ case 'f': /* basename of path */ case 'h': /* leading directories part of path */ @@ -1452,7 +1457,7 @@ make_segment (struct segment **segment, case 'm': /* mode as octal number (perms only) */ *fmt++ = 'o'; - fprintf_stat_needed = true; + fprintf_stat_needed = PRED_NEED_STAT; break; } *fmt = '\0'; --- findutils-4.1.20/gnulib/config.h.in.jj 2003-05-26 14:09:52.000000000 +0200 +++ findutils-4.1.20/gnulib/config.h.in 2004-03-30 16:38:06.321836630 +0200 @@ -11,6 +11,10 @@ /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA +/* Define if there is a member named d_type in the struct describing directory + headers. */ +#undef D_TYPE_IN_DIRENT + /* Define to 1 if translation of program messages to the user's native language is requested. */ #undef ENABLE_NLS --- findutils-4.1.20/gnulib/Makefile.in.jj 2003-05-26 14:09:29.000000000 +0200 +++ findutils-4.1.20/gnulib/Makefile.in 2004-03-30 16:39:00.119195443 +0200 @@ -168,7 +168,7 @@ $(top_builddir)/config.status: $(srcdir) $(srcdir)/configure: $(srcdir)/configure.ac $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) cd $(srcdir) && $(AUTOCONF) -$(ACLOCAL_M4): configure.ac m4/alloca.m4 m4/codeset.m4 m4/dirname.m4 m4/dos.m4 m4/error.m4 m4/fileblocks.m4 m4/filemode.m4 m4/fnmatch.m4 m4/getcwd.m4 m4/getline.m4 m4/getopt.m4 m4/gettext.m4 m4/glibc21.m4 m4/human.m4 m4/iconv.m4 m4/idcache.m4 m4/intdiv0.m4 m4/intmax_t.m4 m4/inttypes-pri.m4 m4/inttypes.m4 m4/inttypes_h.m4 m4/isc-posix.m4 m4/lcmessage.m4 m4/lib-ld.m4 m4/lib-link.m4 m4/lib-prefix.m4 m4/longlong.m4 m4/lstat.m4 m4/malloc.m4 m4/mbrtowc.m4 m4/mbstate_t.m4 m4/memcmp.m4 m4/memset.m4 m4/mktime.m4 m4/modechange.m4 m4/onceonly_2_57.m4 m4/pathmax.m4 m4/progtest.m4 m4/quote.m4 m4/quotearg.m4 m4/realloc.m4 m4/regex.m4 m4/rpmatch.m4 m4/savedir.m4 m4/stat.m4 m4/stdint_h.m4 m4/stpcpy.m4 m4/strdup.m4 m4/strerror_r.m4 m4/strftime.m4 m4/strstr.m4 m4/strtoimax.m4 m4/strtol.m4 m4/strtoll.m4 m4/strtoul.m4 m4/strtoull.m4 m4/strtoumax.m4 m4/tm_gmtoff.m4 m4/uintmax_t.m4 m4/ulonglong.m4 m4/unlocked-io.m4 m4/xalloc.m4 m4/xgetcwd.m4 m4/xstrtol.m4 m4/xstrtoumax.m4 m4/yesno.m4 +$(ACLOCAL_M4): configure.ac m4/alloca.m4 m4/codeset.m4 m4/d_type.m4 m4/dirname.m4 m4/dos.m4 m4/error.m4 m4/fileblocks.m4 m4/filemode.m4 m4/fnmatch.m4 m4/getcwd.m4 m4/getline.m4 m4/getopt.m4 m4/gettext.m4 m4/glibc21.m4 m4/human.m4 m4/iconv.m4 m4/idcache.m4 m4/intdiv0.m4 m4/intmax_t.m4 m4/inttypes-pri.m4 m4/inttypes.m4 m4/inttypes_h.m4 m4/isc-posix.m4 m4/lcmessage.m4 m4/lib-ld.m4 m4/lib-link.m4 m4/lib-prefix.m4 m4/longlong.m4 m4/lstat.m4 m4/malloc.m4 m4/mbrtowc.m4 m4/mbstate_t.m4 m4/memcmp.m4 m4/memset.m4 m4/mktime.m4 m4/modechange.m4 m4/onceonly_2_57.m4 m4/pathmax.m4 m4/progtest.m4 m4/quote.m4 m4/quotearg.m4 m4/realloc.m4 m4/regex.m4 m4/rpmatch.m4 m4/savedir.m4 m4/stat.m4 m4/stdint_h.m4 m4/stpcpy.m4 m4/strdup.m4 m4/strerror_r.m4 m4/strftime.m4 m4/strstr.m4 m4/strtoimax.m4 m4/strtol.m4 m4/strtoll.m4 m4/strtoul.m4 m4/strtoull.m4 m4/strtoumax.m4 m4/tm_gmtoff.m4 m4/uintmax_t.m4 m4/ulonglong.m4 m4/unlocked-io.m4 m4/xalloc.m4 m4/xgetcwd.m4 m4/xstrtol.m4 m4/xstrtoumax.m4 m4/yesno.m4 cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) config.h: stamp-h1 --- findutils-4.1.20/gnulib/m4/savedir.m4.jj 2002-12-31 14:42:07.000000000 +0100 +++ findutils-4.1.20/gnulib/m4/savedir.m4 2004-03-30 16:33:45.349606252 +0200 @@ -12,4 +12,5 @@ AC_DEFUN([gl_SAVEDIR], AC_REQUIRE([AC_HEADER_STDC]) AC_REQUIRE([AC_HEADER_DIRENT]) AC_REQUIRE([AC_FUNC_CLOSEDIR_VOID]) + AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE]) ]) --- findutils-4.1.20/gnulib/m4/Makefile.am.jj 2003-05-26 14:09:24.000000000 +0200 +++ findutils-4.1.20/gnulib/m4/Makefile.am 2004-03-30 16:22:40.748711385 +0200 @@ -3,6 +3,7 @@ EXTRA_DIST = EXTRA_DIST += alloca.m4 EXTRA_DIST += codeset.m4 +EXTRA_DIST += d_type.m4 EXTRA_DIST += dirname.m4 EXTRA_DIST += dos.m4 EXTRA_DIST += error.m4 --- findutils-4.1.20/gnulib/m4/d_type.m4.jj 2004-03-30 16:22:19.353545677 +0200 +++ findutils-4.1.20/gnulib/m4/d_type.m4 2004-03-30 16:22:13.788542998 +0200 @@ -0,0 +1,42 @@ +#serial 3 + +dnl From Jim Meyering. +dnl +dnl Check whether struct dirent has a member named d_type. +dnl + +AC_DEFUN(jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE, + [AC_REQUIRE([AC_HEADER_DIRENT])dnl + AC_CACHE_CHECK([for d_type member in directory struct], + jm_cv_struct_dirent_d_type, + [AC_TRY_LINK(dnl + [ +#include +#ifdef HAVE_DIRENT_H +# include +#else /* not HAVE_DIRENT_H */ +# define dirent direct +# ifdef HAVE_SYS_NDIR_H +# include +# endif /* HAVE_SYS_NDIR_H */ +# ifdef HAVE_SYS_DIR_H +# include +# endif /* HAVE_SYS_DIR_H */ +# ifdef HAVE_NDIR_H +# include +# endif /* HAVE_NDIR_H */ +#endif /* HAVE_DIRENT_H */ + ], + [struct dirent dp; dp.d_type = 0;], + + jm_cv_struct_dirent_d_type=yes, + jm_cv_struct_dirent_d_type=no) + ] + ) + if test $jm_cv_struct_dirent_d_type = yes; then + AC_DEFINE(D_TYPE_IN_DIRENT, 1, + [Define if there is a member named d_type in the struct describing + directory headers.]) + fi + ] +) --- findutils-4.1.20/gnulib/m4/Makefile.in.jj 2003-05-26 14:09:29.000000000 +0200 +++ findutils-4.1.20/gnulib/m4/Makefile.in 2004-03-30 16:56:21.405583365 +0200 @@ -129,7 +129,7 @@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ -EXTRA_DIST = alloca.m4 codeset.m4 dirname.m4 dos.m4 error.m4 fileblocks.m4 filemode.m4 fnmatch.m4 getcwd.m4 getline.m4 getopt.m4 gettext.m4 glibc21.m4 human.m4 iconv.m4 idcache.m4 intdiv0.m4 intmax_t.m4 inttypes_h.m4 inttypes.m4 inttypes-pri.m4 isc-posix.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 longlong.m4 lstat.m4 malloc.m4 mbrtowc.m4 mbstate_t.m4 memcmp.m4 memset.m4 mktime.m4 modechange.m4 onceonly_2_57.m4 pathmax.m4 progtest.m4 quotearg.m4 quote.m4 realloc.m4 regex.m4 rpmatch.m4 savedir.m4 stat.m4 stdint_h.m4 stpcpy.m4 strdup.m4 strerror_r.m4 strftime.m4 strstr.m4 strtoimax.m4 strtoll.m4 strtol.m4 strtoull.m4 strtoul.m4 strtoumax.m4 tm_gmtoff.m4 uintmax_t.m4 ulonglong.m4 unlocked-io.m4 xalloc.m4 xgetcwd.m4 xstrtol.m4 xstrtoumax.m4 yesno.m4 +EXTRA_DIST = alloca.m4 codeset.m4 d_type.m4 dirname.m4 dos.m4 error.m4 fileblocks.m4 filemode.m4 fnmatch.m4 getcwd.m4 getline.m4 getopt.m4 gettext.m4 glibc21.m4 human.m4 iconv.m4 idcache.m4 intdiv0.m4 intmax_t.m4 inttypes_h.m4 inttypes.m4 inttypes-pri.m4 isc-posix.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 longlong.m4 lstat.m4 malloc.m4 mbrtowc.m4 mbstate_t.m4 memcmp.m4 memset.m4 mktime.m4 modechange.m4 onceonly_2_57.m4 pathmax.m4 progtest.m4 quotearg.m4 quote.m4 realloc.m4 regex.m4 rpmatch.m4 savedir.m4 stat.m4 stdint_h.m4 stpcpy.m4 strdup.m4 strerror_r.m4 strftime.m4 strstr.m4 strtoimax.m4 strtoll.m4 strtol.m4 strtoull.m4 strtoul.m4 strtoumax.m4 tm_gmtoff.m4 uintmax_t.m4 ulonglong.m4 unlocked-io.m4 xalloc.m4 xgetcwd.m4 xstrtol.m4 xstrtoumax.m4 yesno.m4 subdir = m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs --- findutils-4.1.20/gnulib/aclocal.m4.jj 2003-05-26 14:09:25.000000000 +0200 +++ findutils-4.1.20/gnulib/aclocal.m4 2004-03-30 16:34:05.913920859 +0200 @@ -968,6 +968,49 @@ AC_DEFUN([AC_CHECK_DECLS_ONCE], [ ]) ]) +#serial 3 + +dnl From Jim Meyering. +dnl +dnl Check whether struct dirent has a member named d_type. +dnl + +AC_DEFUN(jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE, + [AC_REQUIRE([AC_HEADER_DIRENT])dnl + AC_CACHE_CHECK([for d_type member in directory struct], + jm_cv_struct_dirent_d_type, + [AC_TRY_LINK(dnl + [ +#include +#ifdef HAVE_DIRENT_H +# include +#else /* not HAVE_DIRENT_H */ +# define dirent direct +# ifdef HAVE_SYS_NDIR_H +# include +# endif /* HAVE_SYS_NDIR_H */ +# ifdef HAVE_SYS_DIR_H +# include +# endif /* HAVE_SYS_DIR_H */ +# ifdef HAVE_NDIR_H +# include +# endif /* HAVE_NDIR_H */ +#endif /* HAVE_DIRENT_H */ + ], + [struct dirent dp; dp.d_type = 0;], + + jm_cv_struct_dirent_d_type=yes, + jm_cv_struct_dirent_d_type=no) + ] + ) + if test $jm_cv_struct_dirent_d_type = yes; then + AC_DEFINE(D_TYPE_IN_DIRENT, 1, + [Define if there is a member named d_type in the struct describing + directory headers.]) + fi + ] +) + # dirname.m4 serial 1 dnl Copyright (C) 2002 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU @@ -3627,6 +3670,7 @@ AC_DEFUN([gl_SAVEDIR], AC_REQUIRE([AC_HEADER_STDC]) AC_REQUIRE([AC_HEADER_DIRENT]) AC_REQUIRE([AC_FUNC_CLOSEDIR_VOID]) + AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE]) ]) #serial 8 --- findutils-4.1.20/gnulib/lib/savedir.c.jj 2001-08-31 11:09:53.000000000 +0200 +++ findutils-4.1.20/gnulib/lib/savedir.c 2004-03-30 16:18:41.353614103 +0200 @@ -45,6 +45,10 @@ extern int errno; # endif #endif +#ifndef DT_UNKNOWN +# define DT_UNKNOWN 0 +#endif + #ifdef CLOSEDIR_VOID /* Fake a return value. */ # define CLOSEDIR(d) (closedir (d), 0) @@ -64,8 +68,9 @@ extern int errno; #include "xalloc.h" /* Return a freshly allocated string containing the filenames - in directory DIR, separated by '\0' characters; - the end is marked by two '\0' characters in a row. + in directory DIR, terminated by '\0' characters and followed + by one byte containing file type (DT_*). + The end is marked by zero-length filename. Return NULL (setting errno) if DIR cannot be opened, read, or closed. */ #ifndef NAME_SIZE_DEFAULT @@ -96,7 +101,7 @@ savedir (const char *dir) char const *entry = dp->d_name; if (entry[entry[0] != '.' ? 0 : entry[1] != '.' ? 1 : 2] != '\0') { - size_t entry_size = strlen (entry) + 1; + size_t entry_size = strlen (entry) + 2; if (used + entry_size < used) xalloc_die (); if (allocated <= used + entry_size) @@ -111,7 +116,12 @@ savedir (const char *dir) name_space = xrealloc (name_space, allocated); } - memcpy (name_space + used, entry, entry_size); + memcpy (name_space + used, entry, entry_size - 1); +#ifdef D_TYPE_IN_DIRENT + name_space [used + entry_size - 1] = dp->d_type; +#else + name_space [used + entry_size - 1] = DT_UNKNOWN; +#endif used += entry_size; } } --- findutils-4.1.20/gnulib/configure.jj 2003-05-26 14:09:28.000000000 +0200 +++ findutils-4.1.20/gnulib/configure 2004-03-30 16:37:32.680865530 +0200 @@ -9310,6 +9310,88 @@ _ACEOF fi + echo "$as_me:$LINENO: checking for d_type member in directory struct" >&5 +echo $ECHO_N "checking for d_type member in directory struct... $ECHO_C" >&6 +if test "${jm_cv_struct_dirent_d_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#ifdef HAVE_DIRENT_H +# include +#else /* not HAVE_DIRENT_H */ +# define dirent direct +# ifdef HAVE_SYS_NDIR_H +# include +# endif /* HAVE_SYS_NDIR_H */ +# ifdef HAVE_SYS_DIR_H +# include +# endif /* HAVE_SYS_DIR_H */ +# ifdef HAVE_NDIR_H +# include +# endif /* HAVE_NDIR_H */ +#endif /* HAVE_DIRENT_H */ + +int +main () +{ +struct dirent dp; dp.d_type = 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + jm_cv_struct_dirent_d_type=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +jm_cv_struct_dirent_d_type=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + +fi +echo "$as_me:$LINENO: result: $jm_cv_struct_dirent_d_type" >&5 +echo "${ECHO_T}$jm_cv_struct_dirent_d_type" >&6 + if test $jm_cv_struct_dirent_d_type = yes; then + +cat >>confdefs.h <<\_ACEOF +#define D_TYPE_IN_DIRENT 1 +_ACEOF + + fi + + +