summaryrefslogtreecommitdiffstats
path: root/hl/Makefile.am
blob: 1f016b599204d9d3238885ec84848a43238881de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#
# Copyright (C) 2001 National Center for Supercomputing Applications.
#                    All rights reserved.
#
# 
# This makefile mostly just reinvokes make in the various subdirectories
# but does so in the correct order.  You can alternatively invoke make from
# each subdirectory manually.
##
## Makefile.am
## Run automake to generate a Makefile.in from this file.
##
#
# HDF5 High-Level Makefile(.in)

include $(top_srcdir)/config/commence.am

## Automake will automatically recurse into fortran directory for distclean
## if we define it conditionally.
if BUILD_FORTRAN_CONDITIONAL
  FORTRAN_DIR = fortran
endif
if BUILD_CXX_CONDITIONAL
  CXX_DIR = c++
endif

## Don't recurse into any subdirectories if HDF5 is not configured to
## use the HL library
if BUILD_HDF5_HL_CONDITIONAL
   SUBDIRS=src test $(CXX_DIR) $(FORTRAN_DIR)
endif

include $(top_srcdir)/config/conclude.am
n value='bug_bc1a96407a'>bug_bc1a96407a Tcl is a high-level, general-purpose, interpreted, dynamic programming language. It was designed with the goal of being very simple but powerful.
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat
-rw-r--r--ChangeLog45
-rw-r--r--doc/FileSystem.327
-rw-r--r--generic/tcl.decls8
-rw-r--r--generic/tclFCmd.c6
-rw-r--r--generic/tclFileName.c247
-rw-r--r--generic/tclIOUtil.c145
-rw-r--r--generic/tclInt.decls86
-rw-r--r--generic/tclInt.h23
-rw-r--r--generic/tclIntDecls.h142
-rw-r--r--generic/tclLoadNone.c6
-rw-r--r--generic/tclStubInit.c26
-rw-r--r--generic/tclTest.c155
-rw-r--r--mac/tclMacChan.c17
-rw-r--r--mac/tclMacFCmd.c452
-rw-r--r--mac/tclMacFile.c583
-rw-r--r--mac/tclMacLoad.c13
-rw-r--r--mac/tclMacPort.h10
-rw-r--r--mac/tclMacShLib.exp4
-rw-r--r--tests/fileName.test36
-rw-r--r--tests/winFCmd.test18
-rw-r--r--unix/tclLoadAout.c12
-rw-r--r--unix/tclLoadDl.c14
-rw-r--r--unix/tclLoadDld.c16
-rw-r--r--unix/tclLoadDyld.c7
-rw-r--r--unix/tclLoadNext.c9
-rw-r--r--unix/tclLoadOSF.c9
-rw-r--r--unix/tclLoadShl.c9
-rw-r--r--unix/tclUnixChan.c19
-rw-r--r--unix/tclUnixFCmd.c249
-rw-r--r--unix/tclUnixFile.c224
-rw-r--r--unix/tclUnixPort.h11
-rw-r--r--win/tclWinChan.c26
-rw-r--r--win/tclWinFCmd.c287
-rw-r--r--win/tclWinFile.c244
-rw-r--r--win/tclWinLoad.c7
-rw-r--r--win/tclWinPort.h3
36 files changed, 1319 insertions, 1876 deletions
diff --git a/ChangeLog b/ChangeLog
index 8c5ce27..8dcca50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,48 @@
+2001-08-30 Vince Darley <vincentdarley@users.sourceforge.net>
+
+ Further fs updates. After examining the most common Tcl
+ extensions (TclX, BLT, Tk, TclPro, Mktclapp), it has been
+ determined that only TclpGetCwd and the Access/Stat/Open
+ insert/delete hooks of the internal fs functions are ever used.
+ The remaining functions from Tcl's internal interfaces have
+ therefore been removed, since Tcl now exports a more suitable
+ public API (Tcl_FS...)
+
+ * generic/tclInt.stubs:
+ * generic/tclInt.h: updated for removed internal functions.
+ Some new internal functions have been put in tclInt.h (and
+ not exported in the stub table because good public equivalents
+ exist).
+ * generic/tclTest.c: some test functions used the internal private
+ APIs. These tests have been retained, but modified to use
+ public APIs. Also objectified the internal filesystem tests.
+ * win/tclWinFile.c: removed TclpStat, TclpAccess and refactored
+ code to use NativeAccess, NativeStat. This should speed up
+ stat, access and glob commands.
+ * win/tclWinFCmd.c: removed all TclpCopy/Rename/Delete
+ File/Directory string-based procedures which aren't used any more.
+ Improved efficiency of some other procedures. Ensure that filename
+ conversions with a NULL interp do not crash Tcl.
+ * mac/tclMacFCmd.c: wrapped long lines and cleaned up
+ TclpObjNormalizePath, removed all TclpCopy/Rename/Delete
+ File/Directory string-based procedures which aren't used any more.
+ * mac/tclMacFile.c: removed obsolete TclpStat, TclpAccess, TclpChdir,
+ etc.
+ * unix/tclUnixFCmd.c: removed use of TclpAccess, removed all
+ TclpCopy/Rename/Delete File/Directory string-based procedures which
+ aren't used any more.
+ * unix/tclUnixFile.c: removed obsolete TclpStat, TclpAccess, TclpChdir,
+ etc.
+ * tcl(Unix|Mac|Win)Chan.c: objectified TclpOpenFileChannel.
+ * various 'load' implementations all objectified.
+ * generic/tclFileName.c: removed redundant code.
+ * generic/tclIOUtil.c: removed TclStat, TclAccess, TclpListVolumes.
+ Fix to MatchInDirectory at the root of a volume. Also improved
+ some documentation, and improved default path joining behaviour
+ for virtual filesystems, especially regarding '~'.
+ * tests/fileName.test: added tests to check for bugs fixed above.
+ * doc/FileName.3: improved documentation
+
2001-08-30 David Gravereaux <davygrvy@pobox.com>
* generic/tclAsync.c:
diff --git a/doc/FileSystem.3 b/doc/FileSystem.3
index 7e49235..9836dea 100644
--- a/doc/FileSystem.3
+++ b/doc/FileSystem.3
@@ -4,13 +4,13 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: FileSystem.3,v 1.3 2001/08/23 17:37:07 vincentdarley Exp $
+'\" RCS: @(#) $Id: FileSystem.3,v 1.4 2001/08/30 08:53:14 vincentdarley Exp $
'\"
.so man.macros
.TH Tcl_FSCopyFile 3 8.4 Tcl "Tcl Library Procedures"
.BS
.SH NAME
-Tcl_FSRegister, Tcl_FSUnregister, Tcl_FSData, Tcl_FSCopyFile, Tcl_FSCopyDirectory, Tcl_FSCreateDirectory, Tcl_FSDeleteFile, Tcl_FSRemoveDirectory, Tcl_FSRenameFile, Tcl_FSListVolumes, Tcl_FSEvalFile, Tcl_FSLoadFile, Tcl_FSMatchInDirectory, Tcl_FSReadlink, Tcl_FSLstat, Tcl_FSUtime, Tcl_FSFileAttrsGet, Tcl_FSFileAttrsSet, Tcl_FSFileAttrStrings, Tcl_FSStat, Tcl_FSAccess, Tcl_FSOpenFileChannel, Tcl_FSGetCwd, Tcl_FSChdir, Tcl_FSPathSeparator, Tcl_FSJoinPath, Tcl_FSSplitPath, Tcl_FSEqualPaths, Tcl_FSGetNormalizedPath, Tcl_FSJoinToPath, Tcl_FSConvertToPathType, Tcl_FSGetInternalRep, Tcl_FSGetTranslatedPath, Tcl_FSGetTranslatedStringPath, Tcl_FSNewNativePath, Tcl_FSGetNativePath, Tcl_FSFileSystemInfo \- procedures to interact with any filesystem
+Tcl_FSRegister, Tcl_FSUnregister, Tcl_FSData, Tcl_FSCopyFile, Tcl_FSCopyDirectory, Tcl_FSCreateDirectory, Tcl_FSDeleteFile, Tcl_FSRemoveDirectory, Tcl_FSRenameFile, Tcl_FSListVolumes, Tcl_FSEvalFile, Tcl_FSLoadFile, Tcl_FSMatchInDirectory, Tcl_FSLink, Tcl_FSLstat, Tcl_FSUtime, Tcl_FSFileAttrsGet, Tcl_FSFileAttrsSet, Tcl_FSFileAttrStrings, Tcl_FSStat, Tcl_FSAccess, Tcl_FSOpenFileChannel, Tcl_FSGetCwd, Tcl_FSChdir, Tcl_FSPathSeparator, Tcl_FSJoinPath, Tcl_FSSplitPath, Tcl_FSEqualPaths, Tcl_FSGetNormalizedPath, Tcl_FSJoinToPath, Tcl_FSConvertToPathType, Tcl_FSGetInternalRep, Tcl_FSGetTranslatedPath, Tcl_FSGetTranslatedStringPath, Tcl_FSNewNativePath, Tcl_FSGetNativePath, Tcl_FSFileSystemInfo \- procedures to interact with any filesystem
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -589,7 +589,7 @@ typedef struct Tcl_Filesystem {
Tcl_FSOpenFileChannelProc *\fIopenFileChannelProc\fR;
Tcl_FSMatchInDirectoryProc *\fImatchInDirectoryProc\fR;
Tcl_FSUtimeProc *\fIutimeProc\fR;
- Tcl_FSReadlinkProc *\fIreadlinkProc\fR;
+ Tcl_FSLinkProc *\fIlinkProc\fR;
Tcl_FSListVolumesProc *\fIlistVolumesProc\fR;
Tcl_FSFileAttrStringsProc *\fIfileAttrStringsProc\fR;
Tcl_FSFileAttrsGetProc *\fIfileAttrsGetProc\fR;
@@ -917,20 +917,25 @@ should be changed to the values given in the \fItval\fR structure.
The return value is a standard Tcl result indicating whether an error
occurred in the process.
.PP
-.SH READLINKPROC
+.SH LINKPROC
.PP
-Function to process a 'Tcl_FSReadlink()' call. Should be implemented
+Function to process a 'Tcl_FSLink()' call. Should be implemented
only if the filesystem supports links, and may otherwise be NULL.
.PP
.CS
-typedef Tcl_Obj* Tcl_FSReadlinkProc(
- Tcl_Obj *\fIpathPtr\fR);
+typedef Tcl_Obj* Tcl_FSLinkProc(
+ Tcl_Obj *\fIpathPtr\fR,
+ Tcl_Obj *\fItoPtr\fR);
.CE
.PP
-The result is a Tcl_Obj specifying the contents of the symbolic link
-given by 'path', or NULL if the symbolic link could not be read. The
-result is owned by the caller, which should call Tcl_DecrRefCount when
-the result is no longer needed.
+If \fItoPtr\fR is NULL, the function is being asked to read the
+contents of a link. The result is a Tcl_Obj specifying the contents of
+the symbolic link given by 'path', or NULL if the symbolic link could
+not be read. The result is owned by the caller, which should call
+Tcl_DecrRefCount when the result is no longer needed. If \fItoPtr\fR
+is not NULL, the function should attempt to create a link. The result
+in this case should be \fItoPtr\fR if the link was successful and NULL
+otherwise. In this case the result is not owned by the caller.
.PP
.SH LISTVOLUMESPROC
.PP
diff --git a/generic/tcl.decls b/generic/tcl.decls
index 65ff02a..7a93099 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -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: tcl.decls,v 1.52 2001/08/23 17:37:07 vincentdarley Exp $
+# RCS: @(#) $Id: tcl.decls,v 1.53 2001/08/30 08:53:14 vincentdarley Exp $
library tcl
@@ -468,6 +468,7 @@ declare 128 generic {
declare 129 generic {
int Tcl_Eval(Tcl_Interp *interp, char *string)
}
+# This is obsolete, use Tcl_FSEvalFile
declare 130 generic {
int Tcl_EvalFile(Tcl_Interp *interp, char *fileName)
}
@@ -656,6 +657,7 @@ declare 184 generic {
declare 185 generic {
int Tcl_IsSafe(Tcl_Interp *interp)
}
+# Obsolete, use Tcl_FSJoinPath
declare 186 generic {
char * Tcl_JoinPath(int argc, char **argv, Tcl_DString *resultPtr)
}
@@ -698,6 +700,7 @@ declare 197 {unix win} {
Tcl_Channel Tcl_OpenCommandChannel(Tcl_Interp *interp, int argc, \
char **argv, int flags)
}
+# This is obsolete, use Tcl_FSOpenFileChannel
declare 198 generic {
Tcl_Channel Tcl_OpenFileChannel(Tcl_Interp *interp, char *fileName, \
char *modeString, int permissions)
@@ -845,6 +848,7 @@ declare 242 generic {
int Tcl_SplitList(Tcl_Interp *interp, CONST char *listStr, int *argcPtr, \
char ***argvPtr)
}
+# Obsolete, use Tcl_FSSplitPath
declare 243 generic {
void Tcl_SplitPath(CONST char *path, int *argcPtr, char ***argvPtr)
}
@@ -1279,6 +1283,8 @@ declare 364 generic {
int Tcl_ParseVarName (Tcl_Interp *interp, char *string, \
int numBytes, Tcl_Parse *parsePtr, int append)
}
+# These 4 functions are obsolete, use Tcl_FSGetCwd, Tcl_FSChdir,
+# Tcl_FSAccess and Tcl_FSStat
declare 365 generic {
char *Tcl_GetCwd(Tcl_Interp *interp, Tcl_DString *cwdPtr)
}
diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c
index 7f3c590..035446f 100644
--- a/generic/tclFCmd.c
+++ b/generic/tclFCmd.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclFCmd.c,v 1.10 2001/08/23 17:37:07 vincentdarley Exp $
+ * RCS: @(#) $Id: tclFCmd.c,v 1.11 2001/08/30 08:53:14 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -544,8 +544,8 @@ CopyRenameOneFile(interp, source, target, copyFlag, force)
/*
* The rename failed because the move was across file systems.
* Fall through to copy file and then remove original. Note that
- * the low-level TclpRenameFile is allowed to implement
- * cross-filesystem moves itself.
+ * the low-level Tcl_FSRenameFileProc in the filesystem is allowed
+ * to implement cross-filesystem moves itself, if it desires.
*/
}
diff --git a/generic/tclFileName.c b/generic/tclFileName.c
index e4c484d..1839564 100644
--- a/generic/tclFileName.c
+++ b/generic/tclFileName.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: tclFileName.c,v 1.18 2001/08/23 18:20:50 hobbs Exp $
+ * RCS: @(#) $Id: tclFileName.c,v 1.19 2001/08/30 08:53:14 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -1110,7 +1110,7 @@ TclpNativeJoinPath(prefix, joining)
* exactly one separator inbetween (unless the object we're
* adding contains multiple contiguous colons, all of which
* we must add). Also if an object is just ':' we don't
- * both to add it unless it's the very first element.
+ * bother to add it unless it's the very first element.
*/
#ifdef MAC_UNDERSTANDS_UNIX_PATHS
@@ -1184,7 +1184,9 @@ TclpNativeJoinPath(prefix, joining)
*
* Tcl_JoinPath --
*
- * Combine a list of paths in a platform specific manner.
+ * Combine a list of paths in a platform specific manner. The
+ * function 'Tcl_FSJoinPath' should be used in preference where
+ * possible.
*
* Results:
* Appends the joined path to the end of the specified
@@ -1203,225 +1205,28 @@ Tcl_JoinPath(argc, argv, resultPtr)
char **argv;
Tcl_DString *resultPtr; /* Pointer to previously initialized DString. */
{
- int oldLength, length, i, needsSep;
- char c, *dest;
- CONST char *p;
- Tcl_PathType type = TCL_PATH_ABSOLUTE;
-
- oldLength = Tcl_DStringLength(resultPtr);
-
- switch (tclPlatform) {
- case TCL_PLATFORM_UNIX:
- for (i = 0; i < argc; i++) {
- p = argv[i];
- /*
- * If the path is absolute, reset the result buffer.
- * Consume any duplicate leading slashes or a ./ in
- * front of a tilde prefixed path that isn't at the
- * beginning of the path.
- */
-
-#ifdef __QNX__
- /*
- * Check for QNX //<node id> prefix
- */
- if (*p && (strlen(p) > 3) && (p[0] == '/') && (p[1] == '/')
- && isdigit(UCHAR(p[2]))) { /* INTL: digit */
- p += 3;
- while (isdigit(UCHAR(*p))) { /* INTL: digit */
- ++p;
- }
- }
-#endif
- if (*p == '/') {
- Tcl_DStringSetLength(resultPtr, oldLength);
- Tcl_DStringAppend(resultPtr, "/", 1);
- while (*p == '/') {
- p++;
- }
- } else if (*p == '~') {
- Tcl_DStringSetLength(resultPtr, oldLength);
- } else if ((Tcl_DStringLength(resultPtr) != oldLength)
- && (p[0] == '.') && (p[1] == '/')
- && (p[2] == '~')) {
- p += 2;
- }
-
- if (*p == '\0') {
- continue;
- }
-
- /*
- * Append a separator if needed.
- */
-
- length = Tcl_DStringLength(resultPtr);
- if ((length != oldLength)
- && (Tcl_DStringValue(resultPtr)[length-1] != '/')) {
- Tcl_DStringAppend(resultPtr, "/", 1);
- length++;
- }
-
- /*
- * Append the element, eliminating duplicate and trailing
- * slashes.
- */
-
- Tcl_DStringSetLength(resultPtr, (int) (length + strlen(p)));
- dest = Tcl_DStringValue(resultPtr) + length;
- for (; *p != '\0'; p++) {
- if (*p == '/') {
- while (p[1] == '/') {
- p++;
- }
- if (p[1] != '\0') {
- *dest++ = '/';
- }
- } else {
- *dest++ = *p;
- }
- }
- length = dest - Tcl_DStringValue(resultPtr);
- Tcl_DStringSetLength(resultPtr, length);
- }
- break;
-
- case TCL_PLATFORM_WINDOWS:
- /*
- * Iterate over all of the components. If a component is
- * absolute, then reset the result and start building the
- * path from the current component on.
- */
-
- for (i = 0; i < argc; i++) {
- p = ExtractWinRoot(argv[i], resultPtr, oldLength, &type);
- length = Tcl_DStringLength(resultPtr);
-
- /*
- * If the pointer didn't move, then this is a relative path
- * or a tilde prefixed path.
- */
-
- if (p == argv[i]) {
- /*
- * Remove the ./ from tilde prefixed elements unless
- * it is the first component.
- */
-
- if ((length != oldLength)
- && (p[0] == '.')
- && ((p[1] == '/') || (p[1] == '\\'))
- && (p[2] == '~')) {
- p += 2;
- } else if (*p == '~') {
- Tcl_DStringSetLength(resultPtr, oldLength);
- length = oldLength;
- }
- }
-
- if (*p != '\0') {
- /*
- * Check to see if we need to append a separator.
- */
-
-
- if (length != oldLength) {
- c = Tcl_DStringValue(resultPtr)[length-1];
- if ((c != '/') && (c != ':')) {
- Tcl_DStringAppend(resultPtr, "/", 1);
- }
- }
-
- /*
- * Append the element, eliminating duplicate and
- * trailing slashes.
- */
-
- length = Tcl_DStringLength(resultPtr);
- Tcl_DStringSetLength(resultPtr, (int) (length + strlen(p)));
- dest = Tcl_DStringValue(resultPtr) + length;
- for (; *p != '\0'; p++) {
- if ((*p == '/') || (*p == '\\')) {
- while ((p[1] == '/') || (p[1] == '\\')) {
- p++;
- }
- if (p[1] != '\0') {
- *dest++ = '/';
- }
- } else {
- *dest++ = *p;
- }
- }
- length = dest - Tcl_DStringValue(resultPtr);
- Tcl_DStringSetLength(resultPtr, length);
- }
- }
- break;
-
- case TCL_PLATFORM_MAC:
- needsSep = 1;
- for (i = 0; i < argc; i++) {
- Tcl_Obj *splitPtr;
- Tcl_Obj *eltPtr;
- int eltLen;
- int splitIndex = 0;
- int splitElements;
-
- splitPtr = SplitMacPath(argv[i]);
-
- Tcl_ListObjLength(NULL, splitPtr, &splitElements);
- if (splitElements == 0) {
- Tcl_DecrRefCount(splitPtr);
- continue;
- }
-
- Tcl_ListObjIndex(NULL, splitPtr, 0, &eltPtr);
- p = Tcl_GetStringFromObj(eltPtr, &eltLen);
- if ((eltLen != 0) && (*p != ':') && (strchr(p, ':') != NULL)) {
- Tcl_DStringSetLength(resultPtr, oldLength);
- length = strlen(p);
- Tcl_DStringAppend(resultPtr, p, eltLen);
- needsSep = 0;
- splitIndex++;
- }
-
- /*
- * Now append the rest of the path elements, skipping
- * : unless it is the first element of the path, and
- * watching out for :: et al. so we don't end up with
- * too many colons in the result.
- */
-
- for (; splitIndex < splitElements; splitIndex++) {
- Tcl_ListObjIndex(NULL, splitPtr, splitIndex, &eltPtr);
- p = Tcl_GetStringFromObj(eltPtr, &eltLen);
- if (p[0] == ':' && p[1] == '\0') {
- if (Tcl_DStringLength(resultPtr) != oldLength) {
- p++;
- } else {
- needsSep = 0;
- }
- } else {
- c = p[1];
- if (*p == ':') {
- if (!needsSep) {
- p++;
- }
- } else {
- if (needsSep) {
- Tcl_DStringAppend(resultPtr, ":", 1);
- }
- }
- needsSep = (c == ':') ? 0 : 1;
- }
- length = strlen(p);
- Tcl_DStringAppend(resultPtr, p, length);
- }
- Tcl_DecrRefCount(splitPtr);
- }
- break;
-
+ int i, len;
+ Tcl_Obj *listObj = Tcl_NewObj();
+ Tcl_Obj *resultObj;
+ char *resultStr;
+
+ /* Build the list of paths */
+ for (i = 0; i < argc; i++) {
+ Tcl_ListObjAppendElement(NULL, listObj, Tcl_NewStringObj(argv[i],-1));
}
+
+ /* Ask the objectified code to join the paths */
+ Tcl_IncrRefCount(listObj);
+ resultObj = Tcl_FSJoinPath(listObj, argc);
+ Tcl_IncrRefCount(resultObj);
+ Tcl_DecrRefCount(listObj);
+
+ /* Store the result */
+ resultStr = Tcl_GetStringFromObj(resultObj, &len);
+ Tcl_DStringAppend(resultPtr, resultStr, len);
+ Tcl_DecrRefCount(resultObj);
+
+ /* Return a pointer to the result */
return Tcl_DStringValue(resultPtr);
}
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index d5fa64c..2406215 100644
--- a/generic/tclIOUtil.c
+++ b/generic/tclIOUtil.c
@@ -17,7 +17,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIOUtil.c,v 1.16 2001/08/23 18:20:50 hobbs Exp $
+ * RCS: @(#) $Id: tclIOUtil.c,v 1.17 2001/08/30 08:53:14 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -71,29 +71,11 @@ extern CONST TclFileAttrProcs tclpFileAttrProcs[];
/*
* The following functions are obsolete string based APIs, and should
- * be removed in a future release.
+ * be removed in a future release (Tcl 9 would be a good time).
*/
/* Obsolete */
int
-TclStat(path, buf)
- CONST char *path; /* Path of file to stat (in current CP). */
- struct stat *buf; /* Filled with results of stat call. */
-{
- return Tcl_Stat(path,buf);
-}
-
-/* Obsolete */
-int
-TclAccess(path, mode)
- CONST char *path; /* Path of file to access (in current CP). */
- int mode; /* Permission setting. */
-{
- return Tcl_Access(path, mode);
-}
-
-/* Obsolete */
-int
Tcl_Stat(path, buf)
CONST char *path; /* Path of file to stat (in current CP). */
struct stat *buf; /* Filled with results of stat call. */
@@ -187,17 +169,6 @@ Tcl_EvalFile(interp, fileName)
return ret;
}
-/* Obsolete */
-int
-TclpListVolumes(
- Tcl_Interp *interp) /* Interpreter for returning volume list. */
-{
- Tcl_Obj *resultPtr = TclpObjListVolumes();
- Tcl_SetObjResult(interp, resultPtr);
- Tcl_DecrRefCount(resultPtr);
- return TCL_OK;
-}
-
/*
* The 3 hooks for Stat, Access and OpenFileChannel are obsolete. The
@@ -207,6 +178,9 @@ TclpListVolumes(
* from stubs/tclInt. The only known users of these APIs are prowrap
* and mktclapp. New code/extensions should not use them, since they
* do not provide as full support as the full filesystem API.
+ *
+ * As soon as prowrap and mktclapp are updated to use the full
+ * filesystem support, I suggest all these hooks are removed.
*/
#define USE_OBSOLETE_FS_HOOKS
@@ -299,8 +273,6 @@ static Tcl_FSCreateInternalRepProc NativeCreateNativeRep;
static Tcl_FSFileAttrStringsProc NativeFileAttrStrings;
static Tcl_FSFileAttrsGetProc NativeFileAttrsGet;
static Tcl_FSFileAttrsSetProc NativeFileAttrsSet;
-static Tcl_FSLoadFileProc NativeLoadFile;
-static Tcl_FSOpenFileChannelProc NativeOpenFileChannel;
static Tcl_FSUtimeProc NativeUtime;
/*
@@ -345,7 +317,7 @@ static Tcl_Filesystem nativeFilesystem = {
&NativeFilesystemSeparator,
&TclpObjStat,
&TclpObjAccess,
- &NativeOpenFileChannel,
+ &TclpOpenFileChannel,
&TclpMatchInDirectory,
&NativeUtime,
#ifndef S_IFLNK
@@ -364,7 +336,7 @@ static Tcl_Filesystem nativeFilesystem = {
&TclpObjCopyFile,
&TclpObjRenameFile,
&TclpObjCopyDirectory,
- &NativeLoadFile,
+ &TclpLoadFile,
&TclpUnloadFile,
&TclpObjGetCwd,
&TclpObjChdir
@@ -1602,19 +1574,33 @@ Tcl_FSMatchInDirectory(interp, result, pathPtr, pattern, types)
if (proc != NULL) {
int cwdLen;
Tcl_Obj *cwdDir;
+ char *cwdStr;
+#ifdef MAC_TCL
+ char sep = ':';
+#else
+ char sep = '/';
+#endif
Tcl_Obj* tmpResultPtr = Tcl_NewListObj(0, NULL);
/*
* We know the cwd is a normalised object which does
- * not end in a directory delimiter.
+ * not end in a directory delimiter, unless the cwd
+ * is the name of a volume, in which case it will
+ * end in a delimiter! We handle this situation here.
+ * A better test than the '!= sep' might be to simply
+ * check if 'cwd' is a root volume.
+ *
+ * Note that if we get this wrong, we will strip off
+ * either too much or too little below, leading to
+ * wrong answers returned by glob.
*/
cwdDir = Tcl_DuplicateObj(cwd);
-#ifdef MAC_TCL
- Tcl_AppendToObj(cwdDir, ":", 1);
-#else
- Tcl_AppendToObj(cwdDir, "/", 1);
-#endif
- Tcl_GetStringFromObj(cwdDir, &cwdLen);
Tcl_IncrRefCount(cwdDir);
+ cwdStr = Tcl_GetStringFromObj(cwdDir, &cwdLen);
+ if (cwdStr[cwdLen-1] != sep) {
+ Tcl_AppendToObj(cwdDir, &sep, 1);
+ cwdLen++;
+ /* Note: cwdStr may no longer be a valid pointer */
+ }
ret = (*proc)(interp, tmpResultPtr, cwdDir, pattern, types);
Tcl_DecrRefCount(cwdDir);
if (ret == TCL_OK) {
@@ -2636,10 +2622,13 @@ Tcl_FSJoinPath(listObj, elements)
int driveNameLength;
Tcl_PathType type;
char *strElt;
+ int strEltLen;
+ int length;
+ char *ptr;
Tcl_Obj *driveName = NULL;
Tcl_ListObjIndex(NULL, listObj, i, &elt);
- strElt = Tcl_GetString(elt);
+ strElt = Tcl_GetStringFromObj(elt, &strEltLen);
type = GetPathType(elt, &fsPtr, &driveNameLength, &driveName);
if (type != TCL_PATH_RELATIVE) {
/* Zero out the current result */
@@ -2653,6 +2642,19 @@ Tcl_FSJoinPath(listObj, elements)
strElt += driveNameLength;
}
+ ptr = Tcl_GetStringFromObj(res, &length);
+
+ /*
+ * Strip off any './' before a tilde, unless this is the
+ * beginning of the path.
+ */
+ if (length > 0 && strEltLen > 0) {
+ if ((strElt[0] == '.') && (strElt[1] == '/')
+ && (strElt[2] == '~')) {
+ strElt += 2;
+ }
+ }
+
/*
* A NULL value for fsPtr at this stage basically means
* we're trying to join a relative path onto something
@@ -2664,9 +2666,7 @@ Tcl_FSJoinPath(listObj, elements)
if (fsPtr == &nativeFilesystem || fsPtr == NULL) {
TclpNativeJoinPath(res, strElt);
} else {
- int length;
char separator = '/';
- char *ptr;
int needsSep = 0;
if (fsPtr->filesystemSeparatorProc != NULL) {
@@ -2675,7 +2675,7 @@ Tcl_FSJoinPath(listObj, elements)
separator = Tcl_GetString(sep)[0];
}
}
- ptr = Tcl_GetStringFromObj(res, &length);
+
if (length > 0 && ptr[length -1] != '/') {
Tcl_AppendToObj(res, &separator, 1);
length++;
@@ -3735,6 +3735,17 @@ Tcl_FSGetInternalRep(pathObjPtr, fsPtr)
* to allow this sub-optimal routing.
*/
Tcl_FSGetFileSystemForPath(pathObjPtr);
+
+ /*
+ * If we fail through here, then the path is probably not a
+ * valid path in the filesystsem, and is most likely to be a
+ * use of the empty path "" via a direct call to one of the
+ * objectified interfaces (e.g. from the Tcl testsuite).
+ */
+ srcFsPathPtr = (FsPath*) pathObjPtr->internalRep.otherValuePtr;
+ if (srcFsPathPtr->fsRecPtr == NULL) {
+ return NULL;
+ }
}
if (fsPtr != srcFsPathPtr->fsRecPtr->fsPtr) {
@@ -3915,6 +3926,11 @@ NativeDupInternalRep(clientData)
* Any path object is acceptable to the native filesystem, by
* default (we will throw errors when illegal paths are actually
* tried to be used).
+ *
+ * However, this behavior means the native filesystem must be
+ * the last filesystem in the lookup list (otherwise it will
+ * claim all files belong to it, and other filesystems will
+ * never get a look in).
*
* Results:
* TCL_OK, to indicate 'yes', -1 to indicate no.
@@ -4262,22 +4278,6 @@ Tcl_FSEqualPaths(firstPtr, secondPtr)
return 0;
}
-/* Wrappers */
-
-static Tcl_Channel
-NativeOpenFileChannel(interp, pathPtr, modeString, permissions)
- Tcl_Interp *interp;
- Tcl_Obj *pathPtr;
- char *modeString;
- int permissions;
-{
- Tcl_Obj *trans = Tcl_FSGetTranslatedPath(interp, pathPtr);
- if (trans == NULL) {
- return NULL;
- }
- return TclpOpenFileChannel(interp, Tcl_GetString(trans), modeString, permissions);
-}
-
/*
* utime wants a normalized, NOT native path. I assume a native
* version of 'utime' doesn't exist (at least under that name) on NT/2000.
@@ -4304,27 +4304,6 @@ NativeUtime(pathPtr, tval)
#endif
}
-static int
-NativeLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
- Tcl_Interp * interp;
- Tcl_Obj *pathPtr;
- char * sym1;
- char * sym2;
- Tcl_PackageInitProc ** proc1Ptr;
- Tcl_PackageInitProc ** proc2Ptr;
- ClientData * clientDataPtr;
-{
- char *path;
- Tcl_Obj *transPtr = Tcl_FSGetTranslatedPath(NULL, pathPtr);
- if (transPtr == NULL) {
- path = NULL;
- } else {
- path = Tcl_GetString(transPtr);
- }
- return TclpLoadFile(interp, path,
- sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr);
-}
-
/* Everything from here on is contained in this obsolete ifdef */
#ifdef USE_OBSOLETE_FS_HOOKS
diff --git a/generic/tclInt.decls b/generic/tclInt.decls
index b0b883b..7b1dac5 100644
--- a/generic/tclInt.decls
+++ b/generic/tclInt.decls
@@ -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: tclInt.decls,v 1.29 2001/07/31 19:12:06 vincentdarley Exp $
+# RCS: @(#) $Id: tclInt.decls,v 1.30 2001/08/30 08:53:14 vincentdarley Exp $
library tcl
@@ -23,9 +23,10 @@ interface tclInt
# Use at your own risk. Note that the position of functions should not
# be changed between versions to avoid gratuitous incompatibilities.
-declare 0 generic {
- int TclAccess(CONST char *path, int mode)
-}
+# Replaced by Tcl_FSAccess in 8.4:
+#declare 0 generic {
+# int TclAccess(CONST char *path, int mode)
+#}
declare 1 generic {
int TclAccessDeleteProc(TclAccessProc_ *proc)
}
@@ -268,9 +269,10 @@ declare 66 generic {
declare 67 generic {
int TclOpenFileChannelInsertProc(TclOpenFileChannelProc_ *proc)
}
-declare 68 generic {
- int TclpAccess(CONST char *path, int mode)
-}
+# Replaced by Tcl_FSAccess in 8.4:
+#declare 68 generic {
+# int TclpAccess(CONST char *path, int mode)
+#}
declare 69 generic {
char * TclpAlloc(unsigned int size)
}
@@ -302,13 +304,15 @@ declare 77 generic {
declare 78 generic {
int TclpGetTimeZone(unsigned long time)
}
-declare 79 generic {
- int TclpListVolumes(Tcl_Interp *interp)
-}
-declare 80 generic {
- Tcl_Channel TclpOpenFileChannel(Tcl_Interp *interp, char *fileName, \
- char *modeString, int permissions)
-}
+# Replaced by Tcl_FSListVolumes in 8.4:
+#declare 79 generic {
+# int TclpListVolumes(Tcl_Interp *interp)
+#}
+# Replaced by Tcl_FSOpenFileChannel in 8.4:
+#declare 80 generic {
+# Tcl_Channel TclpOpenFileChannel(Tcl_Interp *interp, char *fileName, \
+# char *modeString, int permissions)
+#}
declare 81 generic {
char * TclpRealloc(char *ptr, unsigned int size)
}
@@ -362,9 +366,10 @@ declare 94 generic {
int TclProcInterpProc(ClientData clientData, Tcl_Interp *interp, \
int argc, char **argv)
}
-declare 95 generic {
- int TclpStat(CONST char *path, struct stat *buf)
-}
+# Replaced by Tcl_FSStat in 8.4:
+#declare 95 generic {
+# int TclpStat(CONST char *path, struct stat *buf)
+#}
declare 96 generic {
int TclRenameCommand(Tcl_Interp *interp, char *oldName, char *newName)
}
@@ -395,9 +400,10 @@ declare 103 generic {
declare 104 {unix win} {
int TclSockMinimumBuffers(int sock, int size)
}
-declare 105 generic {
- int TclStat(CONST char *path, struct stat *buf)
-}
+# Replaced by Tcl_FSStat in 8.4:
+#declare 105 generic {
+# int TclStat(CONST char *path, struct stat *buf)
+#}
declare 106 generic {
int TclStatDeleteProc(TclStatProc_ *proc)
}
@@ -520,17 +526,18 @@ declare 135 generic {
declare 138 generic {
char * TclGetEnv(CONST char *name, Tcl_DString *valuePtr)
}
-declare 139 generic {
- int TclpLoadFile(Tcl_Interp *interp, char *fileName, char *sym1, \
- char *sym2, Tcl_PackageInitProc **proc1Ptr, \
- Tcl_PackageInitProc **proc2Ptr, ClientData *clientDataPtr)
-}
+#declare 139 generic {
+# int TclpLoadFile(Tcl_Interp *interp, char *fileName, char *sym1, \
+# char *sym2, Tcl_PackageInitProc **proc1Ptr, \
+# Tcl_PackageInitProc **proc2Ptr, ClientData *clientDataPtr)
+#}
declare 140 generic {
int TclLooksLikeInt(char *bytes, int length)
}
-#declare 141 generic {
-# char *TclpGetCwd(Tcl_Interp *interp, Tcl_DString *cwdPtr)
-#}
+# This is used by TclX, but should otherwise be considered private
+declare 141 generic {
+ char *TclpGetCwd(Tcl_Interp *interp, Tcl_DString *cwdPtr)
+}
declare 142 generic {
int TclSetByteCodeFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr, \
CompileHookProc *hookProc, ClientData clientData)
@@ -616,29 +623,8 @@ declare 161 generic {
declare 162 generic {
void TclChannelEventScriptInvoker(ClientData clientData, int flags)
}
-# for virtual filesystem support. These should eventually be moved to
-# Tcl's external API and properly documented, to allow extension writers
-# to use them easily (hence providing automatic VFS support to all
-# extensions)
+# These functions are vfs aware, but are generally only useful internally.
declare 163 generic {
- int TclFileCopyCmd(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
-}
-declare 164 generic {
- int TclFileRenameCmd(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
-}
-declare 165 generic {
- int TclFileDeleteCmd(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
-}
-declare 166 generic {
- int TclFileMakeDirsCmd(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
-}
-declare 167 generic {
- int TclFileAttrsCmd(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
-}
-declare 168 generic {
- Tcl_Obj* TclpTempFileName(void)
-}
-declare 169 generic {
void TclpSetInitialEncodings(void)
}
diff --git a/generic/tclInt.h b/generic/tclInt.h