summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-03-15 21:14:05 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-03-15 21:14:05 (GMT)
commit859cb34d2ddbdd2548004b0e044f759ed55e5ebe (patch)
tree208a77acdb455c105e739d589128c3dd644af53e
parent2bdb719524ba2e7826cfdf6a82bd80c2bcdd9c75 (diff)
parent5841a02367f05ffbefe36849606d77718a556cb2 (diff)
downloadtcl-859cb34d2ddbdd2548004b0e044f759ed55e5ebe.zip
tcl-859cb34d2ddbdd2548004b0e044f759ed55e5ebe.tar.gz
tcl-859cb34d2ddbdd2548004b0e044f759ed55e5ebe.tar.bz2
[Bug 3288345] Wrong Tcl_StatBuf used on Cygwin
-rw-r--r--ChangeLog9
-rw-r--r--generic/tcl.h18
-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.h51
7 files changed, 74 insertions, 113 deletions
diff --git a/ChangeLog b/ChangeLog
index 9794431..a8e4bb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-03-15 Jan Nijtmans <nijtmans@users.sf.net>
+
+ * generic/tcl.h: [Bug 3288345] Wrong Tcl_StatBuf used on Cygwin
+ * unix/tclUnixFile.c
+ * unix/tclUnixPort.h
+ * win/cat.c: Remove cygwin stuff no longer needed
+ * win/tclWinFile.c
+ * win/tclWinPort.h
+
2012-03-12 Jan Nijtmans <nijtmans@users.sf.net>
* win/tclWinFile.c: [Bug 3388350] mingw64 compiler warnings
diff --git a/generic/tcl.h b/generic/tcl.h
index 9fbe378..cb90096 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -373,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;
@@ -436,7 +436,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;
diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c
index c8afeb2..fe3c608 100644
--- a/unix/tclUnixFile.c
+++ b/unix/tclUnixFile.c
@@ -1178,6 +1178,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 2666fb5..48aef9c 100644
--- a/unix/tclUnixPort.h
+++ b/unix/tclUnixPort.h
@@ -78,7 +78,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 a67999f..d49e37c 100644
--- a/win/cat.c
+++ b/win/cat.c
@@ -16,11 +16,7 @@
#endif
#include <stdio.h>
-#ifdef __CYGWIN__
-# include <unistd.h>
-#else
-# include <io.h>
-#endif
+#include <io.h>
#include <string.h>
#include <tchar.h>
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index 6e7b4c2..dcc05bb 100644
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -1809,27 +1809,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 = 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 = SetCurrentDirectory(nativePath);
-#endif /* __CYGWIN__ */
if (result == 0) {
TclWinConvertError(GetLastError());
@@ -1838,51 +1821,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 e5dac8c..e3c5a49 100644
--- a/win/tclWinPort.h
+++ b/win/tclWinPort.h
@@ -92,21 +92,11 @@ typedef DWORD_PTR * PDWORD_PTR;
#include <signal.h>
#include <limits.h>
-#ifdef __CYGWIN__
-# include <unistd.h>
-# ifndef _vsnprintf
-# define _vsnprintf vsnprintf
-# endif
-# 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
/*
@@ -127,25 +117,6 @@ typedef DWORD_PTR * PDWORD_PTR;
#include <time.h>
/*
- * 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
-
-/*
* The following defines redefine the Windows Socket errors as
* BSD errors so Tcl_PosixError can do the right thing.
*/
@@ -549,18 +520,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