summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tclFileName.c9
-rw-r--r--generic/tclPathObj.c52
-rw-r--r--generic/tclPlatDecls.h12
3 files changed, 40 insertions, 33 deletions
diff --git a/generic/tclFileName.c b/generic/tclFileName.c
index 893f68c..847f954 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.86.2.4 2009/08/21 19:03:20 dgp Exp $
+ * RCS: @(#) $Id: tclFileName.c,v 1.86.2.5 2010/05/21 12:18:17 nijtmans Exp $
*/
#include "tclInt.h"
@@ -1891,7 +1891,7 @@ TclGlob(
* for existence and type.
*/
if (types == NULL) {
- /*
+ /*
* We just want to check for existence. In this case we
* make it easy on Tcl_FSMatchInDirectory and its
* sub-implementations by not bothering them (even though
@@ -1903,7 +1903,7 @@ TclGlob(
}
result = TCL_OK;
} else {
- /*
+ /*
* We want to check for the correct type. Tcl_FSMatchInDirectory
* is documented to do this for us, if we give it a NULL pattern.
*/
@@ -1952,7 +1952,7 @@ TclGlob(
if (pathPrefix == NULL) {
Tcl_Panic("Called TclGlob with TCL_GLOBMODE_TAILS and pathPrefix==NULL");
}
-
+
pre = Tcl_GetStringFromObj(pathPrefix, &prefixLen);
if (prefixLen > 0
&& (strchr(separators, pre[prefixLen-1]) == NULL)) {
@@ -2434,7 +2434,6 @@ DoGlob(
#if defined(__CYGWIN__) && defined(__WIN32__)
{
- extern int cygwin_conv_to_win32_path(const char *, char *);
char winbuf[MAX_PATH+1];
cygwin_conv_to_win32_path(Tcl_DStringValue(&append), winbuf);
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c
index 13eeb2b..de39f44 100644
--- a/generic/tclPathObj.c
+++ b/generic/tclPathObj.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: tclPathObj.c,v 1.66.2.11 2010/01/05 18:58:12 dgp Exp $
+ * RCS: @(#) $Id: tclPathObj.c,v 1.66.2.12 2010/05/21 12:18:17 nijtmans Exp $
*/
#include "tclInt.h"
@@ -113,7 +113,7 @@ typedef struct FsPath {
#define PATHOBJ(pathPtr) ((FsPath *) (pathPtr)->internalRep.otherValuePtr)
#define SETPATHOBJ(pathPtr,fsPathPtr) \
- ((pathPtr)->internalRep.otherValuePtr = (VOID *) (fsPathPtr))
+ ((pathPtr)->internalRep.otherValuePtr = (void *) (fsPathPtr))
#define PATHFLAGS(pathPtr) (PATHOBJ(pathPtr)->flags)
/*
@@ -239,7 +239,7 @@ TclFSNormalizeAbsolutePath(
retVal = Tcl_NewStringObj(path, dirSep - path);
Tcl_IncrRefCount(retVal);
}
- Tcl_GetStringFromObj(retVal, &curLen);
+ (void) Tcl_GetStringFromObj(retVal, &curLen);
if (curLen == 0) {
Tcl_AppendToObj(retVal, dirSep, 1);
}
@@ -261,10 +261,11 @@ TclFSNormalizeAbsolutePath(
if (retVal == NULL) {
const char *path = TclGetString(pathPtr);
+
retVal = Tcl_NewStringObj(path, dirSep - path);
Tcl_IncrRefCount(retVal);
}
- Tcl_GetStringFromObj(retVal, &curLen);
+ (void) Tcl_GetStringFromObj(retVal, &curLen);
if (curLen == 0) {
Tcl_AppendToObj(retVal, dirSep, 1);
}
@@ -322,6 +323,7 @@ TclFSNormalizeAbsolutePath(
if (tclPlatform == TCL_PLATFORM_WINDOWS) {
int i;
+
for (i = 0; i < curLen; i++) {
if (linkStr[i] == '\\') {
linkStr[i] = '/';
@@ -707,6 +709,7 @@ TclPathPart(
} else {
Tcl_Obj *root = Tcl_NewStringObj(fileName,
(int) (length - strlen(extension)));
+
Tcl_IncrRefCount(root);
return root;
}
@@ -879,7 +882,6 @@ Tcl_FSJoinPath(
if ((i == (elements-2)) && (i == 0) && (elt->typePtr == &tclFsPathType)
&& !(elt->bytes != NULL && (elt->bytes[0] == '\0'))) {
Tcl_Obj *tail;
- Tcl_PathType type;
Tcl_ListObjIndex(NULL, listObj, i+1, &tail);
type = TclGetPathType(tail, NULL, NULL, NULL);
@@ -929,7 +931,7 @@ Tcl_FSJoinPath(
/*
* Otherwise we don't have an easy join, and we must let the
- * more general code below handle things
+ * more general code below handle things.
*/
} else if (tclPlatform == TCL_PLATFORM_UNIX) {
if (res != NULL) {
@@ -937,7 +939,7 @@ Tcl_FSJoinPath(
}
return tail;
} else {
- const char *str = Tcl_GetString(tail);
+ const char *str = TclGetString(tail);
if (tclPlatform == TCL_PLATFORM_WINDOWS) {
if (strchr(str, '\\') == NULL) {
@@ -1150,7 +1152,6 @@ Tcl_FSConvertToPathType(
return TCL_OK;
}
-
if (pathPtr->bytes == NULL) {
UpdateStringOfFsPath(pathPtr);
}
@@ -1738,9 +1739,7 @@ Tcl_FSGetTranslatedPath(
* translated result we need, and can store it for future use.
*/
- Tcl_Obj *translatedCwdPtr;
-
- translatedCwdPtr = Tcl_FSGetTranslatedPath(interp,
+ Tcl_Obj *translatedCwdPtr = Tcl_FSGetTranslatedPath(interp,
srcFsPathPtr->cwdPtr);
if (translatedCwdPtr == NULL) {
return NULL;
@@ -1851,8 +1850,7 @@ Tcl_FSGetNormalizedPath(
*/
Tcl_Obj *dir, *copy;
- int cwdLen;
- int pathType;
+ int cwdLen, pathType;
ClientData clientData = NULL;
pathType = Tcl_FSGetPathType(fsPathPtr->cwdPtr);
@@ -1951,6 +1949,7 @@ Tcl_FSGetNormalizedPath(
* TclFSNormalizeToUniquePath call above should have already
* set this up. Not changing out of fear of the unknown.
*/
+
fsPathPtr->nativePathPtr = clientData;
}
PATHFLAGS(pathPtr) = 0;
@@ -2007,6 +2006,7 @@ Tcl_FSGetNormalizedPath(
Tcl_Obj *absolutePath = fsPathPtr->translatedPathPtr;
const char *path = TclGetString(absolutePath);
+
Tcl_IncrRefCount(absolutePath);
/*
@@ -2027,8 +2027,8 @@ Tcl_FSGetNormalizedPath(
* In particular, capture the cwd value and save so it can be
* stored in the cwdPtr field below.
*/
- useThisCwd = Tcl_FSGetCwd(interp);
+ useThisCwd = Tcl_FSGetCwd(interp);
} else {
/*
* We don't ask for the type of 'pathPtr' here, because that is
@@ -2105,7 +2105,7 @@ Tcl_FSGetNormalizedPath(
fsPathPtr->normPathPtr = pathPtr;
}
- }
+ }
if (useThisCwd != NULL) {
/*
* We just need to free an object we allocated above for relative
@@ -2417,6 +2417,9 @@ SetFsPathFromAny(
FsPath *fsPathPtr;
Tcl_Obj *transPtr;
char *name;
+#if defined(__CYGWIN__) && defined(__WIN32__)
+ int copied = 0;
+#endif
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&tclFsDataKey);
if (pathPtr->typePtr == &tclFsPathType) {
@@ -2447,7 +2450,7 @@ SetFsPathFromAny(
char *expandedUser;
Tcl_DString temp;
int split;
- char separator='/';
+ char separator = '/';
split = FindSplitPos(name, separator);
if (split != len) {
@@ -2562,7 +2565,6 @@ SetFsPathFromAny(
#if defined(__CYGWIN__) && defined(__WIN32__)
{
- extern int cygwin_conv_to_win32_path(const char *, char *);
char winbuf[MAX_PATH+1];
/*
@@ -2575,6 +2577,11 @@ SetFsPathFromAny(
if (len > 0) {
cygwin_conv_to_win32_path(name, winbuf);
TclWinNoBackslash(winbuf);
+ if (Tcl_IsShared(transPtr)) {
+ copied = 1;
+ transPtr = Tcl_DuplicateObj(transPtr);
+ Tcl_IncrRefCount(transPtr);
+ }
Tcl_SetStringObj(transPtr, winbuf, -1);
}
}
@@ -2605,6 +2612,11 @@ SetFsPathFromAny(
SETPATHOBJ(pathPtr, fsPathPtr);
PATHFLAGS(pathPtr) = 0;
pathPtr->typePtr = &tclFsPathType;
+#if defined(__CYGWIN__) && defined(__WIN32__)
+ if (copied) {
+ Tcl_DecrRefCount(transPtr);
+ }
+#endif
return TCL_OK;
}
@@ -2632,6 +2644,7 @@ FreeFsPathInternalRep(
if (fsPathPtr->nativePathPtr != NULL && fsPathPtr->fsRecPtr != NULL) {
Tcl_FSFreeInternalRepProc *freeProc =
fsPathPtr->fsRecPtr->fsPtr->freeInternalRepProc;
+
if (freeProc != NULL) {
(*freeProc)(fsPathPtr->nativePathPtr);
fsPathPtr->nativePathPtr = NULL;
@@ -2648,7 +2661,7 @@ FreeFsPathInternalRep(
}
}
- ckfree((char*) fsPathPtr);
+ ckfree((char *) fsPathPtr);
}
static void
@@ -2692,6 +2705,7 @@ DupFsPathInternalRep(
&& srcFsPathPtr->nativePathPtr != NULL) {
Tcl_FSDupInternalRepProc *dupProc =
srcFsPathPtr->fsRecPtr->fsPtr->dupInternalRepProc;
+
if (dupProc != NULL) {
copyFsPathPtr->nativePathPtr =
(*dupProc)(srcFsPathPtr->nativePathPtr);
@@ -2801,7 +2815,7 @@ TclNativePathInFilesystem(
int len;
- Tcl_GetStringFromObj(pathPtr, &len);
+ (void) Tcl_GetStringFromObj(pathPtr, &len);
if (len == 0) {
/*
* We reject the empty path "".
diff --git a/generic/tclPlatDecls.h b/generic/tclPlatDecls.h
index 5718b96..7597527 100644
--- a/generic/tclPlatDecls.h
+++ b/generic/tclPlatDecls.h
@@ -6,7 +6,7 @@
* Copyright (c) 1998-1999 by Scriptics Corporation.
* All rights reserved.
*
- * RCS: @(#) $Id: tclPlatDecls.h,v 1.27.2.1 2010/02/07 22:16:54 nijtmans Exp $
+ * RCS: @(#) $Id: tclPlatDecls.h,v 1.27.2.2 2010/05/21 12:18:17 nijtmans Exp $
*/
#ifndef _TCLPLATDECLS
@@ -26,18 +26,12 @@
/*
* Pull in the typedef of TCHAR for windows.
*/
-#if defined(__CYGWIN__)
- typedef char TCHAR;
-#elif defined(__WIN32__) && !defined(_TCHAR_DEFINED)
+#if defined(__WIN32__) && !defined(_TCHAR_DEFINED)
# include <tchar.h>
# ifndef _TCHAR_DEFINED
/* Borland seems to forget to set this. */
- typedef _TCHAR TCHAR;
-# define _TCHAR_DEFINED
-# endif
-# if defined(_MSC_VER) && defined(__STDC__)
- /* MSVC++ misses this. */
typedef _TCHAR TCHAR;
+# define _TCHAR_DEFINED
# endif
#endif