summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixFile.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tclUnixFile.c')
-rw-r--r--unix/tclUnixFile.c68
1 files changed, 39 insertions, 29 deletions
diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c
index 35046a5..fdf7904 100644
--- a/unix/tclUnixFile.c
+++ b/unix/tclUnixFile.c
@@ -34,16 +34,16 @@ static int NativeMatchType(Tcl_Interp *interp, const char* nativeEntry,
*---------------------------------------------------------------------------
*/
+#ifdef __CYGWIN__
void
TclpFindExecutable(
- const char *argv0) /* The value of the application's argv[0]
- * (native). */
+ TCL_UNUSED(const char *) /*argv0*/)
{
Tcl_Encoding encoding;
-#ifdef __CYGWIN__
int length;
- char buf[PATH_MAX * 2];
- char name[PATH_MAX * TCL_UTF_MAX + 1];
+ wchar_t buf[PATH_MAX];
+ char name[PATH_MAX * 3 + 1];
+
GetModuleFileNameW(NULL, buf, PATH_MAX);
cygwin_conv_path(3, buf, name, PATH_MAX);
length = strlen(name);
@@ -54,7 +54,14 @@ TclpFindExecutable(
encoding = Tcl_GetEncoding(NULL, NULL);
TclSetObjNameOfExecutable(
Tcl_NewStringObj(name, length), encoding);
+}
#else
+void
+TclpFindExecutable(
+ const char *argv0) /* The value of the application's argv[0]
+ * (native). */
+{
+ Tcl_Encoding encoding;
const char *name, *p;
Tcl_StatBuf statBuf;
Tcl_DString buffer, nameString, cwd, utfName;
@@ -192,8 +199,8 @@ TclpFindExecutable(
done:
Tcl_DStringFree(&buffer);
-#endif
}
+#endif
/*
*----------------------------------------------------------------------
@@ -249,9 +256,9 @@ TclpMatchInDirectory(
Tcl_Obj *tailPtr;
const char *nativeTail;
- native = Tcl_FSGetNativePath(pathPtr);
+ native = (const char *)Tcl_FSGetNativePath(pathPtr);
tailPtr = TclPathPart(interp, pathPtr, TCL_PATH_TAIL);
- nativeTail = Tcl_FSGetNativePath(tailPtr);
+ nativeTail = (const char *)Tcl_FSGetNativePath(tailPtr);
matchResult = NativeMatchType(interp, native, nativeTail, types);
if (matchResult == 1) {
Tcl_ListObjAppendElement(interp, resultPtr, pathPtr);
@@ -262,14 +269,15 @@ TclpMatchInDirectory(
TclDIR *d;
Tcl_DirEntry *entryPtr;
const char *dirName;
- int dirLength, nativeDirLen;
+ size_t dirLength, nativeDirLen;
int matchHidden, matchHiddenPat;
Tcl_StatBuf statBuf;
Tcl_DString ds; /* native encoding of dir */
Tcl_DString dsOrig; /* utf-8 encoding of dir */
Tcl_DStringInit(&dsOrig);
- dirName = Tcl_GetStringFromObj(fileNamePtr, &dirLength);
+ dirName = TclGetString(fileNamePtr);
+ dirLength = fileNamePtr->length;
Tcl_DStringAppend(&dsOrig, dirName, dirLength);
/*
@@ -554,6 +562,8 @@ NativeMatchType(
return matchResult;
}
}
+#else
+ (void)interp;
#endif /* MAC_OSX_TCL */
return 1;
@@ -621,7 +631,7 @@ TclpObjAccess(
Tcl_Obj *pathPtr, /* Path of file to access */
int mode) /* Permission setting. */
{
- const char *path = Tcl_FSGetNativePath(pathPtr);
+ const char *path = (const char *)Tcl_FSGetNativePath(pathPtr);
if (path == NULL) {
return -1;
@@ -649,7 +659,7 @@ int
TclpObjChdir(
Tcl_Obj *pathPtr) /* Path to new working directory */
{
- const char *path = Tcl_FSGetNativePath(pathPtr);
+ const char *path = (const char *)Tcl_FSGetNativePath(pathPtr);
if (path == NULL) {
return -1;
@@ -678,7 +688,7 @@ TclpObjLstat(
Tcl_Obj *pathPtr, /* Path of file to stat */
Tcl_StatBuf *bufPtr) /* Filled with results of stat call. */
{
- return TclOSlstat(Tcl_FSGetNativePath(pathPtr), bufPtr);
+ return TclOSlstat((const char *)Tcl_FSGetNativePath(pathPtr), bufPtr);
}
/*
@@ -719,7 +729,7 @@ TclpGetNativeCwd(
#endif /* USEGETWD */
if ((clientData == NULL) || strcmp(buffer, (const char *) clientData)) {
- char *newCd = ckalloc(strlen(buffer) + 1);
+ char *newCd = (char*)ckalloc(strlen(buffer) + 1);
strcpy(newCd, buffer);
return newCd;
@@ -846,7 +856,7 @@ TclpObjStat(
Tcl_Obj *pathPtr, /* Path of file to stat */
Tcl_StatBuf *bufPtr) /* Filled with results of stat call. */
{
- const char *path = Tcl_FSGetNativePath(pathPtr);
+ const char *path = (const char *)Tcl_FSGetNativePath(pathPtr);
if (path == NULL) {
return -1;
@@ -863,7 +873,7 @@ TclpObjLink(
int linkAction)
{
if (toPtr != NULL) {
- const char *src = Tcl_FSGetNativePath(pathPtr);
+ const char *src = (const char *)Tcl_FSGetNativePath(pathPtr);
const char *target = NULL;
if (src == NULL) {
@@ -909,7 +919,7 @@ TclpObjLink(
Tcl_DecrRefCount(absPtr);
Tcl_DecrRefCount(dirPtr);
} else {
- target = Tcl_FSGetNativePath(toPtr);
+ target = (const char*)Tcl_FSGetNativePath(toPtr);
if (target == NULL) {
return NULL;
}
@@ -937,7 +947,6 @@ TclpObjLink(
*/
if (linkAction & TCL_CREATE_SYMBOLIC_LINK) {
- int targetLen;
Tcl_DString ds;
Tcl_Obj *transPtr;
@@ -951,8 +960,8 @@ TclpObjLink(
if (transPtr == NULL) {
return NULL;
}
- target = Tcl_GetStringFromObj(transPtr, &targetLen);
- target = Tcl_UtfToExternalDString(NULL, target, targetLen, &ds);
+ target = TclGetString(transPtr);
+ target = Tcl_UtfToExternalDString(NULL, target, transPtr->length, &ds);
Tcl_DecrRefCount(transPtr);
if (symlink(target, src) != 0) {
@@ -982,7 +991,7 @@ TclpObjLink(
}
Tcl_DecrRefCount(transPtr);
- length = readlink(Tcl_FSGetNativePath(pathPtr), link, sizeof(link));
+ length = readlink((const char *)Tcl_FSGetNativePath(pathPtr), link, sizeof(link));
if (length < 0) {
return NULL;
}
@@ -1016,7 +1025,7 @@ TclpObjLink(
Tcl_Obj *
TclpFilesystemPathType(
- Tcl_Obj *pathPtr)
+ TCL_UNUSED(Tcl_Obj *))
{
/*
* All native paths are of the same type.
@@ -1080,7 +1089,7 @@ TclNativeCreateNativeRep(
const char *str;
Tcl_DString ds;
Tcl_Obj *validPathPtr;
- int len;
+ size_t len;
if (TclFSCwdIsNative()) {
/*
@@ -1105,7 +1114,8 @@ TclNativeCreateNativeRep(
Tcl_IncrRefCount(validPathPtr);
}
- str = Tcl_GetStringFromObj(validPathPtr, &len);
+ str = TclGetString(validPathPtr);
+ len = validPathPtr->length;
Tcl_UtfToExternalDString(NULL, str, len, &ds);
len = Tcl_DStringLength(&ds) + sizeof(char);
if (strlen(Tcl_DStringValue(&ds)) < len - sizeof(char)) {
@@ -1115,7 +1125,7 @@ TclNativeCreateNativeRep(
return NULL;
}
Tcl_DecrRefCount(validPathPtr);
- nativePathPtr = ckalloc(len);
+ nativePathPtr = (char *)ckalloc(len);
memcpy(nativePathPtr, Tcl_DStringValue(&ds), len);
Tcl_DStringFree(&ds);
@@ -1156,7 +1166,7 @@ TclNativeDupInternalRep(
len = (strlen((const char*) clientData) + 1) * sizeof(char);
- copy = ckalloc(len);
+ copy = (char *)ckalloc(len);
memcpy(copy, clientData, len);
return copy;
}
@@ -1182,7 +1192,7 @@ TclpUtime(
Tcl_Obj *pathPtr, /* File to modify */
struct utimbuf *tval) /* New modification date structure */
{
- return utime(Tcl_FSGetNativePath(pathPtr), tval);
+ return utime((const char *)Tcl_FSGetNativePath(pathPtr), tval);
}
#ifdef __CYGWIN__
@@ -1193,7 +1203,7 @@ TclOSstat(
void *cygstat)
{
struct stat buf;
- Tcl_StatBuf *statBuf = cygstat;
+ Tcl_StatBuf *statBuf = (Tcl_StatBuf *)cygstat;
int result = stat(name, &buf);
statBuf->st_mode = buf.st_mode;
@@ -1216,7 +1226,7 @@ TclOSlstat(
void *cygstat)
{
struct stat buf;
- Tcl_StatBuf *statBuf = cygstat;
+ Tcl_StatBuf *statBuf = (Tcl_StatBuf *)cygstat;
int result = lstat(name, &buf);
statBuf->st_mode = buf.st_mode;