From 123f5954787216f58928f41149aecdfd49f112f0 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 19 Mar 2012 16:12:35 +0000 Subject: bug 3508771: load tclreg.dll in cygwin tclsh (works on cygwin, on other UNIX not yet complete) --- generic/tclInt.decls | 7 ++++++- generic/tclIntPlatDecls.h | 43 +++++++++++++++++++++++++++++++++++++------ generic/tclStubInit.c | 24 +++++++++++++++++++++++- 3 files changed, 66 insertions(+), 8 deletions(-) diff --git a/generic/tclInt.decls b/generic/tclInt.decls index 4fb88c6..e3d3a08 100644 --- a/generic/tclInt.decls +++ b/generic/tclInt.decls @@ -982,8 +982,9 @@ declare 8 unix { # Added in 8.1: +# On non-cygwin, this is actually a reference to TclpCreateTempFile declare 9 unix { - TclFile TclpCreateTempFile(CONST char *contents) + int TclWinGetPlatformId(void) } # Added in 8.4: @@ -1007,3 +1008,7 @@ declare 13 unix { char * TclpInetNtoa(struct in_addr addr) } +declare 22 unix { + TclFile TclpCreateTempFile(CONST char *contents) +} + diff --git a/generic/tclIntPlatDecls.h b/generic/tclIntPlatDecls.h index 35bacf1..a3898ab 100644 --- a/generic/tclIntPlatDecls.h +++ b/generic/tclIntPlatDecls.h @@ -55,8 +55,7 @@ EXTERN TclFile TclpOpenFile _ANSI_ARGS_((CONST char * fname, EXTERN int TclUnixWaitForFile _ANSI_ARGS_((int fd, int mask, int timeout)); /* 9 */ -EXTERN TclFile TclpCreateTempFile _ANSI_ARGS_(( - CONST char * contents)); +EXTERN int TclWinGetPlatformId _ANSI_ARGS_((void)); /* 10 */ EXTERN Tcl_DirEntry * TclpReaddir _ANSI_ARGS_((DIR * dir)); /* 11 */ @@ -66,6 +65,17 @@ EXTERN struct tm * TclpLocaltime_unix _ANSI_ARGS_(( EXTERN struct tm * TclpGmtime_unix _ANSI_ARGS_((TclpTime_t_CONST clock)); /* 13 */ EXTERN char * TclpInetNtoa _ANSI_ARGS_((struct in_addr addr)); +/* Slot 14 is reserved */ +/* Slot 15 is reserved */ +/* Slot 16 is reserved */ +/* Slot 17 is reserved */ +/* Slot 18 is reserved */ +/* Slot 19 is reserved */ +/* Slot 20 is reserved */ +/* Slot 21 is reserved */ +/* 22 */ +EXTERN TclFile TclpCreateTempFile _ANSI_ARGS_(( + CONST char * contents)); #endif /* UNIX */ #ifdef __WIN32__ /* 0 */ @@ -229,11 +239,20 @@ typedef struct TclIntPlatStubs { TclFile (*tclpMakeFile) _ANSI_ARGS_((Tcl_Channel channel, int direction)); /* 6 */ TclFile (*tclpOpenFile) _ANSI_ARGS_((CONST char * fname, int mode)); /* 7 */ int (*tclUnixWaitForFile) _ANSI_ARGS_((int fd, int mask, int timeout)); /* 8 */ - TclFile (*tclpCreateTempFile) _ANSI_ARGS_((CONST char * contents)); /* 9 */ + int (*tclWinGetPlatformId) _ANSI_ARGS_((void)); /* 9 */ Tcl_DirEntry * (*tclpReaddir) _ANSI_ARGS_((DIR * dir)); /* 10 */ struct tm * (*tclpLocaltime_unix) _ANSI_ARGS_((TclpTime_t_CONST clock)); /* 11 */ struct tm * (*tclpGmtime_unix) _ANSI_ARGS_((TclpTime_t_CONST clock)); /* 12 */ char * (*tclpInetNtoa) _ANSI_ARGS_((struct in_addr addr)); /* 13 */ + void *reserved14; + void *reserved15; + void *reserved16; + void *reserved17; + void *reserved18; + void *reserved19; + void *reserved20; + void *reserved21; + TclFile (*tclpCreateTempFile) _ANSI_ARGS_((CONST char * contents)); /* 22 */ #endif /* UNIX */ #ifdef __WIN32__ void (*tclWinConvertError) _ANSI_ARGS_((DWORD errCode)); /* 0 */ @@ -346,9 +365,9 @@ extern TclIntPlatStubs *tclIntPlatStubsPtr; #define TclUnixWaitForFile \ (tclIntPlatStubsPtr->tclUnixWaitForFile) /* 8 */ #endif -#ifndef TclpCreateTempFile -#define TclpCreateTempFile \ - (tclIntPlatStubsPtr->tclpCreateTempFile) /* 9 */ +#ifndef TclWinGetPlatformId +#define TclWinGetPlatformId \ + (tclIntPlatStubsPtr->tclWinGetPlatformId) /* 9 */ #endif #ifndef TclpReaddir #define TclpReaddir \ @@ -366,6 +385,18 @@ extern TclIntPlatStubs *tclIntPlatStubsPtr; #define TclpInetNtoa \ (tclIntPlatStubsPtr->tclpInetNtoa) /* 13 */ #endif +/* Slot 14 is reserved */ +/* Slot 15 is reserved */ +/* Slot 16 is reserved */ +/* Slot 17 is reserved */ +/* Slot 18 is reserved */ +/* Slot 19 is reserved */ +/* Slot 20 is reserved */ +/* Slot 21 is reserved */ +#ifndef TclpCreateTempFile +#define TclpCreateTempFile \ + (tclIntPlatStubsPtr->tclpCreateTempFile) /* 22 */ +#endif #endif /* UNIX */ #ifdef __WIN32__ #ifndef TclWinConvertError diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index a81f3e8..91f176c 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -57,6 +57,19 @@ Tcl_NotifierProcs tclOriginalNotifier = { NULL }; +#ifdef __CYGWIN__ +#define TclWinGetPlatformId winGetPlatformId +static int +TclWinGetPlatformId() +{ + /* Don't bother to determine the real platform on cygwin, + * because VER_PLATFORM_WIN32_NT is the only supported platform */ + return 2; /* VER_PLATFORM_WIN32_NT */; +} +#elif !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ +#define TclWinGetPlatformId (int (*)()) TclpCreateTempFile +#endif + /* * WARNING: The contents of this file is automatically generated by the * tools/genStubs.tcl script. Any modifications to the function declarations @@ -307,11 +320,20 @@ TclIntPlatStubs tclIntPlatStubs = { TclpMakeFile, /* 6 */ TclpOpenFile, /* 7 */ TclUnixWaitForFile, /* 8 */ - TclpCreateTempFile, /* 9 */ + TclWinGetPlatformId, /* 9 */ TclpReaddir, /* 10 */ TclpLocaltime_unix, /* 11 */ TclpGmtime_unix, /* 12 */ TclpInetNtoa, /* 13 */ + NULL, /* 14 */ + NULL, /* 15 */ + NULL, /* 16 */ + NULL, /* 17 */ + NULL, /* 18 */ + NULL, /* 19 */ + NULL, /* 20 */ + NULL, /* 21 */ + TclpCreateTempFile, /* 22 */ #endif /* UNIX */ #ifdef __WIN32__ TclWinConvertError, /* 0 */ -- cgit v0.12 From fefa2c52da187dad8fac68f63f757cde175bdf8e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 19 Mar 2012 22:27:10 +0000 Subject: implement Tcl_WinUtfToTChar and Tcl_WinTCharToUtf for cygwin --- generic/tcl.decls | 4 ++-- generic/tclInt.decls | 3 +++ generic/tclIntPlatDecls.h | 32 +++++++++++++++++++++++++ generic/tclPlatDecls.h | 54 ++++++++++++++++++++--------------------- generic/tclStubInit.c | 61 +++++++++++++++++++++++++++++++++++++++++++---- 5 files changed, 120 insertions(+), 34 deletions(-) diff --git a/generic/tcl.decls b/generic/tcl.decls index 4ebaea5..a2fb082 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -1862,14 +1862,14 @@ declare 8 mac { # Mac OS X declarations # -declare 0 macosx { +declare 0 unix { int Tcl_MacOSXOpenBundleResources(Tcl_Interp *interp, CONST char *bundleName, int hasResourceFile, int maxPathLen, char *libraryPath) } -declare 1 macosx { +declare 1 unix { int Tcl_MacOSXOpenVersionedBundleResources(Tcl_Interp *interp, CONST char *bundleName, CONST char *bundleVersion, diff --git a/generic/tclInt.decls b/generic/tclInt.decls index e3d3a08..269cd81 100644 --- a/generic/tclInt.decls +++ b/generic/tclInt.decls @@ -1011,4 +1011,7 @@ declare 13 unix { declare 22 unix { TclFile TclpCreateTempFile(CONST char *contents) } +declare 29 unix { + int TclWinCPUID(unsigned int index, unsigned int *regs) +} diff --git a/generic/tclIntPlatDecls.h b/generic/tclIntPlatDecls.h index a3898ab..ec474d4 100644 --- a/generic/tclIntPlatDecls.h +++ b/generic/tclIntPlatDecls.h @@ -76,6 +76,15 @@ EXTERN char * TclpInetNtoa _ANSI_ARGS_((struct in_addr addr)); /* 22 */ EXTERN TclFile TclpCreateTempFile _ANSI_ARGS_(( CONST char * contents)); +/* Slot 23 is reserved */ +/* Slot 24 is reserved */ +/* Slot 25 is reserved */ +/* Slot 26 is reserved */ +/* Slot 27 is reserved */ +/* Slot 28 is reserved */ +/* 29 */ +EXTERN int TclWinCPUID _ANSI_ARGS_((unsigned int index, + unsigned int * regs)); #endif /* UNIX */ #ifdef __WIN32__ /* 0 */ @@ -253,6 +262,13 @@ typedef struct TclIntPlatStubs { void *reserved20; void *reserved21; TclFile (*tclpCreateTempFile) _ANSI_ARGS_((CONST char * contents)); /* 22 */ + void *reserved23; + void *reserved24; + void *reserved25; + void *reserved26; + void *reserved27; + void *reserved28; + int (*tclWinCPUID) _ANSI_ARGS_((unsigned int index, unsigned int * regs)); /* 29 */ #endif /* UNIX */ #ifdef __WIN32__ void (*tclWinConvertError) _ANSI_ARGS_((DWORD errCode)); /* 0 */ @@ -397,6 +413,16 @@ extern TclIntPlatStubs *tclIntPlatStubsPtr; #define TclpCreateTempFile \ (tclIntPlatStubsPtr->tclpCreateTempFile) /* 22 */ #endif +/* Slot 23 is reserved */ +/* Slot 24 is reserved */ +/* Slot 25 is reserved */ +/* Slot 26 is reserved */ +/* Slot 27 is reserved */ +/* Slot 28 is reserved */ +#ifndef TclWinCPUID +#define TclWinCPUID \ + (tclIntPlatStubsPtr->tclWinCPUID) /* 29 */ +#endif #endif /* UNIX */ #ifdef __WIN32__ #ifndef TclWinConvertError @@ -623,4 +649,10 @@ extern TclIntPlatStubs *tclIntPlatStubsPtr; #undef TclpLocaltime_unix #undef TclpGmtime_unix +#if !defined(__WIN32__) && !defined(MAC_TCL) && !defined(__CYGWIN__) && defined(USE_TCL_STUBS) +#undef TclpCreateTempFile +#define TclpCreateTempFile \ + ((TclFile (*)_ANSI_ARGS_((CONST char *))) tclIntPlatStubsPtr->tclWinGetPlatformId) +#endif + #endif /* _TCLINTPLATDECLS */ diff --git a/generic/tclPlatDecls.h b/generic/tclPlatDecls.h index c6fad72..0760250 100644 --- a/generic/tclPlatDecls.h +++ b/generic/tclPlatDecls.h @@ -34,6 +34,19 @@ * Exported function declarations: */ +#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ +/* 0 */ +EXTERN int Tcl_MacOSXOpenBundleResources _ANSI_ARGS_(( + Tcl_Interp * interp, CONST char * bundleName, + int hasResourceFile, int maxPathLen, + char * libraryPath)); +/* 1 */ +EXTERN int Tcl_MacOSXOpenVersionedBundleResources _ANSI_ARGS_(( + Tcl_Interp * interp, CONST char * bundleName, + CONST char * bundleVersion, + int hasResourceFile, int maxPathLen, + char * libraryPath)); +#endif /* UNIX */ #ifdef __WIN32__ /* 0 */ EXTERN TCHAR * Tcl_WinUtfToTChar _ANSI_ARGS_((CONST char * str, @@ -74,24 +87,15 @@ EXTERN int strncasecmp _ANSI_ARGS_((CONST char * s1, EXTERN int strcasecmp _ANSI_ARGS_((CONST char * s1, CONST char * s2)); #endif /* MAC_TCL */ -#ifdef MAC_OSX_TCL -/* 0 */ -EXTERN int Tcl_MacOSXOpenBundleResources _ANSI_ARGS_(( - Tcl_Interp * interp, CONST char * bundleName, - int hasResourceFile, int maxPathLen, - char * libraryPath)); -/* 1 */ -EXTERN int Tcl_MacOSXOpenVersionedBundleResources _ANSI_ARGS_(( - Tcl_Interp * interp, CONST char * bundleName, - CONST char * bundleVersion, - int hasResourceFile, int maxPathLen, - char * libraryPath)); -#endif /* MAC_OSX_TCL */ typedef struct TclPlatStubs { int magic; struct TclPlatStubHooks *hooks; +#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ + int (*tcl_MacOSXOpenBundleResources) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * bundleName, int hasResourceFile, int maxPathLen, char * libraryPath)); /* 0 */ + int (*tcl_MacOSXOpenVersionedBundleResources) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * bundleName, CONST char * bundleVersion, int hasResourceFile, int maxPathLen, char * libraryPath)); /* 1 */ +#endif /* UNIX */ #ifdef __WIN32__ TCHAR * (*tcl_WinUtfToTChar) _ANSI_ARGS_((CONST char * str, int len, Tcl_DString * dsPtr)); /* 0 */ char * (*tcl_WinTCharToUtf) _ANSI_ARGS_((CONST TCHAR * str, int len, Tcl_DString * dsPtr)); /* 1 */ @@ -107,10 +111,6 @@ typedef struct TclPlatStubs { int (*strncasecmp) _ANSI_ARGS_((CONST char * s1, CONST char * s2, size_t n)); /* 7 */ int (*strcasecmp) _ANSI_ARGS_((CONST char * s1, CONST char * s2)); /* 8 */ #endif /* MAC_TCL */ -#ifdef MAC_OSX_TCL - int (*tcl_MacOSXOpenBundleResources) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * bundleName, int hasResourceFile, int maxPathLen, char * libraryPath)); /* 0 */ - int (*tcl_MacOSXOpenVersionedBundleResources) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * bundleName, CONST char * bundleVersion, int hasResourceFile, int maxPathLen, char * libraryPath)); /* 1 */ -#endif /* MAC_OSX_TCL */ } TclPlatStubs; #ifdef __cplusplus @@ -127,6 +127,16 @@ extern TclPlatStubs *tclPlatStubsPtr; * Inline function declarations: */ +#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ +#ifndef Tcl_MacOSXOpenBundleResources +#define Tcl_MacOSXOpenBundleResources \ + (tclPlatStubsPtr->tcl_MacOSXOpenBundleResources) /* 0 */ +#endif +#ifndef Tcl_MacOSXOpenVersionedBundleResources +#define Tcl_MacOSXOpenVersionedBundleResources \ + (tclPlatStubsPtr->tcl_MacOSXOpenVersionedBundleResources) /* 1 */ +#endif +#endif /* UNIX */ #ifdef __WIN32__ #ifndef Tcl_WinUtfToTChar #define Tcl_WinUtfToTChar \ @@ -175,16 +185,6 @@ extern TclPlatStubs *tclPlatStubsPtr; (tclPlatStubsPtr->strcasecmp) /* 8 */ #endif #endif /* MAC_TCL */ -#ifdef MAC_OSX_TCL -#ifndef Tcl_MacOSXOpenBundleResources -#define Tcl_MacOSXOpenBundleResources \ - (tclPlatStubsPtr->tcl_MacOSXOpenBundleResources) /* 0 */ -#endif -#ifndef Tcl_MacOSXOpenVersionedBundleResources -#define Tcl_MacOSXOpenVersionedBundleResources \ - (tclPlatStubsPtr->tcl_MacOSXOpenVersionedBundleResources) /* 1 */ -#endif -#endif /* MAC_OSX_TCL */ #endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */ diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 91f176c..fab94a3 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -58,7 +58,13 @@ Tcl_NotifierProcs tclOriginalNotifier = { }; #ifdef __CYGWIN__ + #define TclWinGetPlatformId winGetPlatformId +#define Tcl_WinUtfToTChar winUtfToTChar +#define Tcl_WinTCharToUtf winTCharToUtf + +static Tcl_Encoding winTCharEncoding; + static int TclWinGetPlatformId() { @@ -66,8 +72,46 @@ TclWinGetPlatformId() * because VER_PLATFORM_WIN32_NT is the only supported platform */ return 2; /* VER_PLATFORM_WIN32_NT */; } + +static char * +Tcl_WinUtfToTChar(string, len, dsPtr) + CONST char *string; + int len; + Tcl_DString *dsPtr; +{ + if (!winTCharEncoding) { + winTCharEncoding = Tcl_GetEncoding(NULL, "unicode"); + } + return Tcl_UtfToExternalDString(winTCharEncoding, + string, len, dsPtr); +} + +char * +Tcl_WinTCharToUtf(string, len, dsPtr) + CONST char *string; + int len; + Tcl_DString *dsPtr; +{ + if (!winTCharEncoding) { + winTCharEncoding = Tcl_GetEncoding(NULL, "unicode"); + } + return Tcl_ExternalToUtfDString(winTCharEncoding, + string, len, dsPtr); +} + +#define TclWinCPUID 0 /* TODO: to be implemented for cygwin */ +#define Tcl_MacOSXOpenBundleResources (int (*) _ANSI_ARGS_(( \ + Tcl_Interp *, CONST char *, int, int, char *))) Tcl_WinUtfToTChar +#define Tcl_MacOSXOpenVersionedBundleResources (int (*) _ANSI_ARGS_(( \ + Tcl_Interp *, CONST char *, CONST char *, int, int, char *))) Tcl_WinTCharToUtf + #elif !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ -#define TclWinGetPlatformId (int (*)()) TclpCreateTempFile +# define TclWinGetPlatformId (int (*)()) TclpCreateTempFile +# define TclWinCPUID 0 +# ifndef MAC_OSX_TCL +# define Tcl_MacOSXOpenBundleResources 0 +# define Tcl_MacOSXOpenVersionedBundleResources 0 +# endif #endif /* @@ -334,6 +378,13 @@ TclIntPlatStubs tclIntPlatStubs = { NULL, /* 20 */ NULL, /* 21 */ TclpCreateTempFile, /* 22 */ + NULL, /* 23 */ + NULL, /* 24 */ + NULL, /* 25 */ + NULL, /* 26 */ + NULL, /* 27 */ + NULL, /* 28 */ + TclWinCPUID, /* 29 */ #endif /* UNIX */ #ifdef __WIN32__ TclWinConvertError, /* 0 */ @@ -401,6 +452,10 @@ TclIntPlatStubs tclIntPlatStubs = { TclPlatStubs tclPlatStubs = { TCL_STUB_MAGIC, NULL, +#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ + Tcl_MacOSXOpenBundleResources, /* 0 */ + Tcl_MacOSXOpenVersionedBundleResources, /* 1 */ +#endif /* UNIX */ #ifdef __WIN32__ Tcl_WinUtfToTChar, /* 0 */ Tcl_WinTCharToUtf, /* 1 */ @@ -416,10 +471,6 @@ TclPlatStubs tclPlatStubs = { strncasecmp, /* 7 */ strcasecmp, /* 8 */ #endif /* MAC_TCL */ -#ifdef MAC_OSX_TCL - Tcl_MacOSXOpenBundleResources, /* 0 */ - Tcl_MacOSXOpenVersionedBundleResources, /* 1 */ -#endif /* MAC_OSX_TCL */ }; static TclStubHooks tclStubHooks = { -- cgit v0.12 From 10f86a8692c0a3a978d81ff4ab06c6f04dde6d99 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 20 Mar 2012 10:15:02 +0000 Subject: [Bug 3288345] Wrong Tcl_StatBuf used on Cygwin (backported from Tcl 8.5) --- ChangeLog | 16 +++++--- generic/tcl.h | 105 ++++++++++++++++++++++++++++++++++++-------------- generic/tclEnv.c | 85 +++------------------------------------- generic/tclFileName.c | 11 ------ generic/tclStubInit.c | 2 +- unix/tclUnixFile.c | 44 ++++++++++++++++++++- unix/tclUnixPort.h | 8 +++- win/tclWinFile.c | 60 ----------------------------- win/tclWinPort.h | 39 ++----------------- 9 files changed, 147 insertions(+), 223 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3955965..95d57c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,16 @@ 2012-03-20 Jan Nijtmans - * generic/tcl.decls: [Bug 3508771] load tclreg.dll in cygwin tclsh - * generic/tclInt.decls: Implement TclWinGetPlatformId, Tcl_WinUtfToTChar, - * generic/tclIntPlatDecls.h: Tcl_WinTCharToUtf (and a dummy TclWinCPUID) for - * generic/tclPlatDecls.h: Cygwin, so win32 extensions using those can be - * generic/tclStubInit.c: loaded in the cygwin version of tclsh. + * generic/tcl.h: [Bug 3288345] Wrong Tcl_StatBuf used on Cygwin + * unix/tclUnixFile.c + * unix/tclUnixPort.h + * win/tclWinFile.c Remove cygwin stuff no longer needed + * win/tclWinPort.h + + * generic/tcl.decls: [Bug 3508771] load tclreg.dll in cygwin tclsh + * generic/tclInt.decls: Implement TclWinGetPlatformId, Tcl_WinUtfToTChar, + * generic/tclIntPlatDecls.h: Tcl_WinTCharToUtf (and a dummy TclWinCPUID) for + * generic/tclPlatDecls.h: Cygwin, so win32 extensions using those can be + * generic/tclStubInit.c: loaded in the cygwin version of tclsh. * unix/tclUnixCompat.c: 2012-03-12 Jan Nijtmans diff --git a/generic/tcl.h b/generic/tcl.h index b9355da..e794032 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -82,6 +82,7 @@ extern "C" { /* * STRICT: See MSDN Article Q83456 */ + #ifdef __WIN32__ # ifndef STRICT # define STRICT @@ -234,11 +235,11 @@ extern "C" { # endif #endif - /* * Definitions that allow this header file to be used either with or * without ANSI C features like function prototypes. */ + #undef _ANSI_ARGS_ #undef CONST #ifndef INLINE @@ -265,7 +266,7 @@ extern "C" { # define CONST84_RETURN #else # ifdef USE_COMPAT_CONST -# define CONST84 +# define CONST84 # define CONST84_RETURN CONST # else # define CONST84 CONST @@ -273,10 +274,10 @@ extern "C" { # endif #endif - /* * Make sure EXTERN isn't defined elsewhere */ + #ifdef EXTERN # undef EXTERN #endif /* EXTERN */ @@ -287,15 +288,15 @@ extern "C" { # define EXTERN extern TCL_STORAGE_CLASS #endif - /* * The following code is copied from winnt.h. - * If we don't replicate it here, then can't be included + * If we don't replicate it here, then can't be included * after tcl.h, since tcl.h also defines VOID. * This block is skipped under Cygwin and Mingw. * * */ + #if defined(__WIN32__) && !defined(HAVE_WINNT_IGNORE_VOID) #ifndef VOID #define VOID void @@ -372,7 +373,7 @@ typedef long LONG; */ #if !defined(TCL_WIDE_INT_TYPE)&&!defined(TCL_WIDE_INT_IS_LONG) -# if defined(__WIN32__) && !defined(__CYGWIN__) +# if defined(__WIN32__) # define TCL_WIDE_INT_TYPE __int64 # ifdef __BORLANDC__ typedef struct stati64 Tcl_StatBuf; @@ -439,7 +440,21 @@ typedef struct stat Tcl_StatBuf; * Windows or some other strange platform. */ # ifndef TCL_LL_MODIFIER -# ifdef HAVE_STRUCT_STAT64 +# ifdef __CYGWIN__ +typedef struct _stat32i64 { + dev_t st_dev; + ino_t st_ino; + unsigned short st_mode; + short st_nlink; + short st_uid; + short st_gid; + dev_t st_rdev; + long long st_size; + struct {long tv_sec;} st_atim; + struct {long tv_sec;} st_mtim; + struct {long tv_sec;} st_ctim; +} Tcl_StatBuf; +# elif defined(HAVE_STRUCT_STAT64) typedef struct stat64 Tcl_StatBuf; # else typedef struct stat Tcl_StatBuf; @@ -531,7 +546,6 @@ typedef unsigned (__stdcall Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData client typedef void (Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData)); #endif - /* * Threading function return types used for abstracting away platform * differences when writing a Tcl_ThreadCreateProc. See the NewThread @@ -545,14 +559,14 @@ typedef void (Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData)); # define TCL_THREAD_CREATE_RETURN return 0 #else # define Tcl_ThreadCreateType void -# define TCL_THREAD_CREATE_RETURN +# define TCL_THREAD_CREATE_RETURN #endif - /* * Definition of values for default stacksize and the possible flags to be * given to Tcl_CreateThread. */ + #define TCL_THREAD_STACK_DEFAULT (0) /* Use default size for stack */ #define TCL_THREAD_NOFLAGS (0000) /* Standard flags, default behaviour */ #define TCL_THREAD_JOINABLE (0001) /* Mark the thread as joinable */ @@ -579,6 +593,7 @@ typedef void (Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData)); * The following flag is experimental and only intended for use by Expect. It * will probably go away in a later release. */ + #define TCL_REG_BOSONLY 002000 /* prepend \A to pattern so it only * matches at the beginning of the * string. */ @@ -594,6 +609,7 @@ typedef void (Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData)); * relative to the start of the match string, not the beginning of the * entire string. */ + typedef struct Tcl_RegExpIndices { long start; /* character offset of first character in match */ long end; /* character offset of first character after the @@ -614,6 +630,7 @@ typedef struct Tcl_RegExpInfo { * Picky compilers complain if this typdef doesn't appear before the * struct's reference in tclDecls.h. */ + typedef Tcl_StatBuf *Tcl_Stat_; typedef struct stat *Tcl_OldStat_; @@ -637,6 +654,7 @@ typedef struct stat *Tcl_OldStat_; * TCL_CONTINUE Go on to the next iteration of the current loop; * the interpreter's result is meaningless. */ + #define TCL_OK 0 #define TCL_ERROR 1 #define TCL_RETURN 2 @@ -648,6 +666,7 @@ typedef struct stat *Tcl_OldStat_; /* * Flags to control what substitutions are performed by Tcl_SubstObj(): */ + #define TCL_SUBST_COMMANDS 001 #define TCL_SUBST_VARIABLES 002 #define TCL_SUBST_BACKSLASHES 004 @@ -675,7 +694,6 @@ typedef struct Tcl_Value { */ struct Tcl_Obj; - /* * Procedure types defined by Tcl: */ @@ -695,8 +713,8 @@ typedef int (Tcl_CmdObjTraceProc) _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int level, CONST char *command, Tcl_Command commandInfo, int objc, struct Tcl_Obj * CONST * objv)); typedef void (Tcl_CmdObjTraceDeleteProc) _ANSI_ARGS_((ClientData clientData)); -typedef void (Tcl_DupInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *srcPtr, - struct Tcl_Obj *dupPtr)); +typedef void (Tcl_DupInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *srcPtr, + struct Tcl_Obj *dupPtr)); typedef int (Tcl_EncodingConvertProc)_ANSI_ARGS_((ClientData clientData, CONST char *src, int srcLen, int flags, Tcl_EncodingState *statePtr, char *dst, int dstLen, int *srcReadPtr, int *dstWrotePtr, @@ -706,7 +724,7 @@ typedef int (Tcl_EventProc) _ANSI_ARGS_((Tcl_Event *evPtr, int flags)); typedef void (Tcl_EventCheckProc) _ANSI_ARGS_((ClientData clientData, int flags)); typedef int (Tcl_EventDeleteProc) _ANSI_ARGS_((Tcl_Event *evPtr, - ClientData clientData)); + ClientData clientData)); typedef void (Tcl_EventSetupProc) _ANSI_ARGS_((ClientData clientData, int flags)); typedef void (Tcl_ExitProc) _ANSI_ARGS_((ClientData clientData)); @@ -725,13 +743,14 @@ typedef int (Tcl_ObjCmdProc) _ANSI_ARGS_((ClientData clientData, typedef int (Tcl_PackageInitProc) _ANSI_ARGS_((Tcl_Interp *interp)); typedef void (Tcl_PanicProc) _ANSI_ARGS_(TCL_VARARGS(CONST char *, format)); typedef void (Tcl_TcpAcceptProc) _ANSI_ARGS_((ClientData callbackData, - Tcl_Channel chan, char *address, int port)); + Tcl_Channel chan, char *address, int port)); typedef void (Tcl_TimerProc) _ANSI_ARGS_((ClientData clientData)); typedef int (Tcl_SetFromAnyProc) _ANSI_ARGS_((Tcl_Interp *interp, struct Tcl_Obj *objPtr)); typedef void (Tcl_UpdateStringProc) _ANSI_ARGS_((struct Tcl_Obj *objPtr)); typedef char *(Tcl_VarTraceProc) _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, CONST84 char *part1, CONST84 char *part2, int flags)); + Tcl_Interp *interp, CONST84 char *part1, CONST84 char *part2, + int flags)); typedef void (Tcl_CommandTraceProc) _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, CONST char *oldName, CONST char *newName, int flags)); @@ -885,7 +904,6 @@ typedef struct Tcl_SavedResult { char resultSpace[TCL_RESULT_SIZE+1]; } Tcl_SavedResult; - /* * The following definitions support Tcl's namespace facility. * Note: the first five fields must match exactly the fields in a @@ -910,7 +928,6 @@ typedef struct Tcl_Namespace { * namespace. */ } Tcl_Namespace; - /* * The following structure represents a call frame, or activation record. * A call frame defines a naming context for a procedure call: its local @@ -950,7 +967,6 @@ typedef struct Tcl_CallFrame { VOID *dummy13; } Tcl_CallFrame; - /* * Information about commands that is returned by Tcl_GetCommandInfo and * passed to Tcl_SetCommandInfo. objProc is an objc/objv object-based @@ -992,6 +1008,7 @@ typedef struct Tcl_CmdInfo { * field that clients should use is the string field, accessible via the * macro Tcl_DStringValue. */ + #define TCL_DSTRING_STATIC_SIZE 200 typedef struct Tcl_DString { char *string; /* Points to beginning of string: either @@ -1014,6 +1031,7 @@ typedef struct Tcl_DString { * be specified in the "tcl_precision" variable, and the number of * bytes of buffer space required by Tcl_PrintDouble. */ + #define TCL_MAX_PREC 17 #define TCL_DOUBLE_SPACE (TCL_MAX_PREC+10) @@ -1022,6 +1040,7 @@ typedef struct Tcl_DString { * string representation of an integer in base 10 (assuming the existence * of 64-bit integers). */ + #define TCL_INTEGER_SPACE 24 /* @@ -1029,12 +1048,14 @@ typedef struct Tcl_DString { * output braces (careful! if you change this flag be sure to change * the definitions at the front of tclUtil.c). */ + #define TCL_DONT_USE_BRACES 1 /* * Flag that may be passed to Tcl_GetIndexFromObj to force it to disallow * abbreviated strings. */ + #define TCL_EXACT 1 /* @@ -1051,6 +1072,7 @@ typedef struct Tcl_DString { * Special freeProc values that may be passed to Tcl_SetResult (see * the man page for details): */ + #define TCL_VOLATILE ((Tcl_FreeProc *) 1) #define TCL_STATIC ((Tcl_FreeProc *) 0) #define TCL_DYNAMIC ((Tcl_FreeProc *) 3) @@ -1058,6 +1080,7 @@ typedef struct Tcl_DString { /* * Flag values passed to variable-related procedures. */ + #define TCL_GLOBAL_ONLY 1 #define TCL_NAMESPACE_ONLY 2 #define TCL_APPEND_VALUE 4 @@ -1105,7 +1128,6 @@ typedef struct Tcl_DString { # define TCL_PARSE_PART1 0x400 #endif - /* * Types for linked variables: */ @@ -1116,10 +1138,10 @@ typedef struct Tcl_DString { #define TCL_LINK_WIDE_INT 5 #define TCL_LINK_READ_ONLY 0x80 - /* * Forward declarations of Tcl_HashTable and related types. */ + typedef struct Tcl_HashKeyType Tcl_HashKeyType; typedef struct Tcl_HashTable Tcl_HashTable; typedef struct Tcl_HashEntry Tcl_HashEntry; @@ -1139,6 +1161,7 @@ typedef void (Tcl_FreeHashEntryProc) _ANSI_ARGS_((Tcl_HashEntry *hPtr)); * access the bucketPtr member of the Tcl_HashTableEntry structure. This * member has been removed and the space used to store the hash value. */ + #ifndef TCL_HASH_KEY_STORE_HASH # define TCL_HASH_KEY_STORE_HASH 1 #endif @@ -1384,6 +1407,7 @@ typedef struct Tcl_HashSearch { * a Tcl_Event header followed by additional information specific to that * event. */ + struct Tcl_Event { Tcl_EventProc *proc; /* Procedure to call to service this event. */ struct Tcl_Event *nextPtr; /* Next in list of pending events, or NULL. */ @@ -1392,6 +1416,7 @@ struct Tcl_Event { /* * Positions to pass to Tcl_QueueEvent: */ + typedef enum { TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, TCL_QUEUE_MARK } Tcl_QueuePosition; @@ -1400,16 +1425,17 @@ typedef enum { * Values to pass to Tcl_SetServiceMode to specify the behavior of notifier * event routines. */ + #define TCL_SERVICE_NONE 0 #define TCL_SERVICE_ALL 1 - /* * The following structure keeps is used to hold a time value, either as * an absolute time (the number of seconds from the epoch) or as an * elapsed time. On Unix systems the epoch is Midnight Jan 1, 1970 GMT. * On Macintosh systems the epoch is Midnight Jan 1, 1904 GMT. */ + typedef struct Tcl_Time { long sec; /* Seconds. */ long usec; /* Microseconds. */ @@ -1418,7 +1444,6 @@ typedef struct Tcl_Time { typedef void (Tcl_SetTimerProc) _ANSI_ARGS_((Tcl_Time *timePtr)); typedef int (Tcl_WaitForEventProc) _ANSI_ARGS_((Tcl_Time *timePtr)); - /* * Bits to pass to Tcl_CreateFileHandler and Tcl_CreateChannelHandler * to indicate what sorts of events are of interest: @@ -1432,6 +1457,7 @@ typedef int (Tcl_WaitForEventProc) _ANSI_ARGS_((Tcl_Time *timePtr)); * disposition of the stdio handles. TCL_STDIN, TCL_STDOUT, TCL_STDERR, * are also used in Tcl_GetStdChannel. */ + #define TCL_STDIN (1<<1) #define TCL_STDOUT (1<<2) #define TCL_STDERR (1<<3) @@ -1448,11 +1474,13 @@ typedef int (Tcl_WaitForEventProc) _ANSI_ARGS_((Tcl_Time *timePtr)); * Value to use as the closeProc for a channel that supports the * close2Proc interface. */ + #define TCL_CLOSE2PROC ((Tcl_DriverCloseProc *)1) /* * Channel version tag. This was introduced in 8.3.2/8.4. */ + #define TCL_CHANNEL_VERSION_1 ((Tcl_ChannelTypeVersion) 0x1) #define TCL_CHANNEL_VERSION_2 ((Tcl_ChannelTypeVersion) 0x2) #define TCL_CHANNEL_VERSION_3 ((Tcl_ChannelTypeVersion) 0x3) @@ -1468,6 +1496,7 @@ typedef int (Tcl_WaitForEventProc) _ANSI_ARGS_((Tcl_Time *timePtr)); /* * Typedefs for the various operations in a channel type: */ + typedef int (Tcl_DriverBlockModeProc) _ANSI_ARGS_(( ClientData instanceData, int mode)); typedef int (Tcl_DriverCloseProc) _ANSI_ARGS_((ClientData instanceData, @@ -1544,6 +1573,7 @@ typedef void (Tcl_DriverThreadActionProc) _ANSI_ARGS_ (( * It is recommend that the Tcl_Channel* functions are used to access * elements of this structure, instead of direct accessing. */ + typedef struct Tcl_ChannelType { char *typeName; /* The name of the channel type in Tcl * commands. This storage is owned by @@ -1616,13 +1646,13 @@ typedef struct Tcl_ChannelType { /* * Enum for different types of file paths. */ + typedef enum Tcl_PathType { TCL_PATH_ABSOLUTE, TCL_PATH_RELATIVE, TCL_PATH_VOLUME_RELATIVE } Tcl_PathType; - /* * The following structure is used to pass glob type data amongst * the various glob routines and Tcl_FSMatchInDirectory. @@ -1641,6 +1671,7 @@ typedef struct Tcl_GlobTypeData { /* * type and permission definitions for glob command */ + #define TCL_GLOB_TYPE_BLOCK (1<<0) #define TCL_GLOB_TYPE_CHAR (1<<1) #define TCL_GLOB_TYPE_DIR (1<<2) @@ -1656,10 +1687,10 @@ typedef struct Tcl_GlobTypeData { #define TCL_GLOB_PERM_W (1<<3) #define TCL_GLOB_PERM_X (1<<4) - /* * Typedefs for the various filesystem operations: */ + typedef int (Tcl_FSStatProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, Tcl_StatBuf *buf)); typedef int (Tcl_FSAccessProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, int mode)); typedef Tcl_Channel (Tcl_FSOpenFileChannelProc) @@ -1927,6 +1958,7 @@ typedef struct Tcl_Filesystem { * TCL_CREATE_SYMBOLIC_LINK: Create a symbolic or soft link. * TCL_CREATE_HARD_LINK: Create a hard link. */ + #define TCL_CREATE_SYMBOLIC_LINK 0x01 #define TCL_CREATE_HARD_LINK 0x02 @@ -1934,6 +1966,7 @@ typedef struct Tcl_Filesystem { * The following structure represents the Notifier functions that * you can override with the Tcl_SetNotifier call. */ + typedef struct Tcl_NotifierProcs { Tcl_SetTimerProc *setTimerProc; Tcl_WaitForEventProc *waitForEventProc; @@ -1945,11 +1978,11 @@ typedef struct Tcl_NotifierProcs { Tcl_ServiceModeHookProc *serviceModeHookProc; } Tcl_NotifierProcs; - /* * The following structure represents a user-defined encoding. It collects * together all the functions that are used by the specific encoding. */ + typedef struct Tcl_EncodingType { CONST char *encodingName; /* The name of the encoding, e.g. "euc-jp". * This name is the unique key for this @@ -2007,7 +2040,6 @@ typedef struct Tcl_EncodingType { #define TCL_ENCODING_END 0x02 #define TCL_ENCODING_STOPONERROR 0x04 - /* * The following data structures and declarations are for the new Tcl * parser. @@ -2018,6 +2050,7 @@ typedef struct Tcl_EncodingType { * variable reference, one of the following structures is created to * describe the token. */ + typedef struct Tcl_Token { int type; /* Type of token, such as TCL_TOKEN_WORD; * see below for valid types. */ @@ -2117,6 +2150,7 @@ typedef struct Tcl_Token { * will be stored in the error field of the Tcl_Parse structure * defined below. */ + #define TCL_PARSE_SUCCESS 0 #define TCL_PARSE_QUOTE_EXTRA 1 #define TCL_PARSE_BRACE_EXTRA 2 @@ -2132,6 +2166,7 @@ typedef struct Tcl_Token { * A structure of the following type is filled in by Tcl_ParseCommand. * It describes a single command parsed from an input string. */ + #define NUM_STATIC_TOKENS 20 typedef struct Tcl_Parse { @@ -2215,12 +2250,13 @@ typedef struct Tcl_Parse { * encoding method was misidentified. This error * is reported only if TCL_ENCODING_STOPONERROR * was specified. - * + * * TCL_CONVERT_UNKNOWN: The source string contained a character * that could not be represented in the target * encoding. This error is reported only if * TCL_ENCODING_STOPONERROR was specified. */ + #define TCL_CONVERT_MULTIBYTE -1 #define TCL_CONVERT_SYNTAX -2 #define TCL_CONVERT_UNKNOWN -3 @@ -2236,6 +2272,7 @@ typedef struct Tcl_Parse { * UCS-4 is experimental and not recommended. It works for the core, * but most extensions expect UCS-2. */ + #ifndef TCL_UTF_MAX #define TCL_UTF_MAX 3 #endif @@ -2244,6 +2281,7 @@ typedef struct Tcl_Parse { * This represents a Unicode character. Any changes to this should * also be reflected in regcustom.h. */ + #if TCL_UTF_MAX > 4 /* * unsigned int isn't 100% accurate as it should be a strict 4-byte @@ -2283,7 +2321,6 @@ typedef unsigned short Tcl_UniChar; #define panic Tcl_Panic #define panicVA Tcl_PanicVA - /* * The following constant is used to test for older versions of Tcl * in the stubs tables. @@ -2356,6 +2393,7 @@ EXTERN void Tcl_Main _ANSI_ARGS_((int argc, char **argv, * This function is not *implemented* by the tcl library, so the storage * class is neither DLLEXPORT nor DLLIMPORT */ + #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS @@ -2369,8 +2407,17 @@ EXTERN int Tcl_AppInit _ANSI_ARGS_((Tcl_Interp *interp)); /* * end block for C++ */ + #ifdef __cplusplus } #endif #endif /* _TCL */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ diff --git a/generic/tclEnv.c b/generic/tclEnv.c index 4ce1c3b..deb5dcd 100644 --- a/generic/tclEnv.c +++ b/generic/tclEnv.c @@ -1,4 +1,4 @@ -/* +/* * tclEnv.c -- * * Tcl support for environment variables, including a setenv @@ -699,83 +699,10 @@ TclFinalizeEnvironment() } } -#if defined(__CYGWIN__) && defined(__WIN32__) - -#include - /* - * When using cygwin, when an environment variable changes, we need to synch - * with both the cygwin environment (in case the application C code calls - * fork) and the Windows environment (in case the application TCL code calls - * exec, which calls the Windows CreateProcess function). + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: */ - -static void -TclCygwinPutenv(str) - const char *str; -{ - char *name, *value; - - /* Get the name and value, so that we can change the environment - variable for Windows. */ - name = (char *) alloca (strlen (str) + 1); - strcpy (name, str); - for (value = name; *value != '=' && *value != '\0'; ++value) - ; - if (*value == '\0') { - /* Can't happen. */ - return; - } - *value = '\0'; - ++value; - if (*value == '\0') { - value = NULL; - } - - /* Set the cygwin environment variable. */ -#undef putenv - if (value == NULL) { - unsetenv (name); - } else { - putenv(str); - } - - /* - * Before changing the environment variable in Windows, if this is PATH, - * we need to convert the value back to a Windows style path. - * - * FIXME: The calling program may know it is running under windows, and - * may have set the path to a Windows path, or, worse, appended or - * prepended a Windows path to PATH. - */ - if (strcmp (name, "PATH") != 0) { - /* If this is Path, eliminate any PATH variable, to prevent any - confusion. */ - if (strcmp (name, "Path") == 0) { - SetEnvironmentVariable ("PATH", (char *) NULL); - unsetenv ("PATH"); - } - - SetEnvironmentVariable (name, value); - } else { - char *buf; - - /* Eliminate any Path variable, to prevent any confusion. */ - SetEnvironmentVariable ("Path", (char *) NULL); - unsetenv ("Path"); - - if (value == NULL) { - buf = NULL; - } else { - int size; - - size = cygwin_posix_to_win32_path_list_buf_size (value); - buf = (char *) alloca (size + 1); - cygwin_posix_to_win32_path_list (value, buf); - } - - SetEnvironmentVariable (name, buf); - } -} - -#endif /* __CYGWIN__ && __WIN32__ */ diff --git a/generic/tclFileName.c b/generic/tclFileName.c index 8d30905..c70bed5 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -2645,17 +2645,6 @@ TclDoGlob(interp, separators, headPtr, tail, types) Tcl_DStringAppend(headPtr, ".", 1); } } -#if defined(__CYGWIN__) && defined(__WIN32__) - { - extern int cygwin_conv_to_win32_path - _ANSI_ARGS_((CONST char *, char *)); - char winbuf[MAX_PATH+1]; - - cygwin_conv_to_win32_path(Tcl_DStringValue(headPtr), winbuf); - Tcl_DStringFree(headPtr); - Tcl_DStringAppend(headPtr, winbuf, -1); - } -#endif /* __CYGWIN__ && __WIN32__ */ /* * Convert to forward slashes. This is required to pass * some Tcl tests. We should probably remove the conversions diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 6493b4e..af34797 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -86,7 +86,7 @@ Tcl_WinUtfToTChar(string, len, dsPtr) string, len, dsPtr); } -char * +static char * Tcl_WinTCharToUtf(string, len, dsPtr) CONST char *string; int len; diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index c0d81b1..5eac978 100644 --- a/unix/tclUnixFile.c +++ b/unix/tclUnixFile.c @@ -1,4 +1,4 @@ -/* +/* * tclUnixFile.c -- * * This file contains wrappers around UNIX file handling functions. @@ -820,3 +820,45 @@ TclpUtime(pathPtr, tval) { return utime(Tcl_FSGetNativePath(pathPtr),tval); } +#ifdef __CYGWIN__ +int TclOSstat(const char *name, Tcl_StatBuf *statBuf) { + struct stat buf; + int result = stat(name, &buf); + statBuf->st_mode = buf.st_mode; + statBuf->st_ino = buf.st_ino; + statBuf->st_dev = buf.st_dev; + statBuf->st_rdev = buf.st_rdev; + statBuf->st_nlink = buf.st_nlink; + statBuf->st_uid = buf.st_uid; + statBuf->st_gid = buf.st_gid; + statBuf->st_size = buf.st_size; + statBuf->st_atime = buf.st_atime; + statBuf->st_mtime = buf.st_mtime; + statBuf->st_ctime = buf.st_ctime; + return result; +} +int TclOSlstat(const char *name, Tcl_StatBuf *statBuf) { + struct stat buf; + int result = lstat(name, &buf); + statBuf->st_mode = buf.st_mode; + statBuf->st_ino = buf.st_ino; + statBuf->st_dev = buf.st_dev; + statBuf->st_rdev = buf.st_rdev; + statBuf->st_nlink = buf.st_nlink; + statBuf->st_uid = buf.st_uid; + statBuf->st_gid = buf.st_gid; + statBuf->st_size = buf.st_size; + statBuf->st_atime = buf.st_atime; + statBuf->st_mtime = buf.st_mtime; + statBuf->st_ctime = buf.st_ctime; + return result; +} +#endif + +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h index c1aaa63..e19a8ed 100644 --- a/unix/tclUnixPort.h +++ b/unix/tclUnixPort.h @@ -73,7 +73,13 @@ typedef off_t Tcl_SeekOffset; # define TclOSopen open #endif -#ifdef HAVE_STRUCT_STAT64 +#ifdef __CYGWIN__ +EXTERN int TclOSstat(const char *name, Tcl_StatBuf *statBuf); +EXTERN int TclOSlstat(const char *name, Tcl_StatBuf *statBuf); +#undef HAVE_ST_BLKSIZE +#define NO_FSTATFS +#undef HAVE_FTS +#elif defined(HAVE_STRUCT_STAT64) # define TclOSstat stat64 # define TclOSlstat lstat64 #else diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 4ed5a3d..2c6150f 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -1640,24 +1640,9 @@ TclpObjChdir(pathPtr) { int result; CONST TCHAR *nativePath; -#ifdef __CYGWIN__ - extern int cygwin_conv_to_posix_path - _ANSI_ARGS_((CONST char *, char *)); - char posixPath[MAX_PATH+1]; - CONST char *path; - Tcl_DString ds; -#endif /* __CYGWIN__ */ nativePath = (CONST TCHAR *) Tcl_FSGetNativePath(pathPtr); -#ifdef __CYGWIN__ - /* Cygwin chdir only groks POSIX path. */ - path = Tcl_WinTCharToUtf(nativePath, -1, &ds); - cygwin_conv_to_posix_path(path, posixPath); - result = (chdir(posixPath) == 0 ? 1 : 0); - Tcl_DStringFree(&ds); -#else /* __CYGWIN__ */ result = (*tclWinProcs->setCurrentDirectoryProc)(nativePath); -#endif /* __CYGWIN__ */ if (result == 0) { TclWinConvertError(GetLastError()); @@ -1666,51 +1651,6 @@ TclpObjChdir(pathPtr) return 0; } -#ifdef __CYGWIN__ -/* - *--------------------------------------------------------------------------- - * - * TclpReadlink -- - * - * This function replaces the library version of readlink(). - * - * Results: - * The result is a pointer to a string specifying the contents - * of the symbolic link given by 'path', or NULL if the symbolic - * link could not be read. Storage for the result string is - * allocated in bufferPtr; the caller must call Tcl_DStringFree() - * when the result is no longer needed. - * - * Side effects: - * See readlink() documentation. - * - *--------------------------------------------------------------------------- - */ - -char * -TclpReadlink(path, linkPtr) - CONST char *path; /* Path of file to readlink (UTF-8). */ - Tcl_DString *linkPtr; /* Uninitialized or free DString filled - * with contents of link (UTF-8). */ -{ - char link[MAXPATHLEN]; - int length; - char *native; - Tcl_DString ds; - - native = Tcl_UtfToExternalDString(NULL, path, -1, &ds); - length = readlink(native, link, sizeof(link)); /* INTL: Native. */ - Tcl_DStringFree(&ds); - - if (length < 0) { - return NULL; - } - - Tcl_ExternalToUtfDString(NULL, link, length, linkPtr); - return Tcl_DStringValue(linkPtr); -} -#endif /* __CYGWIN__ */ - /* *---------------------------------------------------------------------- * diff --git a/win/tclWinPort.h b/win/tclWinPort.h index dd42340..aca3279 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -98,25 +98,6 @@ typedef DWORD_PTR * PDWORD_PTR; #undef ENOTSUP #define ENOTSUP -1030507 -/* - * cygwin does not have this struct. - */ -#ifdef __CYGWIN__ - struct _stat32i64 { - dev_t st_dev; - ino_t st_ino; - unsigned short st_mode; - short st_nlink; - short st_uid; - short st_gid; - dev_t st_rdev; - __int64 st_size; - struct {long tv_sec;} st_atim; - struct {long tv_sec;} st_mtim; - struct {long tv_sec;} st_ctim; - }; -#endif - /* Those codes, from Visual Studio 2010, conflict with other values */ #undef ENODATA #undef ENOMSG @@ -374,14 +355,6 @@ typedef DWORD_PTR * PDWORD_PTR; # define environ _environ #endif /* __BORLANDC__ */ -#ifdef __CYGWIN__ -/* On Cygwin, the environment is imported from the Cygwin DLL. */ - DLLIMPORT extern char **__cygwin_environ; -# define environ __cygwin_environ -# define putenv TclCygwinPutenv -# define timezone _timezone -#endif /* __CYGWIN__ */ - /* * There is no platform-specific panic routine for Windows in the Tcl internals. */ @@ -430,18 +403,12 @@ typedef DWORD_PTR * PDWORD_PTR; * use by tclAlloc.c. */ -#ifdef __CYGWIN__ -# define TclpSysAlloc(size, isBin) malloc((size)) -# define TclpSysFree(ptr) free((ptr)) -# define TclpSysRealloc(ptr, size) realloc((ptr), (size)) -#else -# define TclpSysAlloc(size, isBin) ((void*)HeapAlloc(GetProcessHeap(), \ +#define TclpSysAlloc(size, isBin) ((void*)HeapAlloc(GetProcessHeap(), \ (DWORD)0, (DWORD)size)) -# define TclpSysFree(ptr) (HeapFree(GetProcessHeap(), \ +#define TclpSysFree(ptr) (HeapFree(GetProcessHeap(), \ (DWORD)0, (HGLOBAL)ptr)) -# define TclpSysRealloc(ptr, size) ((void*)HeapReAlloc(GetProcessHeap(), \ +#define TclpSysRealloc(ptr, size) ((void*)HeapReAlloc(GetProcessHeap(), \ (DWORD)0, (LPVOID)ptr, (DWORD)size)) -#endif /* * The following defines map from standard socket names to our internal -- cgit v0.12