summaryrefslogtreecommitdiff
path: root/lib/fts.c
AgeCommit message (Collapse)Author
2005-06-02Don't use "path" or "filename" to mean "file name"Paul Eggert
in comments or local variable names.
2005-05-28Don't worry about debugging on pre-C99-comopatible hosts;Paul Eggert
the configuration hassle isn't worth it. Include inttypes.h and stdint.h unconditionally if FTS_DEBUG. (LONGEST_MODIFIER, PRIuMAX): Remove.
2005-05-22(fd_safer) [_LGPL_PACKAGE]: New static function,Paul Eggert
so that unistd-safer.h (GPL'ed code) need not be included.
2005-05-20Don't include "cycle-check.h" or "hash.h".Paul Eggert
(setup_dir, free_dir): New functions. (enter_dir, leave_dir): Define trivial alternatives of _LGPL_PACKAGE. Move to fts-cycle.c if !_LGPL_PACKAGE. (HT_INITIAL_SIZE, ENTER_DIR): Remove. All uses removed. (LEAVE_DIR): Fix typo: pass Fts and Ent to leave_dir. (struct Active_dir, AD_compare, AD_hash, enter_dir, leave_dir): Move to fts-cycle.c. (fts_open): Use setup_dir. (fts_close): Use free_dir. (fts_read): Have just one copy of the ENTER_DIR code rather than three. This adds a label and some gotos, but the alternatives were messier. Check for memory allocation failure when entering a dir. (fts_stat) [_LGPL_PACKAGE]: Bring back glibc cycle detection code.
2005-05-20(fts_open): Remove useless but otherwise harmless malloc call.Jim Meyering
Spotted by Paul Eggert.
2005-05-18Include fts_.h first, to check interface.Paul Eggert
Do not include intprops.h; no longer needed. Include cycle-check.h and hash.h, since fts_.h no longer does. Remove unnecessary casts of closedir to void. (fts_build): Use a simpler method (not involving TYPE_SIGNED) to decide whether to decrement nlinks.
2005-05-14tweak cpp indentation on one lineJim Meyering
2005-05-14Update FSF postal mail address.Jim Meyering
2005-05-09(fts_sort): Optimize the common case where all pointers smell the same.Paul Eggert
2005-05-09(__P): Remove. All uses rewritten to assume C89 or better.Paul Eggert
(fts_open): Don't cast a function value in a possibly-unsafe way. (fts_compar): New function. (fts_sort): Use it.
2005-04-11Include unistd-safer.h.Paul Eggert
(fts_safe_changedir): Use fd_safer.
2005-04-09(__attribute__, ATTRIBUTE_UNUSED): Define.Jim Meyering
Mark parameter `sp' with ATTRIBUTE_UNUSED.
2005-03-09* lib/fts.c: Include intprops.h.Paul Eggert
(TYPE_SIGNED): Remove.
2004-10-13(fts_read): When about to fail (by returning NULL) dueJim Meyering
to a failed fchdir or failed fts_safe_changedir call, set `sp->fts_cur = p'. Do this by removing the explicit `return NULL;' statements and setting p->fts_errno so execution falls through to the common-case code below. Otherwise, after such a failure, calling fts_close would attempt to free an already-freed buffer. Reported by Luis Lopez Lopez in http://bugs.debian.org/276352.
2004-09-02(fts_stat, fts_open, fts_read): Use "unsigned short int"Paul Eggert
rather than the unportable "u_short", and similarly for u_int.
2004-08-11(O_DIRECTORY): Define to 0 if the system doesn't define.Paul Eggert
2004-08-09(diropen): New function.Paul Eggert
(fts_open, fts_read, fts_children, fts_safe_changedir): Use it, so that the code works even if the directory is writeable but not readable.
2004-08-04(LONGEST_MODIFIER): New macro.Paul Eggert
(PRIuMAX) [!PRI_MACROS_BROKEN && !defined PRIuMAX]: New macro. (find_matching_ancestor): Use it for dev_t and ino_t.
2004-08-02Add an FSF copyright notice, since our changes are becoming nontrivial.Paul Eggert
Include stdint.h if available, as Autoconf suggests. (ALIGNBYTES, ALIGN): Remove; no longer needed now that fts_statp is an array. (fts_alloc, fts_palloc, fts_sort, fts_load, fts_build): Use size_t for sizes. (fts_stat, fts_safe_changedir, fts_debug, fts_read, fts_build, fts_palloc): Use bool when appropriate. (SIZE_MAX, TYPE_SIGNED): New macros. (fts_read): Use u_short for instructions. (fts_build): Use ptrdiff_t for levels. Don't assume file name lengths fit into int. Don't assume nlink_t is signed. (find_matching_ancestor): Don't assume dev, ino fit in int. (fts_stat): Use function prototype; required for bool arg. (fts_sort): Detect integer overflow in size calculations. (fts_alloc): Simplify allocation code, now that fts_statp is an array and not a pointer.
2004-06-08(fts_stat, fts_alloc): Always allocate and use a structJim Meyering
stat, even if the user isn't interested in the results. This prevents a core dump in cycle_check when FTS_NOSTAT is set.
2004-03-29Include dirfd.h, for dirfd.Jim Meyering
2003-12-20[!_LIBC]: Undefine, then define-away __P.Jim Meyering
2003-12-20[!_LIBC]: Define __P.Jim Meyering
2003-12-19Don't include <search.h>.Jim Meyering
[HAVE_INTTYPES_H]: Include <inttypes.h>. (tdestroy, tfind, tsearch): Remove definitions. (struct Active_dir): Rename from `known_object'. (AD_compare, AD_hash): New functions. (enter_dir, leave_dir): Rewrite to manipulate a hash table rather than a tree. (fts_open): Initialize hash table or cycle_state buffer. (free_node): Remove function. (find_matching_ancestor): Renamed/rewritten from look_up_active_dir. (fts_cross_check): Adapt to use new data structure.
2003-12-18Rewrite cycle detection code to work properly.Jim Meyering
Add some framework (compiled out by default) to test it. (Dprintf, ENTER_DIR, LEAVE_DIR): Define. (add_object): Remove function. Rewritten as... (enter_dir): New function. (leave_dir, free_node): New functions. (fts_read): Ensure that we call ENTER_DIR or LEAVE_DIR, as appropriate, before returning. (look_up_active_dir, fts_cross_check) [FTS_DEBUG]: New functions. (fts_stat): Don't perform the cycle check here. Now it's done via enter_dir.
2003-10-02Don't require that the maximum length of a file nameJim Meyering
encountered in a traversal fit in an `unsigned short', and fix some portability bugs (don't depend on gcc). Include "fts_.h", not <fts.h>. (ALIGNBYTES) [!(__GNUC__ >= 2)]: Add a definition that works with compilers that don't have __alignof__. (MAX): Use a definition that doesn't depend on gcc. (fts_build): Make `len' and `maxlen' be of type size_t, not int. Test for overflow in a less type-dependent manner. Test HAVE_STRUCT_DIRENT_D_TYPE, rather than defined DT_DIR && defined _DIRENT_HAVE_D_TYPE. (fts_palloc): Test for overflow in a less type-dependent manner. (fts_safe_changedir): Use stat, not stat64. Use fstat, not __fxstat64(_STAT_VER.
2003-04-15Remove (or replace-with-TAB(s) to retain alignment)Jim Meyering
each sequence of spaces before a TAB character.
2003-02-28(fts_children): If opening `.' fails, set the fts_childJim Meyering
member to NULL before returning. From NetBSD.
2003-02-28(fts_children): If fchdir fails, close file descriptorJim Meyering
before returning. From NetBSD.
2003-02-24Include <search.h>.Jim Meyering
(struct known_object): Define. (object_compare, add_object, find_object): New functions, like those in ftw.c. (fts_open): Initialize new member. (fts_close): Free memory allocated for new member. (fts_stat): Detect a cycle in O(logN) time per directory processed.
2003-02-24[HAVE_CONFIG_H]: Include <config.h>.Jim Meyering
Conditionalize inclusion of <sys/param.h>. Conditionalize inclusion of <include/sys/stat.h> vs <sys/stat.h>. Include autoconf-recommended block of dirent/NAMELEN-related definitions and includes. Use NAMLEN throughout, rather than _D_EXACT_NAMLEN. [_LIBC] (close, closedir, fchdir, open, opendir): Define. [_LIBC] (readdir, tdestroy, tfind, tsearch): Define. Remove `__' prefix from all uses of the above. This will help to merge *BSD changes. [!_LIBC] (internal_function): Define. [! _LIBC && ! LSTAT_FOLLOWS_SLASHED_SYMLINK]: Define lstat. (__set_errno): Define if not already defined.
2003-02-24(fts_open): If fts_alloc returns NULL, don't dereference it.Jim Meyering
(fts_read): If fts_safe_changedir fails because it is not able to chdir into a subdirectory, then inform the caller.
2003-02-24virgin copy from glibcJim Meyering
2003-02-13hacked from the versions in glibcJim Meyering