New fts module.
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 20 May 2005 23:07:53 +0000 (23:07 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 20 May 2005 23:07:53 +0000 (23:07 +0000)
commitc2546905a0f3958439581290d150c9ae4ae52a50
tree750fde31ac1ef2ccadf62c540cc776245f39c058
parentb00e860d80d31318069eafaa67c920f24deae638
New fts module.
* MODULES.html.sh (File system functions): Add fts, fts-lgpl.
* lib/fts.c: Don't include "cycle-check.h" or "hash.h".
(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.
* lib/fts_.h (_LGPL_PACKAGE) [defined _LIBC]: New macro.
(FTS): New member fts_cycle, that is a union that contains the
old active_dir_ht and cycle_state.  All uses changed to mention
fts_cycle.ht and fts_cycle.state.
* lib/fts-cycle.c: New file, containing GPL'ed code migrated out of
fts.c, with the following changes:
(setup_dir, free_dir): New functions.
(enter_dir): Now returns bool.  Return true if successful, false
if memory exhausted.  All callers changed.
Do not bother partly cleaning up on
memory allocation failure; that is free_dir's job.
However, free ad if hash_insert fails, to avoid memory leak.
(enter_dir, leave_dir): Accommodate change to FTS by inspecting
fts->fts_options to see which union member to use.
* m4/fts.m4 (gl_FUNC_FTS_CORE): Renamed from gl_FUNC_FTS.
(gl_FUNC_FTS, gl_FUNC_FTS_LGPL): New macros.

* lib/unlinkdir.h (cannot_unlink_dir) [UNLINK_CANNOT_UNLINK_DIR]:
Now a macro, to pacify GCC.
ChangeLog
MODULES.html.sh
lib/ChangeLog
lib/fts-cycle.c [new file with mode: 0644]
lib/fts.c
lib/fts_.h
lib/unlinkdir.h
m4/ChangeLog
m4/fts.m4
modules/fts [new file with mode: 0644]
modules/fts-lgpl [new file with mode: 0644]