summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tcl.h20
-rw-r--r--generic/tclIntPlatDecls.h6
-rw-r--r--unix/tclUnixFile.c34
-rw-r--r--unix/tclUnixPort.h7
-rw-r--r--win/cat.c6
-rw-r--r--win/tclWinFile.c62
-rw-r--r--win/tclWinPort.h55
7 files changed, 70 insertions, 120 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index 21cd0c4..33fcb6f 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -352,7 +352,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;
@@ -415,7 +415,21 @@ typedef struct stat Tcl_StatBuf;
* 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;
@@ -427,7 +441,7 @@ typedef struct stat Tcl_StatBuf;
# define Tcl_WideAsDouble(val) ((double)((Tcl_WideInt)(val)))
# define Tcl_DoubleAsWide(val) ((Tcl_WideInt)((double)(val)))
#endif /* TCL_WIDE_INT_IS_LONG */
-
+
/*
* Data structures defined opaquely in this module. The definitions below just
* provide dummy types. A few fields are made visible in Tcl_Interp
diff --git a/generic/tclIntPlatDecls.h b/generic/tclIntPlatDecls.h
index 3c03015..13e82b9 100644
--- a/generic/tclIntPlatDecls.h
+++ b/generic/tclIntPlatDecls.h
@@ -36,7 +36,7 @@
* Exported function declarations:
*/
-#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
+#if defined(__CYGWIN__) || !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
#ifndef TclGetAndDetachPids_TCL_DECLARED
#define TclGetAndDetachPids_TCL_DECLARED
/* 0 */
@@ -375,7 +375,7 @@ typedef struct TclIntPlatStubs {
int magic;
struct TclIntPlatStubHooks *hooks;
-#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
+#if defined(__CYGWIN__) || !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
void (*tclGetAndDetachPids) (Tcl_Interp *interp, Tcl_Channel chan); /* 0 */
int (*tclpCloseFile) (TclFile file); /* 1 */
Tcl_Channel (*tclpCreateCommandChannel) (TclFile readFile, TclFile writeFile, TclFile errorFile, int numPids, Tcl_Pid *pidPtr); /* 2 */
@@ -462,7 +462,7 @@ extern TclIntPlatStubs *tclIntPlatStubsPtr;
* Inline function declarations:
*/
-#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
+#if defined(__CYGWIN__) || !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
#ifndef TclGetAndDetachPids
#define TclGetAndDetachPids \
(tclIntPlatStubsPtr->tclGetAndDetachPids) /* 0 */
diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c
index 2639d59..7d82d1d 100644
--- a/unix/tclUnixFile.c
+++ b/unix/tclUnixFile.c
@@ -1164,6 +1164,40 @@ TclpUtime(
{
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:
diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h
index e4008c9..fef748b 100644
--- a/unix/tclUnixPort.h
+++ b/unix/tclUnixPort.h
@@ -73,7 +73,12 @@ typedef off_t Tcl_SeekOffset;
# define TclOSopen open
#endif
-#ifdef HAVE_STRUCT_STAT64
+#ifdef __CYGWIN__
+MODULE_SCOPE int TclOSstat(const char *name, Tcl_StatBuf *statBuf);
+MODULE_SCOPE int TclOSlstat(const char *name, Tcl_StatBuf *statBuf);
+#undef HAVE_STRUCT_STAT_ST_BLOCKS
+#undef HAVE_STRUCT_STAT_ST_BLKSIZE
+#elif defined(HAVE_STRUCT_STAT64)
# define TclOSstat stat64
# define TclOSlstat lstat64
#else
diff --git a/win/cat.c b/win/cat.c
index 2cedd5d..d413923 100644
--- a/win/cat.c
+++ b/win/cat.c
@@ -10,11 +10,7 @@
*/
#include <stdio.h>
-#ifdef __CYGWIN__
-# include <unistd.h>
-#else
-# include <io.h>
-#endif
+#include <io.h>
#include <string.h>
int
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index f764ad8..a9b321d 100644
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -1850,27 +1850,10 @@ TclpObjChdir(
{
int result;
const TCHAR *nativePath;
-#ifdef __CYGWIN__
- extern int cygwin_conv_to_posix_path(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());
@@ -1879,51 +1862,6 @@ TclpObjChdir(
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(
- 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 4855d12..e2cac52 100644
--- a/win/tclWinPort.h
+++ b/win/tclWinPort.h
@@ -51,12 +51,7 @@ typedef DWORD_PTR * PDWORD_PTR;
*---------------------------------------------------------------------------
*/
-#ifdef __CYGWIN__
-# include <unistd.h>
-# include <wchar.h>
-#else
-# include <io.h>
-#endif
+#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@@ -68,18 +63,11 @@ typedef DWORD_PTR * PDWORD_PTR;
#include <string.h>
#include <limits.h>
-#ifdef __CYGWIN__
-# include <unistd.h>
-# ifndef _wcsicmp
-# define _wcsicmp wcscasecmp
-# endif
-#else
-# ifndef strncasecmp
-# define strncasecmp strnicmp
-# endif
-# ifndef strcasecmp
-# define strcasecmp stricmp
-# endif
+#ifndef strncasecmp
+# define strncasecmp strnicmp
+#endif
+#ifndef strcasecmp
+# define strcasecmp stricmp
#endif
/*
@@ -113,25 +101,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
@@ -478,18 +447,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