From 7f06c57b4ac6b323f0332998d5143a1a72ca2210 Mon Sep 17 00:00:00 2001
From: "jan.nijtmans" <nijtmans@users.sourceforge.net>
Date: Mon, 12 Sep 2011 09:45:30 +0000
Subject: [Bug 3407070] tclPosixStr.c won't build with EOVERFLOW==E2BIG

---
 ChangeLog        |   5 ++
 win/tclWinPort.h | 191 ++++++++++++++++++++++---------------------------------
 2 files changed, 80 insertions(+), 116 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bae4b50..2f05189 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-09-12  Jan Nijtmans  <nijtmans@users.sf.net>
+
+	* win/tclWinPort.h: [Bug 3407070] tclPosixStr.c won't build with
+	EOVERFLOW==E2BIG
+
 2011-09-06  Jan Nijtmans  <nijtmans@users.sf.net>
 
 	* generic/tcl.decls: Tcl_HashStats does not return a CONST
diff --git a/win/tclWinPort.h b/win/tclWinPort.h
index f14e1a9..f61e427 100644
--- a/win/tclWinPort.h
+++ b/win/tclWinPort.h
@@ -82,17 +82,15 @@
  * Define EINPROGRESS in terms of WSAEINPROGRESS.
  */
 
-#ifndef	EINPROGRESS
-#   define EINPROGRESS	WSAEINPROGRESS
-#endif
+#undef	EINPROGRESS
+#define EINPROGRESS	WSAEINPROGRESS
 
 /*
- * If ENOTSUP is not defined, define it to a value that will never occur.
+ * Define ENOTSUP to a value that will never occur.
  */
 
-#ifndef ENOTSUP
-#   define ENOTSUP	-1030507
-#endif
+#undef ENOTSUP
+#define ENOTSUP	-1030507
 
 /*
  * Not all mingw32 versions have this struct.
@@ -124,108 +122,74 @@
  * BSD errors so Tcl_PosixError can do the right thing.
  */
 
-#ifndef EWOULDBLOCK
-#   define EWOULDBLOCK	EAGAIN
-#endif
-#ifndef EALREADY
-#   define EALREADY	149	/* operation already in progress */
-#endif
-#ifndef ENOTSOCK
-#   define ENOTSOCK	95	/* Socket operation on non-socket */
-#endif
-#ifndef EDESTADDRREQ
-#   define EDESTADDRREQ	96	/* Destination address required */
-#endif
-#ifndef EMSGSIZE
-#   define EMSGSIZE	97	/* Message too long */
-#endif
-#ifndef EPROTOTYPE
-#   define EPROTOTYPE	98	/* Protocol wrong type for socket */
-#endif
-#ifndef ENOPROTOOPT
-#   define ENOPROTOOPT	99	/* Protocol not available */
-#endif
-#ifndef EPROTONOSUPPORT
-#   define EPROTONOSUPPORT 120	/* Protocol not supported */
-#endif
-#ifndef ESOCKTNOSUPPORT
-#   define ESOCKTNOSUPPORT 121	/* Socket type not supported */
-#endif
-#ifndef EOPNOTSUPP
-#   define EOPNOTSUPP	122	/* Operation not supported on socket */
-#endif
-#ifndef EPFNOSUPPORT
-#   define EPFNOSUPPORT	123	/* Protocol family not supported */
-#endif
-#ifndef EAFNOSUPPORT
-#   define EAFNOSUPPORT	124	/* Address family not supported */
-#endif
-#ifndef EADDRINUSE
-#   define EADDRINUSE	125	/* Address already in use */
-#endif
-#ifndef EADDRNOTAVAIL
-#   define EADDRNOTAVAIL 126	/* Can't assign requested address */
-#endif
-#ifndef ENETDOWN
-#   define ENETDOWN	127	/* Network is down */
-#endif
-#ifndef ENETUNREACH
-#   define ENETUNREACH	128	/* Network is unreachable */
-#endif
-#ifndef ENETRESET
-#   define ENETRESET	129	/* Network dropped connection on reset */
-#endif
-#ifndef ECONNABORTED
-#   define ECONNABORTED	130	/* Software caused connection abort */
-#endif
-#ifndef ECONNRESET
-#   define ECONNRESET	131	/* Connection reset by peer */
-#endif
-#ifndef ENOBUFS
-#   define ENOBUFS	132	/* No buffer space available */
-#endif
-#ifndef EISCONN
-#   define EISCONN	133	/* Socket is already connected */
-#endif
-#ifndef ENOTCONN
-#   define ENOTCONN	134	/* Socket is not connected */
-#endif
-#ifndef ESHUTDOWN
-#   define ESHUTDOWN	143	/* Can't send after socket shutdown */
-#endif
-#ifndef ETOOMANYREFS
-#   define ETOOMANYREFS	144	/* Too many references: can't splice */
-#endif
-#ifndef ETIMEDOUT
-#   define ETIMEDOUT	145	/* Connection timed out */
-#endif
-#ifndef ECONNREFUSED
-#   define ECONNREFUSED	146	/* Connection refused */
-#endif
-#ifndef ELOOP
-#   define ELOOP	90	/* Symbolic link loop */
-#endif
-#ifndef EHOSTDOWN
-#   define EHOSTDOWN	147	/* Host is down */
-#endif
-#ifndef EHOSTUNREACH
-#   define EHOSTUNREACH	148	/* No route to host */
-#endif
-#ifndef ENOTEMPTY
-#   define ENOTEMPTY 	93	/* directory not empty */
-#endif
-#ifndef EUSERS
-#   define EUSERS	94	/* Too many users (for UFS) */
-#endif
-#ifndef EDQUOT
-#   define EDQUOT	69	/* Disc quota exceeded */
-#endif
-#ifndef ESTALE
-#   define ESTALE	151	/* Stale NFS file handle */
-#endif
-#ifndef EREMOTE
-#   define EREMOTE	66	/* The object is remote */
-#endif
+#undef EWOULDBLOCK
+#define EWOULDBLOCK	EAGAIN
+#undef EALREADY
+#define EALREADY	149	/* operation already in progress */
+#undef ENOTSOCK
+#define ENOTSOCK	95	/* Socket operation on non-socket */
+#undef EDESTADDRREQ
+#define EDESTADDRREQ	96	/* Destination address required */
+#undef EMSGSIZE
+#define EMSGSIZE	97	/* Message too long */
+#undef EPROTOTYPE
+#define EPROTOTYPE	98	/* Protocol wrong type for socket */
+#undef ENOPROTOOPT
+#define ENOPROTOOPT	99	/* Protocol not available */
+#undef EPROTONOSUPPORT
+#define EPROTONOSUPPORT 120	/* Protocol not supported */
+#undef ESOCKTNOSUPPORT
+#define ESOCKTNOSUPPORT 121	/* Socket type not supported */
+#undef EOPNOTSUPP
+#define EOPNOTSUPP	122	/* Operation not supported on socket */
+#undef EPFNOSUPPORT
+#define EPFNOSUPPORT	123	/* Protocol family not supported */
+#undef EAFNOSUPPORT
+#define EAFNOSUPPORT	124	/* Address family not supported */
+#undef EADDRINUSE
+#define EADDRINUSE	125	/* Address already in use */
+#undef EADDRNOTAVAIL
+#define EADDRNOTAVAIL 126	/* Can't assign requested address */
+#undef ENETDOWN
+#define ENETDOWN	127	/* Network is down */
+#undef ENETUNREACH
+#define ENETUNREACH	128	/* Network is unreachable */
+#undef ENETRESET
+#define ENETRESET	129	/* Network dropped connection on reset */
+#undef ECONNABORTED
+#define ECONNABORTED	130	/* Software caused connection abort */
+#undef ECONNRESET
+#define ECONNRESET	131	/* Connection reset by peer */
+#undef ENOBUFS
+#define ENOBUFS	132	/* No buffer space available */
+#undef EISCONN
+#define EISCONN	133	/* Socket is already connected */
+#undef ENOTCONN
+#define ENOTCONN	134	/* Socket is not connected */
+#undef ESHUTDOWN
+#define ESHUTDOWN	143	/* Can't send after socket shutdown */
+#undef ETOOMANYREFS
+#define ETOOMANYREFS	144	/* Too many references: can't splice */
+#undef ETIMEDOUT
+#define ETIMEDOUT	145	/* Connection timed out */
+#undef ECONNREFUSED
+#define ECONNREFUSED	146	/* Connection refused */
+#undef ELOOP
+#define ELOOP	90	/* Symbolic link loop */
+#undef EHOSTDOWN
+#define EHOSTDOWN	147	/* Host is down */
+#undef EHOSTUNREACH
+#define EHOSTUNREACH	148	/* No route to host */
+#undef ENOTEMPTY
+#define ENOTEMPTY 	93	/* directory not empty */
+#undef EUSERS
+#define EUSERS	94	/* Too many users (for UFS) */
+#undef EDQUOT
+#define EDQUOT	69	/* Disc quota exceeded */
+#undef ESTALE
+#define ESTALE	151	/* Stale NFS file handle */
+#undef EREMOTE
+#define EREMOTE	66	/* The object is remote */
 
 /*
  * It is very hard to determine how Windows reacts to attempting to
@@ -233,13 +197,8 @@
  * region.  So we fake the error code ourselves.
  */
 
-#ifndef EOVERFLOW
-#   ifdef EFBIG
-#      define EOVERFLOW	EFBIG	/* The object couldn't fit in the datatype */
-#   else /* !EFBIG */
-#      define EOVERFLOW	EINVAL	/* Better than nothing! */
-#   endif /* EFBIG */
-#endif /* !EOVERFLOW */
+#undef EOVERFLOW
+#define EOVERFLOW	EFBIG	/* The object couldn't fit in the datatype */
 
 /*
  * Supply definitions for macros to query wait status, if not already
-- 
cgit v0.12


From ed15644ca944ecc80a17fd622284ceb564443779 Mon Sep 17 00:00:00 2001
From: "jan.nijtmans" <nijtmans@users.sourceforge.net>
Date: Mon, 12 Sep 2011 10:08:16 +0000
Subject: Make compilable in Visual Studio again

---
 win/tclWinPort.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/win/tclWinPort.h b/win/tclWinPort.h
index f61e427..5f9e018 100644
--- a/win/tclWinPort.h
+++ b/win/tclWinPort.h
@@ -117,6 +117,13 @@
   };
 #endif
 
+/* Those codes, from Visual Studio 2010, conflict with other values */
+#undef ENODATA
+#undef ENOMSG
+#undef ENOSR
+#undef ENOSTR
+#undef EPROTO
+
 /*
  * The following defines redefine the Windows Socket errors as
  * BSD errors so Tcl_PosixError can do the right thing.
-- 
cgit v0.12

