diff options
author | nijtmans <nijtmans> | 2010-04-22 11:40:31 (GMT) |
---|---|---|
committer | nijtmans <nijtmans> | 2010-04-22 11:40:31 (GMT) |
commit | 4c3a083386d8c35e9a7d32b9f88b3ba9dc9fc9de (patch) | |
tree | b4c7c5b00f25f4e8cf1882d5b5e88eb39f9d3799 | |
parent | 833ea84043d927c416802983797aa3884a894012 (diff) | |
download | tcl-4c3a083386d8c35e9a7d32b9f88b3ba9dc9fc9de.zip tcl-4c3a083386d8c35e9a7d32b9f88b3ba9dc9fc9de.tar.gz tcl-4c3a083386d8c35e9a7d32b9f88b3ba9dc9fc9de.tar.bz2 |
Move TCHAR fallback typedef from tcl.h to tclPlatDecls.h (as suggested by dgp)
Eliminate various unnecessary type casts.
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | generic/tcl.h | 14 | ||||
-rw-r--r-- | generic/tclIOUtil.c | 4 | ||||
-rw-r--r-- | generic/tclInt.h | 4 | ||||
-rw-r--r-- | generic/tclPlatDecls.h | 15 | ||||
-rw-r--r-- | unix/tclUnixFile.c | 10 | ||||
-rw-r--r-- | unix/tclUnixPipe.c | 4 | ||||
-rw-r--r-- | win/tclWinChan.c | 4 | ||||
-rw-r--r-- | win/tclWinFCmd.c | 8 | ||||
-rw-r--r-- | win/tclWinFile.c | 60 | ||||
-rw-r--r-- | win/tclWinLoad.c | 4 | ||||
-rw-r--r-- | win/tclWinPipe.c | 4 |
12 files changed, 80 insertions, 65 deletions
@@ -1,3 +1,17 @@ +2010-04-22 Jan Nijtmans <nijtmans@users.sf.net> + + * generic/tclPlatDecls.h Move TCHAR fallback typedef from tcl.h to + * generic/tcl.h tclPlatDecls.h (as suggested by dgp) + * generic/tclInt.h fix typo + * generic/tclIOUtil.c Eliminate various unnecessary + * unix/tclUnixFile.c type casts. + * unix/tclUnixPipe.c + * win/tclWinChan.c + * win/tclWinFCmd.c + * win/tclWinFile.c + * win/tclWinLoad.c + * win/tclWinPipe.c + 2010-04-20 Jan Nijtmans <nijtmans@users.sf.net> * generic/tclTest.c Use function prototypes from the FS API. diff --git a/generic/tcl.h b/generic/tcl.h index f9ce79a..8fd5772 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -13,7 +13,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.h,v 1.304 2010/04/15 14:56:32 nijtmans Exp $ + * RCS: @(#) $Id: tcl.h,v 1.305 2010/04/22 11:40:31 nijtmans Exp $ */ #ifndef _TCL @@ -2376,18 +2376,6 @@ EXTERN void Tcl_GetMemoryInfo(Tcl_DString *dsPtr); #endif /* - * Unfortunately, TCHAR is needed in tclPlatDecls.h for - * win32, so if TCHAR is not defined yet do it here. - * This way, we don't need to include <tchar.h> just - * for one define. - */ -#if !defined(_TCHAR_DEFINED) -# if defined(__WIN32__) - typedef char TCHAR; -# define _TCHAR_DEFINED -# endif -#endif -/* *---------------------------------------------------------------------------- * Include the public function declarations that are accessible via the stubs * table. diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index 6723f27..69114e3 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.174 2010/04/04 15:11:51 dkf Exp $ + * RCS: @(#) $Id: tclIOUtil.c,v 1.175 2010/04/22 11:40:31 nijtmans Exp $ */ #include "tclInt.h" @@ -4568,7 +4568,7 @@ const char * Tcl_FSGetNativePath( Tcl_Obj *pathPtr) { - return (const char *) Tcl_FSGetInternalRep(pathPtr, &tclNativeFilesystem); + return Tcl_FSGetInternalRep(pathPtr, &tclNativeFilesystem); } /* diff --git a/generic/tclInt.h b/generic/tclInt.h index 047a823..d04bd07 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -15,7 +15,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.h,v 1.468 2010/04/05 19:44:45 ferrieux Exp $ + * RCS: @(#) $Id: tclInt.h,v 1.469 2010/04/22 11:40:31 nijtmans Exp $ */ #ifndef _TCLINT @@ -64,7 +64,7 @@ typedef int ptrdiff_t; #endif /* - * Ensure WORDS_BIGENDIAN is defined correcly: + * Ensure WORDS_BIGENDIAN is defined correctly: * Needs to happen here in addition to configure to work with fat compiles on * Darwin (where configure runs only once for multiple architectures). */ diff --git a/generic/tclPlatDecls.h b/generic/tclPlatDecls.h index b9117ac..6d44a7e 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.38 2010/04/15 13:58:44 nijtmans Exp $ + * RCS: @(#) $Id: tclPlatDecls.h,v 1.39 2010/04/22 11:40:31 nijtmans Exp $ */ #ifndef _TCLPLATDECLS @@ -29,6 +29,19 @@ * in the generic/tcl.decls script. */ +/* + * TCHAR is needed here for win32, so if it is not defined yet do it here. + * This way, we don't need to include <tchar.h> just for one define. + */ +#if defined(_WIN32) && !defined(_TCHAR_DEFINED) +# if defined(_UNICODE) + typedef wchar_t TCHAR; +# else + typedef char TCHAR; +# endif +# define _TCHAR_DEFINED +#endif + /* !BEGIN!: Do not edit below this line. */ /* diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index a656f4c..d6cf239 100644 --- a/unix/tclUnixFile.c +++ b/unix/tclUnixFile.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: tclUnixFile.c,v 1.56 2009/12/16 23:26:00 nijtmans Exp $ + * RCS: @(#) $Id: tclUnixFile.c,v 1.57 2010/04/22 11:40:32 nijtmans Exp $ */ #include "tclInt.h" @@ -232,9 +232,9 @@ TclpMatchInDirectory( Tcl_Obj *tailPtr; const char *nativeTail; - native = (const char *) Tcl_FSGetNativePath(pathPtr); + native = Tcl_FSGetNativePath(pathPtr); tailPtr = TclPathPart(interp, pathPtr, TCL_PATH_TAIL); - nativeTail = (const char *) Tcl_FSGetNativePath(tailPtr); + nativeTail = Tcl_FSGetNativePath(tailPtr); matchResult = NativeMatchType(interp, native, nativeTail, types); if (matchResult == 1) { Tcl_ListObjAppendElement(interp, resultPtr, pathPtr); @@ -1115,7 +1115,7 @@ TclNativeCreateNativeRep( memcpy(nativePathPtr, Tcl_DStringValue(&ds), (size_t) len); Tcl_DStringFree(&ds); - return (ClientData)nativePathPtr; + return nativePathPtr; } /* @@ -1154,7 +1154,7 @@ TclNativeDupInternalRep( copy = ckalloc(len); memcpy(copy, clientData, len); - return (ClientData) copy; + return copy; } /* diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c index ccb97c2..391c7a1 100644 --- a/unix/tclUnixPipe.c +++ b/unix/tclUnixPipe.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: tclUnixPipe.c,v 1.52 2010/04/02 21:21:06 kennykb Exp $ + * RCS: @(#) $Id: tclUnixPipe.c,v 1.53 2010/04/22 11:40:32 nijtmans Exp $ */ #include "tclInt.h" @@ -263,7 +263,7 @@ TclpTempFileName(void) fcntl(fd, F_SETFD, FD_CLOEXEC); unlink(fileName); /* INTL: Native. */ - result = TclpNativeToNormalized((ClientData) fileName); + result = TclpNativeToNormalized(fileName); close(fd); return result; } diff --git a/win/tclWinChan.c b/win/tclWinChan.c index 6ab056d..400fb64 100644 --- a/win/tclWinChan.c +++ b/win/tclWinChan.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: tclWinChan.c,v 1.56 2010/03/16 16:18:35 nijtmans Exp $ + * RCS: @(#) $Id: tclWinChan.c,v 1.57 2010/04/22 11:40:32 nijtmans Exp $ */ #include "tclWinInt.h" @@ -856,7 +856,7 @@ TclpOpenFileChannel( char channelName[16 + TCL_INTEGER_SPACE]; TclFile readFile = NULL, writeFile = NULL; - nativeName = (const TCHAR *) Tcl_FSGetNativePath(pathPtr); + nativeName = Tcl_FSGetNativePath(pathPtr); if (nativeName == NULL) { return NULL; } diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c index 6fa7441..89cb59f 100644 --- a/win/tclWinFCmd.c +++ b/win/tclWinFCmd.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: tclWinFCmd.c,v 1.61 2010/03/07 14:39:25 nijtmans Exp $ + * RCS: @(#) $Id: tclWinFCmd.c,v 1.62 2010/04/22 11:40:32 nijtmans Exp $ */ #include "tclWinInt.h" @@ -1188,7 +1188,7 @@ DoRemoveDirectory( * filled with UTF-8 name of file causing * error. */ { - int res = DoRemoveJustDirectory(Tcl_DStringValue(pathPtr), recursive, + int res = DoRemoveJustDirectory((const TCHAR *)Tcl_DStringValue(pathPtr), recursive, errorPtr); if ((res == TCL_ERROR) && (recursive != 0) && (Tcl_GetErrno() == EEXIST)) { @@ -1400,8 +1400,8 @@ TraverseWinTree( * files in that directory. */ - result = traverseProc(Tcl_DStringValue(sourcePtr), - (targetPtr == NULL ? NULL : Tcl_DStringValue(targetPtr)), + result = traverseProc((const TCHAR *)Tcl_DStringValue(sourcePtr), + (const TCHAR *)(targetPtr == NULL ? NULL : Tcl_DStringValue(targetPtr)), DOTREE_POSTD, errorPtr); } diff --git a/win/tclWinFile.c b/win/tclWinFile.c index b18aa1c..c38a86f 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinFile.c,v 1.106 2010/04/13 13:37:29 nijtmans Exp $ + * RCS: @(#) $Id: tclWinFile.c,v 1.107 2010/04/22 11:40:32 nijtmans Exp $ */ /* #define _WIN32_WINNT 0x0500 */ @@ -667,7 +667,7 @@ WinReadLinkDirectory( } } - tclWinProcs->tchar2utf((const char *) + tclWinProcs->tchar2utf((const TCHAR *) reparseBuffer->MountPointReparseBuffer.PathBuffer, (int) reparseBuffer->MountPointReparseBuffer .SubstituteNameLength, &ds); @@ -908,7 +908,7 @@ TclpMatchInDirectory( DWORD attr; const char *str = Tcl_GetStringFromObj(norm,&len); - native = (const TCHAR *) Tcl_FSGetNativePath(pathPtr); + native = Tcl_FSGetNativePath(pathPtr); if (tclWinProcs->getFileAttributesExProc == NULL) { attr = tclWinProcs->getFileAttributesProc(native); @@ -1851,7 +1851,7 @@ TclpObjChdir( Tcl_DString ds; #endif /* __CYGWIN__ */ - nativePath = (const TCHAR *) Tcl_FSGetNativePath(pathPtr); + nativePath = Tcl_FSGetNativePath(pathPtr); #ifdef __CYGWIN__ /* @@ -2003,7 +2003,7 @@ TclpObjStat( TclWinFlushDirtyChannels(); - return NativeStat((const TCHAR *) Tcl_FSGetNativePath(pathPtr), + return NativeStat(Tcl_FSGetNativePath(pathPtr), statPtr, 0); } @@ -2394,7 +2394,7 @@ TclpGetNativeCwd( } } - return TclNativeDupInternalRep((ClientData) buffer); + return TclNativeDupInternalRep(buffer); } int @@ -2402,7 +2402,7 @@ TclpObjAccess( Tcl_Obj *pathPtr, int mode) { - return NativeAccess((const TCHAR *) Tcl_FSGetNativePath(pathPtr), mode); + return NativeAccess(Tcl_FSGetNativePath(pathPtr), mode); } int @@ -2418,7 +2418,7 @@ TclpObjLstat( TclWinFlushDirtyChannels(); - return NativeStat((const TCHAR *) Tcl_FSGetNativePath(pathPtr), + return NativeStat(Tcl_FSGetNativePath(pathPtr), statPtr, 1); } @@ -2431,15 +2431,15 @@ TclpObjLink( { if (toPtr != NULL) { int res; - TCHAR *LinkTarget; - TCHAR *LinkSource = (TCHAR *) Tcl_FSGetNativePath(pathPtr); + const TCHAR *LinkTarget; + const TCHAR *LinkSource = Tcl_FSGetNativePath(pathPtr); Tcl_Obj *normalizedToPtr = Tcl_FSGetNormalizedPath(NULL, toPtr); if (normalizedToPtr == NULL) { return NULL; } - LinkTarget = (TCHAR *) Tcl_FSGetNativePath(normalizedToPtr); + LinkTarget = Tcl_FSGetNativePath(normalizedToPtr); if (LinkSource == NULL || LinkTarget == NULL) { return NULL; @@ -2451,7 +2451,7 @@ TclpObjLink( return NULL; } } else { - TCHAR *LinkSource = (TCHAR *) Tcl_FSGetNativePath(pathPtr); + const TCHAR *LinkSource = Tcl_FSGetNativePath(pathPtr); if (LinkSource == NULL) { return NULL; @@ -2501,14 +2501,14 @@ TclpFilesystemPathType( firstSeparator = strchr(path, '/'); if (firstSeparator == NULL) { found = tclWinProcs->getVolumeInformationProc( - Tcl_FSGetNativePath(pathPtr), NULL, 0, NULL, NULL, NULL, + Tcl_FSGetNativePath(pathPtr), NULL, 0, NULL, NULL, NULL, volType, VOL_BUF_SIZE); } else { Tcl_Obj *driveName = Tcl_NewStringObj(path, firstSeparator - path+1); Tcl_IncrRefCount(driveName); found = tclWinProcs->getVolumeInformationProc( - Tcl_FSGetNativePath(driveName), NULL, 0, NULL, NULL, NULL, + Tcl_FSGetNativePath(driveName), NULL, 0, NULL, NULL, NULL, volType, VOL_BUF_SIZE); Tcl_DecrRefCount(driveName); } @@ -2519,7 +2519,7 @@ TclpFilesystemPathType( Tcl_DString ds; Tcl_Obj *objPtr; - tclWinProcs->tchar2utf((const char *) volType, -1, &ds); + tclWinProcs->tchar2utf(volType, -1, &ds); objPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); Tcl_DStringFree(&ds); @@ -2667,7 +2667,7 @@ TclpObjNormalizePath( * path segment and continue */ - Tcl_DStringAppend(&dsNorm, (TCHAR *) + Tcl_DStringAppend(&dsNorm, (const char *) (nativePath + Tcl_DStringLength(&ds)-dotLen), dotLen); } else { @@ -2675,7 +2675,7 @@ TclpObjNormalizePath( * Normal path. */ - WIN32_FIND_DATA fData; + WIN32_FIND_DATAA fData; HANDLE handle; handle = FindFirstFileA(nativePath, &fData); @@ -2746,7 +2746,7 @@ TclpObjNormalizePath( */ WIN32_FILE_ATTRIBUTE_DATA data; - const char *nativePath = tclWinProcs->utf2tchar(path, + const TCHAR *nativePath = tclWinProcs->utf2tchar(path, currentPathEndPosition - path, &ds); if (tclWinProcs->getFileAttributesExProc(nativePath, @@ -2773,7 +2773,7 @@ TclpObjNormalizePath( ((WCHAR *) nativePath)[i] = wc; } } - Tcl_DStringAppend(&dsNorm, nativePath, + Tcl_DStringAppend(&dsNorm, (const char *)nativePath, (int)(sizeof(WCHAR) * len)); lastValidPathEnd = currentPathEndPosition; } @@ -2855,7 +2855,7 @@ TclpObjNormalizePath( drive -= (L'a' - L'A'); ((WCHAR *) nativePath)[0] = drive; } - Tcl_DStringAppend(&dsNorm, nativePath, + Tcl_DStringAppend(&dsNorm, (const char *)nativePath, Tcl_DStringLength(&ds)); } else { char *checkDots = NULL; @@ -2880,8 +2880,8 @@ TclpObjNormalizePath( * path segment and continue. */ - Tcl_DStringAppend(&dsNorm, (TCHAR *) - ((WCHAR*)(nativePath + Tcl_DStringLength(&ds)) + Tcl_DStringAppend(&dsNorm, (const char *) + ((WCHAR *)(nativePath + Tcl_DStringLength(&ds)) - dotLen), (int)(dotLen * sizeof(WCHAR))); } else { /* @@ -2911,7 +2911,7 @@ TclpObjNormalizePath( FindClose(handle); Tcl_DStringAppend(&dsNorm, (const char *) L"/", sizeof(WCHAR)); - Tcl_DStringAppend(&dsNorm, (TCHAR *) nativeName, + Tcl_DStringAppend(&dsNorm, (const char *) nativeName, (int) (wcslen(nativeName)*sizeof(WCHAR))); } } @@ -2940,7 +2940,7 @@ TclpObjNormalizePath( if (1) { WCHAR wpath[MAX_PATH]; - const char *nativePath = + const TCHAR *nativePath = tclWinProcs->utf2tchar(path, lastValidPathEnd - path, &ds); DWORD wpathlen = tclWinProcs->getLongPathNameProc(nativePath, (TCHAR *) wpath, MAX_PATH); @@ -2952,7 +2952,7 @@ TclpObjNormalizePath( if (wpath[0] >= L'a') { wpath[0] -= (L'a' - L'A'); } - Tcl_DStringAppend(&dsNorm, (TCHAR*)wpath, wpathlen*sizeof(WCHAR)); + Tcl_DStringAppend(&dsNorm, (const char *)wpath, wpathlen*sizeof(WCHAR)); Tcl_DStringFree(&ds); } #endif @@ -2972,7 +2972,7 @@ TclpObjNormalizePath( Tcl_DString dsTemp; - tclWinProcs->tchar2utf(Tcl_DStringValue(&dsNorm), + tclWinProcs->tchar2utf((const TCHAR *)Tcl_DStringValue(&dsNorm), Tcl_DStringLength(&dsNorm), &dsTemp); nextCheckpoint = Tcl_DStringLength(&dsTemp); if (*lastValidPathEnd != 0) { @@ -3150,7 +3150,7 @@ TclpNativeToNormalized( int len; char *copy, *p; - tclWinProcs->tchar2utf((const char *) clientData, -1, &ds); + tclWinProcs->tchar2utf((const TCHAR *) clientData, -1, &ds); copy = Tcl_DStringValue(&ds); len = Tcl_DStringLength(&ds); @@ -3255,7 +3255,7 @@ TclNativeCreateNativeRep( memcpy(nativePathPtr, Tcl_DStringValue(&ds), (size_t) len); Tcl_DStringFree(&ds); - return (ClientData) nativePathPtr; + return nativePathPtr; } /* @@ -3302,7 +3302,7 @@ TclNativeDupInternalRep( copy = (char *) ckalloc(len); memcpy(copy, clientData, len); - return (ClientData) copy; + return copy; } /* @@ -3337,7 +3337,7 @@ TclpUtime( FromCTime(tval->actime, &lastAccessTime); FromCTime(tval->modtime, &lastModTime); - native = (const TCHAR *) Tcl_FSGetNativePath(pathPtr); + native = Tcl_FSGetNativePath(pathPtr); attr = tclWinProcs->getFileAttributesProc(native); diff --git a/win/tclWinLoad.c b/win/tclWinLoad.c index f1eb1e0..3eb0134 100644 --- a/win/tclWinLoad.c +++ b/win/tclWinLoad.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: tclWinLoad.c,v 1.28 2010/04/13 13:37:29 nijtmans Exp $ + * RCS: @(#) $Id: tclWinLoad.c,v 1.29 2010/04/22 11:40:32 nijtmans Exp $ */ #include "tclWinInt.h" @@ -347,7 +347,7 @@ TclpTempFileNameForLibrary(Tcl_Interp* interp, /* Tcl interpreter */ Tcl_AppendResult(interp, "couldn't create temporary directory: ", Tcl_PosixError(interp), NULL); } - fileName = TclpNativeToNormalized((ClientData) dllDirectoryName); + fileName = TclpNativeToNormalized(dllDirectoryName); tail = TclPathPart(interp, path, TCL_PATH_TAIL); if (tail == NULL) { Tcl_DecrRefCount(fileName); diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index 2ee7310..7c19e38 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.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: tclWinPipe.c,v 1.78 2010/03/20 12:00:42 nijtmans Exp $ + * RCS: @(#) $Id: tclWinPipe.c,v 1.79 2010/04/22 11:40:32 nijtmans Exp $ */ #include "tclWinInt.h" @@ -766,7 +766,7 @@ TclpTempFileName(void) return NULL; } - return TclpNativeToNormalized((ClientData) fileName); + return TclpNativeToNormalized(fileName); } /* |