summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rwxr-xr-xunix/configure137
-rw-r--r--unix/configure.in18
-rw-r--r--unix/tcl.m411
-rw-r--r--unix/tclConfig.h.in3
-rw-r--r--unix/tclUnixFCmd.c35
6 files changed, 126 insertions, 92 deletions
diff --git a/ChangeLog b/ChangeLog
index eb71468..5460ec1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,19 @@
+2005-12-05 Daniel Steffen <das@users.sourceforge.net>
+
+ * unix/configure.in: move check for fts API to configure.in and run it
+ * unix/tcl.m4: on all platforms, since Linux glibc2 and *BSDs also
+ have this; using fts is more efficient than recursive opendir/readdir.
+ * unix/tclUnixFCmd.c (TraverseUnixTree): add support to fts code for
+ platforms with stat64.
+ * unix/configure:
+ * unix/tclConfig.h.in: regen.
+
2005-12-05 Jeff Hobbs <jeffh@ActiveState.com>
- * unix/configure: Use FTS file APIs on Darwin if available.
+ * unix/configure: Use fts file API on Darwin if available.
* unix/tcl.m4: Addresses file delete issues in readdir noted
* unix/tclUnixFCmd.c: in [Bug 1034337]. (steffen)
- Reduce on stat call in DoCopyFile. (steffen)
+ Remove redundant stat call for each file in DoCopyFile. (steffen)
2005-12-02 Kevin B. Kenny <kennykb@acm.org>
diff --git a/unix/configure b/unix/configure
index 43d1a82..d906f7b 100755
--- a/unix/configure
+++ b/unix/configure
@@ -7897,72 +7897,6 @@ _ACEOF
fi
done
- echo "$as_me:$LINENO: checking for fts" >&5
-echo $ECHO_N "checking for fts... $ECHO_C" >&6
-if test "${tcl_cv_api_fts+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 <sys/param.h>
- #include <sys/stat.h>
- #include <fts.h>
-int
-main ()
-{
-char*const p[2] = {"/", NULL};
- FTS *f = fts_open(p, FTS_PHYSICAL|FTS_NOCHDIR|FTS_NOSTAT, NULL);
- FTSENT *e = fts_read(f); fts_close(f);
- ;
- 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
- tcl_cv_api_fts=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-tcl_cv_api_fts=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $tcl_cv_api_fts" >&5
-echo "${ECHO_T}$tcl_cv_api_fts" >&6
- if test $tcl_cv_api_fts = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_FTS 1
-_ACEOF
-
- fi
cat >>confdefs.h <<\_ACEOF
#define MAC_OSX_TCL 1
@@ -14504,6 +14438,77 @@ done
#--------------------------------------------------------------------
+# Check for support of fts functions (readdir replacement)
+#--------------------------------------------------------------------
+
+echo "$as_me:$LINENO: checking for fts" >&5
+echo $ECHO_N "checking for fts... $ECHO_C" >&6
+if test "${tcl_cv_api_fts+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 <sys/param.h>
+ #include <sys/stat.h>
+ #include <fts.h>
+int
+main ()
+{
+char*const p[2] = {"/", NULL};
+ FTS *f = fts_open(p, FTS_PHYSICAL|FTS_NOCHDIR|FTS_NOSTAT, NULL);
+ FTSENT *e = fts_read(f); fts_close(f);
+ ;
+ 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
+ tcl_cv_api_fts=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+tcl_cv_api_fts=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $tcl_cv_api_fts" >&5
+echo "${ECHO_T}$tcl_cv_api_fts" >&6
+if test $tcl_cv_api_fts = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_FTS 1
+_ACEOF
+
+fi
+
+#--------------------------------------------------------------------
# The statements below check for systems where POSIX-style
# non-blocking I/O (O_NONBLOCK) doesn't work or is unimplemented.
# On these systems (mostly older ones), use the old BSD-style
diff --git a/unix/configure.in b/unix/configure.in
index f64e499..decdade 100644
--- a/unix/configure.in
+++ b/unix/configure.in
@@ -3,7 +3,7 @@ dnl This file is an input file used by the GNU "autoconf" program to
dnl generate the file "configure", which is run during Tcl installation
dnl to configure the system for the local environment.
#
-# RCS: @(#) $Id: configure.in,v 1.138 2005/11/27 02:33:50 das Exp $
+# RCS: @(#) $Id: configure.in,v 1.139 2005/12/05 13:03:18 das Exp $
AC_INIT([tcl],[8.5])
AC_PREREQ(2.59)
@@ -433,6 +433,22 @@ AC_CHECK_FUNCS(chflags)
AC_CHECK_FUNCS(getattrlist)
#--------------------------------------------------------------------
+# Check for support of fts functions (readdir replacement)
+#--------------------------------------------------------------------
+
+AC_CACHE_CHECK([for fts], tcl_cv_api_fts, [
+ AC_TRY_LINK([#include <sys/param.h>
+ #include <sys/stat.h>
+ #include <fts.h>],
+ [char*const p[2] = {"/", NULL};
+ FTS *f = fts_open(p, FTS_PHYSICAL|FTS_NOCHDIR|FTS_NOSTAT, NULL);
+ FTSENT *e = fts_read(f); fts_close(f);],
+ tcl_cv_api_fts=yes, tcl_cv_api_fts=no)])
+if test $tcl_cv_api_fts = yes; then
+ AC_DEFINE(HAVE_FTS, 1, [Do we have fts functions?])
+fi
+
+#--------------------------------------------------------------------
# The statements below check for systems where POSIX-style
# non-blocking I/O (O_NONBLOCK) doesn't work or is unimplemented.
# On these systems (mostly older ones), use the old BSD-style
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index 1bc6e31..211dae3 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -1497,17 +1497,6 @@ dnl AC_CHECK_TOOL(AR, ar)
AC_CHECK_FUNCS(OSSpinLockLock)
AC_CHECK_HEADERS(copyfile.h)
AC_CHECK_FUNCS(copyfile)
- AC_CACHE_CHECK([for fts], tcl_cv_api_fts, [
- AC_TRY_LINK([#include <sys/param.h>
- #include <sys/stat.h>
- #include <fts.h>],
- [char*const p[2] = {"/", NULL};
- FTS *f = fts_open(p, FTS_PHYSICAL|FTS_NOCHDIR|FTS_NOSTAT, NULL);
- FTSENT *e = fts_read(f); fts_close(f);],
- tcl_cv_api_fts=yes, tcl_cv_api_fts=no)])
- if test $tcl_cv_api_fts = yes; then
- AC_DEFINE(HAVE_FTS, 1, [Do we have fts functions?])
- fi
AC_DEFINE(MAC_OSX_TCL, 1, [Is this a Mac I see before me?])
AC_DEFINE(USE_VFORK, 1, [Should we use vfork() instead of fork()?])
AC_DEFINE(TCL_DEFAULT_ENCODING,"utf-8",
diff --git a/unix/tclConfig.h.in b/unix/tclConfig.h.in
index 98d4908..91a5bb4 100644
--- a/unix/tclConfig.h.in
+++ b/unix/tclConfig.h.in
@@ -28,6 +28,9 @@
/* Do we have access to Darwin CoreFoundation.framework ? */
#undef HAVE_COREFOUNDATION
+/* Do we have fts functions? */
+#undef HAVE_FTS
+
/* Define to 1 if you have the `getattrlist' function. */
#undef HAVE_GETATTRLIST
diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c
index bdb4cef..e32c467 100644
--- a/unix/tclUnixFCmd.c
+++ b/unix/tclUnixFCmd.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixFCmd.c,v 1.50 2005/12/05 08:19:37 hobbs Exp $
+ * RCS: @(#) $Id: tclUnixFCmd.c,v 1.51 2005/12/05 13:03:18 das Exp $
*
* Portions of this code were derived from NetBSD source code which has the
* following copyright notice:
@@ -992,18 +992,15 @@ TraverseUnixTree(
result = (*traverseProc)(sourcePtr, targetPtr, &statBuf, DOTREE_POSTD,
errorPtr);
}
-
- end:
- if (errfile != NULL) {
- if (errorPtr != NULL) {
- Tcl_ExternalToUtfDString(NULL, errfile, -1, errorPtr);
- }
- result = TCL_ERROR;
- }
#else /* HAVE_FTS */
paths[0] = source;
fts = fts_open((char**)paths, FTS_PHYSICAL|FTS_NOCHDIR|
- (doRewind ? FTS_NOSTAT : 0), NULL); /* no need to stat for delete */
+#ifdef HAVE_STRUCT_STAT64
+ FTS_NOSTAT, /* fts doesn't do stat64 */
+#else
+ (doRewind ? FTS_NOSTAT : 0), /* no need to stat for delete */
+#endif
+ NULL);
if (fts == NULL) {
errfile = source;
goto end;
@@ -1019,6 +1016,7 @@ TraverseUnixTree(
char * path = ent->fts_path + sourceLen;
unsigned short pathlen = ent->fts_pathlen - sourceLen;
int type;
+ Tcl_StatBuf *statBufPtr = NULL;
if (info == FTS_DNR || info == FTS_ERR || info == FTS_NS) {
errfile = ent->fts_path;
@@ -1039,7 +1037,18 @@ TraverseUnixTree(
type = DOTREE_F;
break;
}
- result = (*traverseProc)(sourcePtr, targetPtr, ent->fts_statp, type,
+ if (!doRewind) { /* no need to stat for delete */
+#ifdef HAVE_STRUCT_STAT64
+ statBufPtr = &statBuf;
+ if (TclOSlstat(ent->fts_path, statBufPtr) != 0) {
+ errfile = ent->fts_path;
+ break;
+ }
+#else
+ statBufPtr = ent->fts_statp;
+#endif
+ }
+ result = (*traverseProc)(sourcePtr, targetPtr, statBufPtr, type,
errorPtr);
if (result != TCL_OK) {
break;
@@ -1049,6 +1058,7 @@ TraverseUnixTree(
Tcl_DStringSetLength(targetPtr, targetLen);
}
}
+#endif /* HAVE_FTS */
end:
if (errfile != NULL) {
@@ -1057,10 +1067,11 @@ TraverseUnixTree(
}
result = TCL_ERROR;
}
+#ifdef HAVE_FTS
if (fts != NULL) {
fts_close(fts);
}
-#endif /* HAVE_FTS */
+#endif
return result;
}